public void AddforTarining(int _category, string _word)//Uygun kategori bulunup değer ekleniyor. { if (_cat_dic.ContainsKey(_category)) { catDictionary category_word = (catDictionary)_cat_dic[_category]; category_word.Add(_word); _cat_dic[_category] = category_word; } else { catDictionary category_word = new catDictionary(_category); category_word.Add(_word); _cat_dic.Add(_category, category_word); } }
public void CalculateScore(string _sentence) { _cat_score = new Dictionary <int, double>(); word_dic _new_wd = new word_dic(); _new_wd.update_hashtables(_sentence, 0, language, stemming, addtur, n, punctuation, nov); foreach (DictionaryEntry _word in _new_wd._words_in_sentence) { foreach (var _cat in _cat_dic) { catDictionary _cd = (catDictionary)_cat.Value; double _countofword = Convert.ToDouble(_cd.Search((string)_word.Key)); double _totalWords = Convert.ToDouble(_cd.CountofWordsinCategory); double _countofsentenceincat = (int)_category_sentence_count[(int)_cat.Key]; double _score = 0; if (_countofword > 0) { _score = System.Math.Log(((double)_countofword + 1) / ((double)_totalWords + _all_sentence_count)); } else { _score = 0; } if (!_cat_score.ContainsKey((int)_cat.Key)) { _cat_score.Add((int)_cat.Key, _score + System.Math.Log((double)_countofsentenceincat / (double)_all_sentence_count)); } else { _cat_score[(int)_cat.Key] = (double)_cat_score[(int)_cat.Key] + _score; } } } }