public void AddSentenceforTraining(string _sentence, int _category) { _wd.update_hashtables(_sentence, _category, language, stemming, addtur, n, punctuation, nov); foreach (DictionaryEntry _word in _wd._words_in_sentence) { AddforTarining(_category, (string)_word.Key); } }
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; } } } }