コード例 #1
0
        public SentimentResult Predict(string sentiment)
        {
            var result     = new SentimentResult();
            var tokenized  = _preprocessor.Process(sentiment);
            var featurized = _bagOfWords.Transform(tokenized).ToInt32();

            var scores = _bayes.Scores(featurized);
            var prob   = _bayes.Probabilities(featurized);

            result.Polarity            = _bayes.Decide(featurized) == 0 ? Polarity.Negative : Polarity.Positive;
            result.NegativeScore       = scores[0];
            result.PositiveScore       = scores[1];
            result.NegativeProbability = prob[0];
            result.PositiveProbability = prob[1];

            return(result);
        }