示例#1
0
        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);
            }
        }
示例#2
0
        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);
            }
        }
示例#3
0
        private void countTermsFrequencies(Article article, List <string> searchWords)
        {
            TokenizeStopStem t = new TokenizeStopStem(article.description);

            t.tokenize();

            article.TF = t.countTermsFrequencies(Dictionary.dictionary);
        }
示例#4
0
        private static void addTokens(TokenizeStopStem t)
        {
            List <String> tokens = t.getTokens();

            foreach (String token in tokens)
            {
                if (!dictionary.ContainsKey(token))
                {
                    dictionary.Add(token, no++);
                }
            }
        }