Are you looking for customized advices? Click here to contact the expert!
by
1
6
247k
1
Top 1% !
Popular
Pearl of Wisdom
Tagged
Tuned
OpenSource
Popularity: 5538th place
Created
Modified Nov 4, 2014

Published on:

.NETFramework4.0
Architecturex86_64
ClassNameRssReader
Extension.cs
InputDefValue21
InputName0url
InputName1maxItems
InputName2minLenOfAcceptedWords
InputType0string
InputType1int
InputType2int
LanguageCSharp
LicenseMIT_X11
MethodNameComputeWordsOccurrencesInRss
OSWindows
OutputTypeDictionary<string,int>
RequiredSnippet215957
RequiredSnippet215962
Windows VersionWindows7

Calculate the occurrences of words in Rss feed

Creates a dictionary with keys=words and values=occurrences of that word in the given Rss (specified by the URL). The caller should specify the maximum number of items in the returning dictionary and, optionally, the minimum length of the words that will be added to the output.
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/215956/Calculate-the-occurrences-of-words-in-Rs?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
public static Dictionary<string, int> ComputeWordsOccurrencesInRss(string url, int maxItems, int minLenOfAcceptedWords = 1) { Dictionary<string, int> occurrences = new Dictionary<string, int>(); IList<RssReader.RssItem> singleRssResult = RssReader.ReadRss(url, maxItems, true); string[] splitted = null; foreach (RssReader.RssItem rss in singleRssResult) { List<string> words = new List<string>(); //split title in words: splitted = StringHelper.SplitIntoWords(rss.Title); if (splitted != null) words.AddRange(splitted); //split summary in words: splitted = StringHelper.SplitIntoWords(rss.Summary); if (splitted != null) words.AddRange(splitted); //compute occurrences of words: for (int w = 0; w < words.Count; w++) { string word = words[w].ToLower(); if (word.Length < minLenOfAcceptedWords) continue; if (occurrences.ContainsKey(word)) occurrences[word]++; else occurrences.Add(word, 1); } } return occurrences; }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus