public BagOfWords AnalyzeFeed(Feed feed) { BagOfWords bag = new BagOfWords(feed.Name, feed.URL, feed.Name); foreach (FeedItem item in feed.Items) { bag.AddDocument(item.Title, item.ContentText, item.Tags); } return(bag); }
public IEnumerable <BagOfWords> AnalyzeFeedItems(Feed feed) { List <BagOfWords> bags = new List <BagOfWords>(); foreach (FeedItem item in feed.Items) { BagOfWords bag = new BagOfWords(item.Title, item.Id, feed.Name); bag.AddDocument(item.Title, item.ContentText, item.Tags); yield return(bag); } }
public List <BagOfWords> GetAllBags() { List <Feed> feeds = GetFeeds(); List <BagOfWords> bags = new List <BagOfWords>(); foreach (Feed feed in feeds) { foreach (FeedItem doc in feed.Items) { BagOfWords bag = new BagOfWords(doc.Title, doc.Id, feed.Name); bag.AddDocument(doc.Title, doc.ContentText, doc.Tags); bags.Add(bag); } } return(bags); }
public void ExtractAllLabels() { FeedRepository fRep = new FeedRepository(); List <Feed> feeds = fRep.GetAll().Where(f => f.Active).ToList(); int addedItems = 0; foreach (Feed feed in feeds) { foreach (FeedItem item in feed.Items) { BagOfWords bag = new BagOfWords(); bag.AddDocument(item.Title, item.ContentText, item.Tags); item.WordsCount = bag.Words.Count(); item.UniqueWordsCount = bag.WordsFrequency.Count(); foreach (var freq in bag.Labels) { item.Labels.Add(new Label(freq.Key, freq.Value.Count, freq.Value.Frequency)); } } fRep.Update(feed); } }