GetNetworkDescription
        (
            String sUserNameToAnalyze,
            WhatToInclude eWhatToInclude,
            NetworkLevel eNetworkLevel,
            Int32 iMaximumPeoplePerRequest
        )
        {
            Debug.Assert(!String.IsNullOrEmpty(sUserNameToAnalyze));
            Debug.Assert(iMaximumPeoplePerRequest > 0);
            AssertValid();

            NetworkDescriber oNetworkDescriber = new NetworkDescriber();

            oNetworkDescriber.AddSentence(

                "The graph represents the {0} YouTube network of the user with the"
                + " username \"{1}\"."
                ,
                NetworkLevelToString(eNetworkLevel),
                sUserNameToAnalyze
                );

            oNetworkDescriber.AddNetworkTime(NetworkSource);

            oNetworkDescriber.StartNewParagraph();

            if (WhatToIncludeFlagIsSet(eWhatToInclude,
                                       WhatToInclude.FriendVertices))
            {
                oNetworkDescriber.AddSentence(
                    "There is a vertex for each friend of the user."
                    );
            }

            if (WhatToIncludeFlagIsSet(eWhatToInclude,
                                       WhatToInclude.SubscriptionVertices))
            {
                oNetworkDescriber.AddSentence(
                    "There is a vertex for each person or channel subscribed to by"
                    + " the user."
                    );
            }

            oNetworkDescriber.AddNetworkLimit(iMaximumPeoplePerRequest, "people");

            return(oNetworkDescriber.ConcatenateSentences());
        }
        GetNetworkDescription
        (
            String sSearchTerm,
            WhatToInclude eWhatToInclude,
            Int32 iMaximumVideos
        )
        {
            Debug.Assert(!String.IsNullOrEmpty(sSearchTerm));
            Debug.Assert(iMaximumVideos > 0);
            AssertValid();

            NetworkDescriber oNetworkDescriber = new NetworkDescriber();

            oNetworkDescriber.AddSentence(

                "The graph represents the network of YouTube videos whose title,"
                + " keywords, description, categories, or author\'s username"
                + " contain \"{0}\"."
                ,
                sSearchTerm
                );

            oNetworkDescriber.AddNetworkTime(NetworkSource);

            oNetworkDescriber.StartNewParagraph();
            oNetworkDescriber.AddNetworkLimit(iMaximumVideos, "videos");

            if (WhatToIncludeFlagIsSet(eWhatToInclude,

                                       WhatToInclude.SharedCategoryEdges
                                       |
                                       WhatToInclude.SharedCommenterEdges
                                       |
                                       WhatToInclude.SharedVideoResponderEdges
                                       ))
            {
                oNetworkDescriber.StartNewParagraph();
            }

            if (WhatToIncludeFlagIsSet(eWhatToInclude,
                                       WhatToInclude.SharedCategoryEdges))
            {
                oNetworkDescriber.AddSentence(
                    "There is an edge for each pair of videos that have the same"
                    + " category."
                    );
            }

            if (WhatToIncludeFlagIsSet(eWhatToInclude,
                                       WhatToInclude.SharedCommenterEdges))
            {
                oNetworkDescriber.AddSentence(
                    "There is an edge for each pair of videos commented on by the"
                    + " same user."
                    );
            }

            if (WhatToIncludeFlagIsSet(eWhatToInclude,
                                       WhatToInclude.SharedVideoResponderEdges))
            {
                oNetworkDescriber.AddSentence(
                    "There is an edge for each pair of videos responded to with"
                    + " another video by the same user."
                    );
            }

            return(oNetworkDescriber.ConcatenateSentences());
        }
    GetNetworkDescription
    (
        String sSearchTerm,
        DateTime oMinimumStatusDateUtc,
        DateTime oMaximumStatusDateUtc,
        String sGraphServerUserName,
        String sGraphServerPassword,
        XmlDocument oGraphMLXmlDocument
    )
    {
        Debug.Assert( !String.IsNullOrEmpty(sSearchTerm) );
        Debug.Assert(oMaximumStatusDateUtc >= oMinimumStatusDateUtc);
        Debug.Assert( !String.IsNullOrEmpty(sGraphServerUserName) );
        Debug.Assert( !String.IsNullOrEmpty(sGraphServerPassword) );
        Debug.Assert(oGraphMLXmlDocument != null);
        AssertValid();

        const String Int32FormatString = "N0";

        NetworkDescriber oNetworkDescriber = new NetworkDescriber();

        Int32 iVertexCount = GetVertexCount(oGraphMLXmlDocument);

        oNetworkDescriber.AddSentence(

            "The graph represents a network of {0} Twitter {1} whose tweets in"
            + " the requested date range contained \"{2}\", or who {3} replied"
            + " to or mentioned in those tweets."
            ,
            iVertexCount.ToString(Int32FormatString),
            StringUtil.MakePlural("user", iVertexCount),
            sSearchTerm,
			iVertexCount > 1 ? "were" : "was"
            );

        oNetworkDescriber.AddNetworkTime(NetworkSource);

        oNetworkDescriber.AddSentenceNewParagraph(

            "The requested date range was from {0} through {1}."
            ,
            oNetworkDescriber.FormatEventTime(oMinimumStatusDateUtc),
            oNetworkDescriber.FormatEventTime(oMaximumStatusDateUtc)
            );

        oNetworkDescriber.StartNewParagraph();

        TweetDateRangeAnalyzer.AddTweetDateRangeToNetworkDescription(
            oGraphMLXmlDocument, oNetworkDescriber);

        oNetworkDescriber.AddSentenceNewParagraph(
            "There is an edge for each \"replies-to\" relationship in a tweet,"
            + " an edge for each \"mentions\" relationship in a tweet, and a"
            + " self-loop edge for each tweet that is not a \"replies-to\" or"
            + " \"mentions\"."
            );

        return ( oNetworkDescriber.ConcatenateSentences() );
    }
    GetNetworkDescription
    (
        String sSearchTerm,
        WhatToInclude eWhatToInclude,
        Int32 iMaximumVideos
    )
    {
        Debug.Assert( !String.IsNullOrEmpty(sSearchTerm) );
        Debug.Assert(iMaximumVideos > 0);
        AssertValid();

        NetworkDescriber oNetworkDescriber = new NetworkDescriber();

        oNetworkDescriber.AddSentence(

            "The graph represents the network of YouTube videos whose title,"
            + " keywords, description, categories, or author\'s username"
            + " contain \"{0}\"."
            ,
            sSearchTerm
            );

        oNetworkDescriber.AddNetworkTime(NetworkSource);

        oNetworkDescriber.StartNewParagraph();
        oNetworkDescriber.AddNetworkLimit(iMaximumVideos, "videos");

        if ( WhatToIncludeFlagIsSet(eWhatToInclude,

            WhatToInclude.SharedCategoryEdges
            |
            WhatToInclude.SharedCommenterEdges
            |
            WhatToInclude.SharedVideoResponderEdges
            ) )
        {
            oNetworkDescriber.StartNewParagraph();
        }

        if ( WhatToIncludeFlagIsSet(eWhatToInclude,
            WhatToInclude.SharedCategoryEdges) )
        {
            oNetworkDescriber.AddSentence(
                "There is an edge for each pair of videos that have the same"
                + " category."
                );
        }

        if ( WhatToIncludeFlagIsSet(eWhatToInclude,
            WhatToInclude.SharedCommenterEdges) )
        {
            oNetworkDescriber.AddSentence(
                "There is an edge for each pair of videos commented on by the"
                + " same user."
                );
        }

        if ( WhatToIncludeFlagIsSet(eWhatToInclude,
            WhatToInclude.SharedVideoResponderEdges) )
        {
            oNetworkDescriber.AddSentence(
                "There is an edge for each pair of videos responded to with"
                + " another video by the same user."
                );
        }

        return ( oNetworkDescriber.ConcatenateSentences() );
    }
    GetNetworkDescription
    (
        Boolean bUseListName,
        String sListName,
        ICollection<String> oScreenNames,
        WhatToInclude eWhatToInclude
    )
    {
        Debug.Assert( !bUseListName || !String.IsNullOrEmpty(sListName) );
        Debug.Assert(bUseListName || oScreenNames != null);
        AssertValid();

        NetworkDescriber oNetworkDescriber = new NetworkDescriber();

        if (bUseListName)
        {
            oNetworkDescriber.AddSentence(

                "The graph represents the network of Twitter users in the"
                + " Twitter List \"{0}\"."
                ,
                sListName
                );
        }
        else
        {
            oNetworkDescriber.AddSentence(

                "The graph represents a network of {0} specified Twitter"
                + " users."
                ,
                oScreenNames.Count
                );
        }

        oNetworkDescriber.AddNetworkTime(NetworkSource);

        if ( WhatToIncludeFlagIsSet(eWhatToInclude,

            WhatToInclude.FollowedEdges
            |
            WhatToInclude.RepliesToEdges
            |
            WhatToInclude.MentionsEdges
            ) )
        {
            oNetworkDescriber.StartNewParagraph();
        }

        if ( WhatToIncludeFlagIsSet(eWhatToInclude,
            WhatToInclude.FollowedEdges) )
        {
            oNetworkDescriber.AddSentence(
                "There is an edge for each follows relationship."
                );
        }

        if ( WhatToIncludeFlagIsSet(eWhatToInclude,
            WhatToInclude.RepliesToEdges) )
        {
            oNetworkDescriber.AddSentence(
                "There is an edge for each \"replies-to\" relationship in the"
                + " user's latest tweet."
                );
        }

        if ( WhatToIncludeFlagIsSet(eWhatToInclude,
            WhatToInclude.MentionsEdges) )
        {
            oNetworkDescriber.AddSentence(
                "There is an edge for each \"mentions\" relationship in the"
                + " user's latest tweet."
                );
        }

        return ( oNetworkDescriber.ConcatenateSentences() );
    }
    GetNetworkDescription
    (
        String sSearchTerm,
        WhatToInclude eWhatToInclude,
        Int32 iMaximumStatuses,
        GraphMLXmlDocument oGraphMLXmlDocument
    )
    {
        Debug.Assert( !String.IsNullOrEmpty(sSearchTerm) );
        Debug.Assert(iMaximumStatuses > 0);
        Debug.Assert(iMaximumStatuses != Int32.MaxValue);
        Debug.Assert(oGraphMLXmlDocument != null);
        AssertValid();

        const String Int32FormatString = "N0";

        NetworkDescriber oNetworkDescriber = new NetworkDescriber();
        Int32 iVertexXmlNodes = oGraphMLXmlDocument.VertexXmlNodes;

        oNetworkDescriber.AddSentence(

            // WARNING:
            //
            // If you change this first sentence, you may also have to change
            // the code in
            // TwitterSearchNetworkTopItemsCalculator2.GetSearchTerm(), which
            // attempts to extract the search term from the graph description.

            "The graph represents a network of {0} Twitter {1} whose recent"
            + " tweets contained \"{2}\", or who {3} replied to or mentioned"
            + " in those tweets, taken from a data set limited to a maximum of"
            + " {4} tweets."
            ,
            iVertexXmlNodes.ToString(Int32FormatString),
            StringUtil.MakePlural("user", iVertexXmlNodes),
            sSearchTerm,
            iVertexXmlNodes > 1 ? "were" : "was",
            iMaximumStatuses.ToString(Int32FormatString)
            );

        oNetworkDescriber.AddNetworkTime(NetworkSource);

        Boolean bIncludeFollowedEdges = WhatToIncludeFlagIsSet(eWhatToInclude,
            WhatToInclude.FollowedEdges);

        Boolean bIncludeRepliesToEdges = WhatToIncludeFlagIsSet(eWhatToInclude,
            WhatToInclude.RepliesToEdges);

        Boolean bIncludeMentionsEdges = WhatToIncludeFlagIsSet(eWhatToInclude,
            WhatToInclude.MentionsEdges);

        Boolean bIncludeNonRepliesToNonMentionsEdges = WhatToIncludeFlagIsSet(
            eWhatToInclude, WhatToInclude.NonRepliesToNonMentionsEdges);

        if (bIncludeRepliesToEdges && bIncludeMentionsEdges &&
            bIncludeNonRepliesToNonMentionsEdges)
        {
            // Every collected tweet has an edge that contains the date of the
            // tweet, so the range of tweet dates can be determined.

            oNetworkDescriber.StartNewParagraph();

            TweetDateRangeAnalyzer.AddTweetDateRangeToNetworkDescription(
                oGraphMLXmlDocument, oNetworkDescriber);
        }

        if (bIncludeFollowedEdges || bIncludeRepliesToEdges ||
            bIncludeMentionsEdges || bIncludeNonRepliesToNonMentionsEdges)
        {
            oNetworkDescriber.StartNewParagraph();
        }

        if (bIncludeFollowedEdges)
        {
            oNetworkDescriber.AddSentence(
                "There is an edge for each follows relationship."
                );
        }

        if (bIncludeRepliesToEdges)
        {
            oNetworkDescriber.AddSentence(
                "There is an edge for each \"replies-to\" relationship in a"
                + " tweet."
                );
        }

        if (bIncludeMentionsEdges)
        {
            oNetworkDescriber.AddSentence(
                "There is an edge for each \"mentions\" relationship in a"
                + " tweet."
                );
        }

        if (bIncludeNonRepliesToNonMentionsEdges)
        {
            oNetworkDescriber.AddSentence(
                "There is a self-loop edge for each tweet that is not a"
                + " \"replies-to\" or \"mentions\"."
                );
        }

        return ( oNetworkDescriber.ConcatenateSentences() );
    }
    GetNetworkDescription
    (
        String sScreenName,
        WhatToInclude eWhatToInclude,
        NetworkLevel eNetworkLevel,
        Int32 iMaximumPerRequest
    )
    {
        Debug.Assert( !String.IsNullOrEmpty(sScreenName) );
        Debug.Assert(iMaximumPerRequest > 0);
        AssertValid();

        NetworkDescriber oNetworkDescriber = new NetworkDescriber();

        oNetworkDescriber.AddSentence(

            "The graph represents the {0} Flickr network of the user with the"
            + " screen name \"{1}\"."
            ,
            NetworkLevelToString(eNetworkLevel),
            sScreenName
            );

        oNetworkDescriber.AddNetworkTime(NetworkSource);

        oNetworkDescriber.StartNewParagraph();

        if ( WhatToIncludeFlagIsSet(eWhatToInclude,
            WhatToInclude.ContactVertices) )
        {
            oNetworkDescriber.AddSentence(
                "There is a vertex for each contact of the user."
                );
        }

        if ( WhatToIncludeFlagIsSet(eWhatToInclude,
            WhatToInclude.CommenterVertices) )
        {
            oNetworkDescriber.AddSentence(
                "There is a vertex for each person who commented on the user's"
                + " photos."
                );
        }

        oNetworkDescriber.AddNetworkLimit(iMaximumPerRequest, "people");

        return ( oNetworkDescriber.ConcatenateSentences() );
    }
