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 sTag, WhatToInclude eWhatToInclude, NetworkLevel eNetworkLevel ) { Debug.Assert(!String.IsNullOrEmpty(sTag)); AssertValid(); NetworkDescriber oNetworkDescriber = new NetworkDescriber(); oNetworkDescriber.AddSentence( "The graph represents the {0} network of Flickr tags related to" + " the tag \"{1}\"." , NetworkLevelToString(eNetworkLevel), sTag ); oNetworkDescriber.AddNetworkTime(NetworkSource); 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()); }
AddTweetDateRangeToNetworkDescription ( XmlDocument graphMLXmlDocument, NetworkDescriber networkDescriber ) { Debug.Assert(graphMLXmlDocument != null); Debug.Assert(networkDescriber != null); XmlNamespaceManager oXmlNamespaceManager = new XmlNamespaceManager( graphMLXmlDocument.NameTable); oXmlNamespaceManager.AddNamespace("g", GraphMLXmlDocument.GraphMLNamespaceUri); DateTime oMinimumRelationshipDateUtc = DateTime.MaxValue; DateTime oMaximumRelationshipDateUtc = DateTime.MinValue; // Loop through the graph's edges. foreach ( XmlNode oEdgeXmlNode in graphMLXmlDocument.DocumentElement.SelectNodes( "g:graph/g:edge", oXmlNamespaceManager) ) { // Get the value of the edge's "relationship" GraphML-Attribute. String sRelationship; if ( !TryGetEdgeGraphMLAttributeValue(oEdgeXmlNode, NodeXLGraphMLUtil.EdgeRelationshipID, oXmlNamespaceManager, out sRelationship) ) { continue; } switch (sRelationship) { case TwitterGraphMLUtil.RepliesToRelationship: case TwitterGraphMLUtil.MentionsRelationship: case TwitterGraphMLUtil.NonRepliesToNonMentionsRelationship: // Get the value of the edge's "relationship date" // GraphML-Attribute. String sRelationshipDateUtc; if ( !TryGetEdgeGraphMLAttributeValue(oEdgeXmlNode, TwitterGraphMLUtil.EdgeRelationshipDateUtcID, oXmlNamespaceManager, out sRelationshipDateUtc) ) { break; } DateTime oRelationshipDateUtc; try { // Note that the relationship date may be in an // unrecognized format. oRelationshipDateUtc = DateTimeUtil2.FromCultureInvariantString( sRelationshipDateUtc); } catch (FormatException) { break; } if (oRelationshipDateUtc < oMinimumRelationshipDateUtc) { oMinimumRelationshipDateUtc = oRelationshipDateUtc; } if (oRelationshipDateUtc > oMaximumRelationshipDateUtc) { oMaximumRelationshipDateUtc = oRelationshipDateUtc; } break; default: break; } } if (oMinimumRelationshipDateUtc != DateTime.MaxValue) { networkDescriber.AddSentence( "The tweets in the network were tweeted over the {0} period" + " from {1} to {2}." , networkDescriber.FormatDuration(oMinimumRelationshipDateUtc, oMaximumRelationshipDateUtc), networkDescriber.FormatEventTime(oMinimumRelationshipDateUtc), networkDescriber.FormatEventTime(oMaximumRelationshipDateUtc) ); } }
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 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 ( 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 ( JSONObject streamPosts, String fanPageUsernameID, List<NetworkType> netTypes, int iFromPost, int iToPost, DateTime fromDate, DateTime endDate, GraphMLXmlDocument oGraphMLXmlDocument ) { Debug.Assert(oGraphMLXmlDocument != null); AssertValid(); NetworkDescriber oNetworkDescriber = new NetworkDescriber(); oNetworkDescriber.AddSentence( "The graph represents the {0} network of the \"{1}\" Facebook fan page.", ConcatenateNetworkTypes(netTypes),fanPageUsernameID ); oNetworkDescriber.AddNetworkTime(); if (iFromPost > 0 && iToPost >0) { oNetworkDescriber.AddSentence( "Wall post from {0} to {1} of the fan page are analyzed.", iFromPost, iToPost ); } else { oNetworkDescriber.AddSentence( "Wall posts between {0} and {1} of the fan page are analyzed.", fromDate, endDate ); } if (netTypes.Contains(NetworkType.UserUserComments)) { oNetworkDescriber.AddSentence( "There is an edge between users that have co-commented on the same post." ); } if (netTypes.Contains(NetworkType.UserUserLikes)) { oNetworkDescriber.AddSentence( "There is an edge between users that have co-liked on the same post." ); } if (netTypes.Contains(NetworkType.UserPostComments)) { oNetworkDescriber.AddSentence( "There is an edge between the user that has commented " +"and the post in which he has commented." ); } if (netTypes.Contains(NetworkType.UserPostLikes)) { oNetworkDescriber.AddSentence( "There is an edge between the user that has liked " + "and the post which he has liked." ); } if (netTypes.Contains(NetworkType.PostPostComments)) { oNetworkDescriber.AddSentence( "There is an edge between posts that share the same commenters." ); } if (netTypes.Contains(NetworkType.PostPostLikes)) { oNetworkDescriber.AddSentence( "There is an edge between posts that share the same likers." ); } if (bGetWallPosts) { oNetworkDescriber.AddSentence( "For each user, 8000 characters of his wall posts are downloaded." ); } if (bGetStatusUpdates) { oNetworkDescriber.AddSentence( "For each user, 8000 characters of his status updates are downloaded." ); } if (bGetWallPosts || bGetStatusUpdates) { oNetworkDescriber.AddSentence( "URLs, Hashtags and user tags are extracted from the downloaded" + " wall posts/status updates." ); } AddPostDateRangeToNetworkDescription(streamPosts, oNetworkDescriber); 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() ); }
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 ( List<NetworkType> oEdgeType, bool bDownloadFromPostToPost, bool bDownloadBetweenDates, int iFromPost, int iToPost, DateTime oStartDate, DateTime oEndDate, bool bLimitCommentsLikes, int iNrLimit, GraphMLXmlDocument oGraphMLXmlDocument ) { Debug.Assert(oGraphMLXmlDocument != null); AssertValid(); NetworkDescriber oNetworkDescriber = new NetworkDescriber(); oNetworkDescriber.AddSentence( "The graph represents the network of "+ GetLoggedInUsername()+"\'s friends." ); oNetworkDescriber.AddNetworkTime(); oNetworkDescriber.AddSentence( "The network has "+oVertices.Count+" vertices and "+ oEdges.Count+" edges." ); if (oEdgeType.Contains(NetworkType.TimelinePostAuthors)) { oNetworkDescriber.AddSentence( "There exists an edge for each post author." ); } if (oEdgeType.Contains(NetworkType.TimelineUserComments)) { oNetworkDescriber.AddSentence( "There exists an edge for each user that has commented on a post." ); } if (oEdgeType.Contains(NetworkType.TimelineUserLikes)) { oNetworkDescriber.AddSentence( "There exists an edge for each user that has liked a post." ); } if (oEdgeType.Contains(NetworkType.TimelineUserTagged)) { oNetworkDescriber.AddSentence( "There exists an edge for each user tagged in a post." ); } oNetworkDescriber.AddSentence( "The network is built " ); if (bDownloadFromPostToPost) { oNetworkDescriber.AddSentence( "from post number "+iFromPost+" to post number "+iToPost+" of each friend timeline." ); } else if (bDownloadBetweenDates) { oNetworkDescriber.AddSentence( "upon posts between " + oStartDate.ToString() + " and " + oEndDate.ToString() + " of each friend timeline." ); } if(bLimitCommentsLikes) { oNetworkDescriber.AddNetworkLimit(iNrLimit, "comments/likes"); } 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() ); }
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()); }
GetNetworkDescription ( String sTag, WhatToInclude eWhatToInclude, NetworkLevel eNetworkLevel ) { Debug.Assert( !String.IsNullOrEmpty(sTag) ); AssertValid(); NetworkDescriber oNetworkDescriber = new NetworkDescriber(); oNetworkDescriber.AddSentence( "The graph represents the {0} network of Flickr tags related to" + " the tag \"{1}\"." , NetworkLevelToString(eNetworkLevel), sTag ); oNetworkDescriber.AddNetworkTime(NetworkSource); return ( oNetworkDescriber.ConcatenateSentences() ); }
AddTweetDateRangeToNetworkDescription ( XmlDocument graphMLXmlDocument, NetworkDescriber networkDescriber ) { Debug.Assert(graphMLXmlDocument != null); Debug.Assert(networkDescriber != null); XmlNamespaceManager oXmlNamespaceManager = new XmlNamespaceManager( graphMLXmlDocument.NameTable); oXmlNamespaceManager.AddNamespace("g", GraphMLXmlDocument.GraphMLNamespaceUri); DateTime oMinimumRelationshipDateUtc = DateTime.MaxValue; DateTime oMaximumRelationshipDateUtc = DateTime.MinValue; // Loop through the graph's edges. foreach (XmlNode oEdgeXmlNode in graphMLXmlDocument.DocumentElement.SelectNodes( "g:graph/g:edge", oXmlNamespaceManager)) { // Get the value of the edge's "relationship" GraphML-Attribute. String sRelationship; if (!TryGetEdgeGraphMLAttributeValue(oEdgeXmlNode, NodeXLGraphMLUtil.EdgeRelationshipID, oXmlNamespaceManager, out sRelationship)) { continue; } switch (sRelationship) { case TwitterGraphMLUtil.RepliesToRelationship: case TwitterGraphMLUtil.MentionsRelationship: case TwitterGraphMLUtil.NonRepliesToNonMentionsRelationship: // Get the value of the edge's "relationship date" // GraphML-Attribute. String sRelationshipDateUtc; if (!TryGetEdgeGraphMLAttributeValue(oEdgeXmlNode, TwitterGraphMLUtil.EdgeRelationshipDateUtcID, oXmlNamespaceManager, out sRelationshipDateUtc)) { break; } DateTime oRelationshipDateUtc; try { // Note that the relationship date may be in an // unrecognized format. oRelationshipDateUtc = DateTimeUtil2.FromCultureInvariantString( sRelationshipDateUtc); } catch (FormatException) { break; } if (oRelationshipDateUtc < oMinimumRelationshipDateUtc) { oMinimumRelationshipDateUtc = oRelationshipDateUtc; } if (oRelationshipDateUtc > oMaximumRelationshipDateUtc) { oMaximumRelationshipDateUtc = oRelationshipDateUtc; } break; default: break; } } if (oMinimumRelationshipDateUtc != DateTime.MaxValue) { networkDescriber.AddSentence( "The tweets in the network were tweeted over the {0} period" + " from {1} to {2}." , networkDescriber.FormatDuration(oMinimumRelationshipDateUtc, oMaximumRelationshipDateUtc), networkDescriber.FormatEventTime(oMinimumRelationshipDateUtc), networkDescriber.FormatEventTime(oMaximumRelationshipDateUtc) ); } }