public static void buildDictionary2(List <Article> articles) { no = 0; if (dictionary == null) { dictionary = new Dictionary <string, int>(); } else { dictionary.Clear(); } TokenizeStopStem t; foreach (var article in articles) { t = new TokenizeStopStem(article.description); t.tokenize(); addTokens(t); t = new TokenizeStopStem(article.title); t.tokenize(); addTokens(t); } }
private void countTitleFrequencies(Article article, List <string> searchWords) { article.TFTitle = new double[article.TF.Length]; for (int i = 0; i < article.TF.Length; i++) { article.TFTitle[i] = article.TF[i]; } int count = 1; TokenizeStopStem title = new TokenizeStopStem(article.title); title.tokenize(); List <string> t = title.getTokens(); foreach (var item in t) { foreach (string s in searchWords) { if (item.Equals(s)) { count++; } } } for (int i = 0; i < article.TFTitle.Length; i++) { article.TFTitle[i] *= (1 / (double)count); } }
private void countTermsFrequencies(Article article, List <string> searchWords) { TokenizeStopStem t = new TokenizeStopStem(article.description); t.tokenize(); article.TF = t.countTermsFrequencies(Dictionary.dictionary); }
private static void addTokens(TokenizeStopStem t) { List <String> tokens = t.getTokens(); foreach (String token in tokens) { if (!dictionary.ContainsKey(token)) { dictionary.Add(token, no++); } } }