Beispiel #8
0
        GetNetworkDescription
        (
            String sSearchTerm,
            WhatToInclude eWhatToInclude,
            Int32 iMaximumStatuses,
            GraphMLXmlDocument oGraphMLXmlDocument
        )
        {
            Debug.Assert(!String.IsNullOrEmpty(sSearchTerm));
            Debug.Assert(iMaximumStatuses > 0);
            Debug.Assert(iMaximumStatuses != Int32.MaxValue);
            Debug.Assert(oGraphMLXmlDocument != null);
            AssertValid();

            const String Int32FormatString = "N0";

            NetworkDescriber oNetworkDescriber = new NetworkDescriber();
            Int32            iVertexXmlNodes   = oGraphMLXmlDocument.VertexXmlNodes;

            oNetworkDescriber.AddSentence(

                // WARNING:
                //
                // If you change this first sentence, you may also have to change
                // the code in
                // TwitterSearchNetworkTopItemsCalculator2.GetSearchTerm(), which
                // attempts to extract the search term from the graph description.

                "The graph represents a network of {0} Twitter {1} whose recent"
                + " tweets contained \"{2}\", or who {3} replied to or mentioned"
                + " in those tweets, taken from a data set limited to a maximum of"
                + " {4} tweets."
                ,
                iVertexXmlNodes.ToString(Int32FormatString),
                StringUtil.MakePlural("user", iVertexXmlNodes),
                sSearchTerm,
                iVertexXmlNodes > 1 ? "were" : "was",
                iMaximumStatuses.ToString(Int32FormatString)
                );

            oNetworkDescriber.AddNetworkTime(NetworkSource);

            Boolean bIncludeFollowedEdges = WhatToIncludeFlagIsSet(eWhatToInclude,
                                                                   WhatToInclude.FollowedEdges);

            // Every collected tweet has an edge that contains the date of the
            // tweet, so the range of tweet dates can be determined.

            oNetworkDescriber.StartNewParagraph();

            TweetDateRangeAnalyzer.AddTweetDateRangeToNetworkDescription(
                oGraphMLXmlDocument, oNetworkDescriber);

            if (bIncludeFollowedEdges)
            {
                oNetworkDescriber.StartNewParagraph();

                oNetworkDescriber.AddSentence(
                    "There is an edge for each friend relationship."
                    );
            }

            oNetworkDescriber.AddSentence(
                "There is an edge for each \"replies-to\" relationship in a"
                + " tweet, an edge for each \"mentions\" relationship in a tweet,"
                + " and a self-loop edge for each tweet that is not a"
                + " \"replies-to\" or \"mentions\"."
                );

            return(oNetworkDescriber.ConcatenateSentences());
        }
    GetNetworkDescription
    (
        String sUserNameToAnalyze,
        WhatToInclude eWhatToInclude,
        NetworkLevel eNetworkLevel,
        Int32 iMaximumPeoplePerRequest
    )
    {
        Debug.Assert( !String.IsNullOrEmpty(sUserNameToAnalyze) );
        Debug.Assert(iMaximumPeoplePerRequest > 0);
        AssertValid();

        NetworkDescriber oNetworkDescriber = new NetworkDescriber();

        oNetworkDescriber.AddSentence(

            "The graph represents the {0} YouTube network of the user with the"
            + " username \"{1}\"."
            ,
            NetworkLevelToString(eNetworkLevel),
            sUserNameToAnalyze
            );

        oNetworkDescriber.AddNetworkTime(NetworkSource);

        oNetworkDescriber.StartNewParagraph();

        if ( WhatToIncludeFlagIsSet(eWhatToInclude,
            WhatToInclude.FriendVertices) )
        {
            oNetworkDescriber.AddSentence(
                "There is a vertex for each friend of the user."
                );
        }

        if ( WhatToIncludeFlagIsSet(eWhatToInclude,
            WhatToInclude.SubscriptionVertices) )
        {
            oNetworkDescriber.AddSentence(
                "There is a vertex for each person or channel subscribed to by"
                + " the user."
                );
        }

        oNetworkDescriber.AddNetworkLimit(iMaximumPeoplePerRequest, "people");

        return ( oNetworkDescriber.ConcatenateSentences() );
    }
    GetNetworkDescription
    (
        String sScreenNameToAnalyze,
        WhatToInclude eWhatToInclude,
        NetworkLevel eNetworkLevel,
        Int32 iMaximumPeoplePerRequest
    )
    {
        Debug.Assert( !String.IsNullOrEmpty(sScreenNameToAnalyze) );
        Debug.Assert(iMaximumPeoplePerRequest > 0);
        AssertValid();

        NetworkDescriber oNetworkDescriber = new NetworkDescriber();

        oNetworkDescriber.AddSentence(

            "The graph represents the {0} Twitter network of the user with the"
            + " username \"{1}\"."
            ,
            NetworkLevelToString(eNetworkLevel),
            sScreenNameToAnalyze
            );

        oNetworkDescriber.AddNetworkTime(NetworkSource);

        oNetworkDescriber.StartNewParagraph();

        Boolean bFollowedVertices = WhatToIncludeFlagIsSet(eWhatToInclude,
            WhatToInclude.FollowedVertices);

        Boolean bFollowerVertices = WhatToIncludeFlagIsSet(eWhatToInclude,
            WhatToInclude.FollowerVertices);

        if (bFollowedVertices)
        {
            oNetworkDescriber.AddSentence(
                "There is a vertex for each person followed by the user."
                );
        }

        if (bFollowerVertices)
        {
            oNetworkDescriber.AddSentence(
                "There is a vertex for each person following the user."
                );
        }

        oNetworkDescriber.AddNetworkLimit(iMaximumPeoplePerRequest, "people");

        if ( WhatToIncludeFlagIsSet(eWhatToInclude,

            WhatToInclude.FollowedFollowerEdges
            |
            WhatToInclude.RepliesToEdges
            |
            WhatToInclude.MentionsEdges
            ) )
        {
            oNetworkDescriber.StartNewParagraph();
        }

        if ( WhatToIncludeFlagIsSet(eWhatToInclude,
            WhatToInclude.FollowedFollowerEdges) )
        {
            if (bFollowedVertices)
            {
                oNetworkDescriber.AddSentence(
                    "There is an edge for each followed relationship."
                    );
            }

            if (bFollowerVertices)
            {
                oNetworkDescriber.AddSentence(
                    "There is an edge for each following relationship."
                    );
            }
        }

        if ( WhatToIncludeFlagIsSet(eWhatToInclude,
            WhatToInclude.RepliesToEdges) )
        {
            oNetworkDescriber.AddSentence(
                "There is an edge for each \"replies-to\" relationship in the"
                + " user's latest tweet."
                );
        }

        if ( WhatToIncludeFlagIsSet(eWhatToInclude,
            WhatToInclude.MentionsEdges) )
        {
            oNetworkDescriber.AddSentence(
                "There is an edge for each \"mentions\" relationship in the"
                + " user's latest tweet."
                );
        }

        return ( oNetworkDescriber.ConcatenateSentences() );
    }
