private void Analyze(object obj) { SentimentIntensityAnalyzer analyzer = new SentimentIntensityAnalyzer(); SentimentAnalyzerController regression = new SentimentAnalyzerController(); foreach (Comment comment in Comments) { var analyzed = analyzer.PolarityScores(comment.Text); comment.NaiveBayes = String.Format("Positive: {0} Neutral: {1} Negative: {2} Compound: {3}", analyzed.Positive, analyzed.Neutral, analyzed.Negative, analyzed.Compound); comment.LogisticRegression = regression.GetTextForMark(comment.Text).ToString(); } }
private void ClickOpenMenu(object sender, EventArgs e) { OpenFileDialog ofdDialog = new OpenFileDialog(); ofdDialog.Title = "Open text file"; if (ofdDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string fileName = ofdDialog.FileName; SentimentAnalyzerController controller = new SentimentAnalyzerController(); string textFromFile = controller.GetTextFromFile(fileName); rtbText.Text = textFromFile; } }
private void ClickTrainButton(object sender, EventArgs e) { string text = rtbText.Text; SentimentAnalyzerController controller = new SentimentAnalyzerController(); var result = controller.GetTextForMark(text); if (result == 1) { MessageBox.Show("Текст положительно окрашен"); } else { MessageBox.Show("Текст окрашен отрицательно"); } }