Esempio n. 1
0
        public void Setup()
        {
            factory   = new Mock <IContextSentimentFactory>();
            instance  = new AspectSentimentTracker(factory.Object);
            review    = new Mock <IParsedReview>();
            sentiment = new Mock <IContextSentiment>();
            var words = new[]
            {
                new TestWordItem(string.Empty),
                new TestWordItem("Aspect1")
                {
                    IsFeature = true,
                    Stemmed   = "Aspect1"
                },
                new TestWordItem("Aspect1")
                {
                    IsFeature = true,
                    Stemmed   = "Aspect1"
                },
                new TestWordItem("Aspect2")
                {
                    IsFeature = true,
                    Stemmed   = "Aspect2"
                }
            };

            review.Setup(item => item.ImportantWords).Returns(words);
            factory.Setup(item => item.Construct(words[1].Relationship)).Returns(sentiment.Object);
            factory.Setup(item => item.Construct(words[2].Relationship)).Returns(sentiment.Object);
            factory.Setup(item => item.Construct(words[3].Relationship)).Returns(sentiment.Object);
            var sentiments = new List <SentimentValue>();

            sentiments.Add(new SentimentValue(words[0], "Text", 10));
            sentiment.Setup(item => item.Sentiments).Returns(sentiments);
        }
        public TestingClient(ILogger <TestingClient> log, IClientContext clientContext)
        {
            if (log == null)
            {
                throw new ArgumentNullException(nameof(log));
            }

            if (string.IsNullOrEmpty(clientContext.Context.SvmPath))
            {
                DisableSvm = true;
            }

            this.clientContext = clientContext ?? throw new ArgumentNullException(nameof(clientContext));
            this.log           = log;
            AspectSentiment    = new AspectSentimentTracker(new ContextSentimentFactory());
            SentimentVector    = new SentimentVector();
        }