public void CorrectUp() { var articlesFilePath = @"TestData\Index\MiddleTerm\Index.MiddleTerm.Up.xml"; var macroWordsLoader = new MacroWordsLoader(@"AppData\MacroWords.xml"); var patternsLoader = new RawPatternsLoader(@"AppData\Up.xml", Trend.Up); var patternProvider = new PatternsProvider(patternsLoader.Patterns, macroWordsLoader.MacroWords); var classifier = new OpinionClassifier(patternProvider); var articles = new TestArticleLoader().LoadArticles(articlesFilePath); foreach (var article in articles) { if (String.IsNullOrEmpty(article.Title) && String.IsNullOrEmpty(article.Text)) { continue; } Trend result = classifier.Classify(article).Trend; Assert.AreEqual(Trend.Up, result, "Incorrect classification for: " + article.Id + " : " + article.Text); } }
private static void Check(string testArticlesFilePath, string rawPatternsPath, Trend trend) { var macroWordsLoader = new MacroWordsLoader(@"AppData\MacroWords.xml"); var patternsLoader = new RawPatternsLoader(rawPatternsPath, trend); var patternProvider = new PatternsProvider(patternsLoader.Patterns, macroWordsLoader.MacroWords); var classifier = new OpinionClassifier(patternProvider); var articles = new TestArticleLoader().LoadArticles(testArticlesFilePath); foreach (var article in articles) { if (String.IsNullOrEmpty(article.Title) && String.IsNullOrEmpty(article.Text)) { continue; } var result = classifier.Classify(article); Assert.AreEqual(Trend.Unknown, result.Trend, "Incorrect classification: Regex: " + result.RegexText + "\n\r : " + article.Text + " \n\r " + "Regex: " + result.RegexText); if (String.IsNullOrEmpty(article.NegativeText) == false) { var negativeResult = classifier.Classify(article.NegativeText); Assert.AreNotEqual(Trend.Unknown, negativeResult, "Incorrect classification for negative text: " + article.Id + " : " + article.Text); } } }
private static void CorrectDown(string testArticlesFilePath) { var patternsLoader = new RawPatternsLoader(@"AppData\TrendPatterns\Down.Unconditional.xml", Trend.Down); var macroWordsLoader = new MacroWordsLoader(@"AppData\TrendPatterns\MacroWords.xml"); var patternProvider = new PatternsProvider(patternsLoader.Patterns, macroWordsLoader.MacroWords); var classifier = new OpinionClassifier(patternProvider); var articles = new TestArticleLoader().LoadArticles(testArticlesFilePath); foreach (var article in articles) { if (String.IsNullOrEmpty(article.Title) && String.IsNullOrEmpty(article.Text)) { continue; } var result = classifier.Classify(article); Assert.AreEqual(Trend.Down, result, "Incorrect classification for: " + article.Id + " : " + article.Text); if (String.IsNullOrEmpty(article.NegativeText) == false) { var negativeResult = classifier.Classify(article.NegativeText); Assert.AreNotEqual(Trend.Down, negativeResult, "Incorrect classification for negative text: " + article.Id + " : " + article.Text); } } }
public void Initial() { var item = new Article("", ""); var classifier = new OpinionClassifier(new PatternsProvider(new RawPattern[0], new MacroWord[0])); Trend result = classifier.Classify(item).Trend; Assert.AreEqual(Trend.Unknown, result); }