private void AppendTrainingDoc(string catg, string textToBeAnalyzed)
        {
            /*
             * create new category &save only unique words
             * rewrite if category already exists
             */
            _interactor.AppendCategory(catg, _interactor.GetSplitWords(textToBeAnalyzed));

            _interactor.ComputeTermFrequencyAltogether(catg);

            _view.SetCategoryNames(_interactor.GetCategories().ToArray());

            _interactor.SaveToJsonFile();
        }
Esempio n. 2
0
        public void OnBtnTermFrequencyClicked(string catg, string textToBeAnalyzed)
        {
            // calculate TermFrequency to all categories and then press IDF. Then TermFrequencyIDF.

            if (string.IsNullOrWhiteSpace(catg))
            {
                _view.Show("Please enter or chose the category");
                return;
            }

            //feature if the field is not empty then learn
            if (!string.IsNullOrWhiteSpace(textToBeAnalyzed))
            {
                /*
                 * create new category &save only unique words
                 * rewrite if category already exists
                 */
                _interactor.AddCategory(catg, _interactor.GetSplitWords(textToBeAnalyzed));

                _interactor.ComputeTermFrequencyAltogether(catg);

                _view.SetCategories(_interactor.GetCategories().ToArray());

                _view.Show("Success");
            }
            else
            {
                //feature if the textBox is empty then show saved data

                if (_interactor.WhetherCategoryExist(catg))
                {
                    _view.Show("Write some texts to update the network");
                }
                else
                {
                    _view.Show("The category \"" + catg +
                               "\" was not created. To create this category enter text of news in the TextBox");
                }
            }
        }