Beispiel #11
0
        GetNetworkDescription
        (
            StatusCriteria oStatusCriteria,
            XmlDocument oGraphMLXmlDocument
        )
        {
            Debug.Assert(oStatusCriteria != null);
            Debug.Assert(oGraphMLXmlDocument != null);
            AssertValid();

            const String Int32FormatString = "N0";

            NetworkDescriber oNetworkDescriber = new NetworkDescriber();

            Int32 iVertexCount = GetVertexCount(oGraphMLXmlDocument);

            oNetworkDescriber.AddSentence(

                "The graph represents a network of {0} Twitter {1} whose tweets in"
                + " the requested range contained \"{2}\", or who {3} replied to"
                + " or mentioned in those tweets."
                ,
                iVertexCount.ToString(Int32FormatString),
                StringUtil.MakePlural("user", iVertexCount),
                oStatusCriteria.SearchTerm,
                iVertexCount > 1 ? "were" : "was"
                );

            oNetworkDescriber.AddNetworkTime(NetworkSource);

            if (oStatusCriteria.HasDateRange)
            {
                oNetworkDescriber.AddSentenceNewParagraph(

                    "The requested date range was from {0} through {1}."
                    ,
                    oNetworkDescriber.FormatEventTime(
                        oStatusCriteria.MinimumStatusDateUtc),

                    oNetworkDescriber.FormatEventTime(
                        oStatusCriteria.MaximumStatusDateUtc)
                    );
            }
            else
            {
                oNetworkDescriber.AddSentenceNewParagraph(

                    "The requested start date was {0} and the maximum number of"
                    + " tweets (going backward in time) was {1}."
                    ,
                    oNetworkDescriber.FormatEventTime(
                        oStatusCriteria.MaximumStatusDateUtc),

                    oStatusCriteria.MaximumStatusesGoingBackward.ToString(
                        Int32FormatString)
                    );
            }

            oNetworkDescriber.StartNewParagraph();

            TweetDateRangeAnalyzer.AddTweetDateRangeToNetworkDescription(
                oGraphMLXmlDocument, oNetworkDescriber);

            oNetworkDescriber.AddSentenceNewParagraph(
                "There is an edge for each \"replies-to\" relationship in a tweet,"
                + " an edge for each \"mentions\" relationship in a tweet, and a"
                + " self-loop edge for each tweet that is not a \"replies-to\" or"
                + " \"mentions\"."
                );

            return(oNetworkDescriber.ConcatenateSentences());
        }