public void Test_Classifier_With_Many_Tweets_When_All_Tweets_Are_Positive() { var initSentences = new[] { new Sentence("hate", WordCategory.Negative), new Sentence("love", WordCategory.Positive) }; var learningService = LearningService.WithCacheService(new CacheServiceForTests()).WithLearner(new TweetLearner()).WithSentences(initSentences).Build(); var service = new BayesAnalysisService(learningService, new TweetClassifier()); var testResult = service.Analyze(Enumerable.Range(0, 10000).Select(x => new Tweet { Text = "love and sun" }).ToList()); testResult.IsSuccess.Should().BeTrue(); testResult.Value.First().Sentiment.Should().Be(WordCategory.Positive); }
public async Task Test_Async_Classifier_With_Many_Tweets_When_All_Tweets_Are_Positive() { var testClassifier = A(TestLearnState().WithSentence(ImmutableDictionary <string, int> .Empty.Add("f**k", -1).Add("love", 4).Add("suck", -5).Add("sun", 5))); var initSentences = new[] { new Sentence("hate", WordCategory.Negative), new Sentence("love", WordCategory.Positive) }; var learningService = LearningService.WithCacheService(new CacheServiceForTests()).WithLearner(new TweetLearner()).WithSentences(initSentences).Build(); var service = new BayesAnalysisService(learningService, new TweetClassifier()); var testResult = await service.AnalyzeAsync(Enumerable.Range(0, 10000).Select(x => new Tweet { Text = "love and sun" }).ToList()); testResult.IsSuccess.Should().BeTrue(); testResult.Value.First().Sentiment.Should().Be(WordCategory.Positive); }
public async Task Test_Async_Classifier_When_All_Tweets_Are_Negative() { var initSentences = new[] { new Sentence("hate", WordCategory.Negative), new Sentence("love", WordCategory.Positive) }; var learningService = LearningService.WithCacheService(new CacheServiceForTests()).WithLearner(new TweetLearner()).WithSentences(initSentences).Build(); var service = new BayesAnalysisService(learningService, new TweetClassifier()); var testResult = await service.AnalyzeAsync(new List <Tweet> { new Tweet { Text = "f**k and suck" } }); testResult.IsSuccess.Should().BeTrue(); testResult.Value.First().Sentiment.Should().Be(WordCategory.Negative); }