ConcatenateTopStringsByCount ( IEnumerable <IEdge> edges, String edgeColumnName, Int32 maximumTopStrings ) { Debug.Assert(edges != null); Debug.Assert(!String.IsNullOrEmpty(edgeColumnName)); Debug.Assert(maximumTopStrings > 0); Dictionary <String, Int32> oStringCounts = TwitterSearchNetworkStringUtil.CountDelimitedStringsInEdgeColumn( edges, edgeColumnName); return(TwitterSearchNetworkStringUtil.ConcatenateTopStrings( oStringCounts, maximumTopStrings)); }
ConcatenateTopStringsBySalience ( IEnumerable <IEdge> edges, String edgeColumnName, Int32 maximumTopStrings ) { Debug.Assert(edges != null); Debug.Assert(!String.IsNullOrEmpty(edgeColumnName)); Debug.Assert(maximumTopStrings > 0); // Don't convert to lower case (bitly URLs are case-sensitive, for // example), and don't skip any words. WordCounter oWordCounter = new WordCounter(false, new String[0]); oWordCounter.SkipUrlsAndPunctuation = false; foreach (IEdge oEdge in edges) { String sSpaceDelimitedCellValue; if (oEdge.TryGetNonEmptyStringValue(edgeColumnName, out sSpaceDelimitedCellValue)) { oWordCounter.CountTermsInDocument(sSpaceDelimitedCellValue); } } oWordCounter.CalculateSalienceOfCountedTerms(); return(String.Join(TwitterSearchNetworkWordMetricUtil.WordSeparator, TwitterSearchNetworkStringUtil.TakeTopStringsAsArray( (from CountedWord oCountedWord in oWordCounter.CountedTerms orderby oCountedWord.Salience descending select oCountedWord.Word), maximumTopStrings ))); }
ConcatenateTopWordsOrWordPairs ( List <GraphMetricValueOrdered> topWordsOrWordPairs, Boolean concatenateTopWords, Int32 maximumTopWordsOrWordPairs ) { Debug.Assert(topWordsOrWordPairs != null); Debug.Assert(maximumTopWordsOrWordPairs > 0); return(String.Join( concatenateTopWords ? WordSeparator : WordPairSeparator, TwitterSearchNetworkStringUtil.TakeTopStringsAsArray( (from oGroupMetricValueWithID in topWordsOrWordPairs select ExcelTextUtil.UnforceCellText( (String)oGroupMetricValueWithID.Value)) , maximumTopWordsOrWordPairs) )); }
ConcatenateTopWordsAndWordPairs ( IEnumerable <IEdge> oEdges, String sStatusEdgeColumnName, Int32 iMaximumTopStrings, WordCounter oWordCounter, WordPairCounter oWordPairCounter, out String sTopWordsInTweetByCount, out String sTopWordsInTweetBySalience, out String sTopWordPairsInTweetByCount, out String sTopWordPairsInTweetBySalience ) { Debug.Assert(oEdges != null); Debug.Assert(!String.IsNullOrEmpty(sStatusEdgeColumnName)); Debug.Assert(iMaximumTopStrings > 0); Debug.Assert(oWordCounter != null); Debug.Assert(oWordPairCounter != null); oWordCounter.Clear(); oWordPairCounter.Clear(); foreach (IEdge oEdge in oEdges) { String sStatus; if (oEdge.TryGetNonEmptyStringValue(sStatusEdgeColumnName, out sStatus)) { oWordCounter.CountTermsInDocument(sStatus); oWordPairCounter.CountTermsInDocument(sStatus); } } oWordCounter.CalculateSalienceOfCountedTerms(); oWordPairCounter.CalculateSalienceOfCountedTerms(); sTopWordsInTweetByCount = String.Join( TwitterSearchNetworkWordMetricUtil.WordSeparator, TwitterSearchNetworkStringUtil.TakeTopStringsAsArray( (from CountedWord oCountedWord in oWordCounter.CountedTerms orderby oCountedWord.Count descending select oCountedWord.Word) , iMaximumTopStrings )); sTopWordsInTweetBySalience = String.Join( TwitterSearchNetworkWordMetricUtil.WordSeparator, TwitterSearchNetworkStringUtil.TakeTopStringsAsArray( (from CountedWord oCountedWord in oWordCounter.CountedTerms orderby oCountedWord.Salience descending select oCountedWord.Word) , iMaximumTopStrings )); sTopWordPairsInTweetByCount = String.Join( TwitterSearchNetworkWordMetricUtil.WordPairSeparator, TwitterSearchNetworkStringUtil.TakeTopStringsAsArray( (from CountedWordPair oCountedWordPair in oWordPairCounter.CountedTerms orderby oCountedWordPair.Count descending select TwitterSearchNetworkWordMetricUtil.FormatWordPair( oCountedWordPair)) , iMaximumTopStrings )); sTopWordPairsInTweetBySalience = String.Join( TwitterSearchNetworkWordMetricUtil.WordPairSeparator, TwitterSearchNetworkStringUtil.TakeTopStringsAsArray( (from CountedWordPair oCountedWordPair in oWordPairCounter.CountedTerms orderby oCountedWordPair.Salience descending select TwitterSearchNetworkWordMetricUtil.FormatWordPair( oCountedWordPair)) , iMaximumTopStrings )); }