public void CalculateQuantMultiTest()
        {
            relationships.Setup(item => item.Inverted)
            .Returns((IWordItem)null);
            relationships.Setup(item => item.PriorQuants)
            .Returns(
                new List <IWordItem>
            {
                new TestWordItem("Word")
                {
                    QuantValue = 10,
                },
                new TestWordItem("Word")
                {
                    QuantValue = 2,
                }
            });

            var value  = SentimentValue.CreateGood(wordItem.Object);
            var target = new SentimentCalculator(value);

            var result = (double)target.InvokeMethod("CalculateQuant");

            Assert.AreEqual(6, result);
        }
Example #2
0
        private SentimentValue ResolveSentiment()
        {
            var sentimentValue = handler?.MeasureSentiment(Owner);

            if (Owner.IsInvertor &&
                !Owner.IsUsedInSentiment())
            {
                if (handler?.Context.DisableFeatureSentiment == true)
                {
                    return(null);
                }

                // is something inverted, but unknown to us
                if (sentimentValue != null)
                {
                    return(sentimentValue);
                }

                return(SentimentValue.CreateInvertor(Owner));
            }

            if (sentimentValue == null)
            {
                return(null);
            }

            sentimentValue = new SentimentCalculator(sentimentValue).Calculate();
            return(sentimentValue);
        }
        public void SentimentCalculatorConstructorTest()
        {
            IWordItem invertor = new TestWordItem(String.Empty);

            relationships.Setup(item => item.Inverted)
            .Returns(invertor);
            relationships.Setup(item => item.PriorQuants)
            .Returns(new List <IWordItem>());

            var value  = SentimentValue.CreateGood(wordItem.Object);
            var target = new SentimentCalculator(value);

            Assert.AreEqual(wordItem.Object, target.GetField <IWordItem>("wordItem"));
            Assert.AreEqual(value, target.GetField <SentimentValue>("sentimentValue"));
        }
        public void CalculateInvertTest()
        {
            IWordItem invertor = new TestWordItem("Invert");

            relationships.Setup(item => item.Inverted)
            .Returns(invertor);
            relationships.Setup(item => item.PriorQuants)
            .Returns(new List <IWordItem>());

            var value = SentimentValue.CreateGood(wordItem.Object);

            var target = new SentimentCalculator(value);

            var result = target.Calculate();

            Assert.AreEqual(-1, result.DataValue.Value);
        }
        public void CalculateSmallQuantTest()
        {
            relationships.Setup(item => item.Inverted)
            .Returns((IWordItem)null);
            relationships.Setup(item => item.PriorQuants)
            .Returns(
                new List <IWordItem>
            {
                new TestWordItem("Quant")
                {
                    QuantValue = 0.5
                }
            });

            var value  = SentimentValue.CreateGood(wordItem.Object);
            var target = new SentimentCalculator(value);
            var result = target.Calculate();

            Assert.AreEqual(0.5, result.DataValue.Value);
        }
        /////////////////////////////////////////////////////////////////////////////////////

        public HomeController(IOptions <TwitterCrawlerConfig> config)
        {
            posTagger           = new PosTagger();
            twitterCrawler      = new TwitterCrawler(config);
            tokenizer           = new Tokenizer();
            tokenAnalyser       = new TokenAnalyser();
            tweetAnalyser       = new TweetAnalyser();
            wordRater           = new WordRater();
            sentimentCalculator = new SentimentCalculator();
            preprocessor        = new Preprocessor();
            parseTreeAnalyser   = new ParseTreeAnalyser();

            networkSendClientSocket    = new NetworkClientSocket(NetworkSendClientPort, NetworkClientHost);
            networkReceiveClientSocket = new NetworkClientSocket(NetworkReceiveClientPort, NetworkClientHost);

            serializer   = new Serializer();
            deserializer = new Deserializer();

            tester = new Tester();
        }
        public void CalculateQuantInvertor()
        {
            var invertor = new TestWordItem(String.Empty);

            relationships.Setup(item => item.Inverted)
            .Returns(invertor);
            relationships.Setup(item => item.PriorQuants)
            .Returns(
                new List <IWordItem>
            {
                new TestWordItem("Word")
                {
                    QuantValue = 10,
                }
            });

            var value  = SentimentValue.CreateGood(wordItem.Object);
            var target = new SentimentCalculator(value);

            var result = (double)target.InvokeMethod("CalculateQuant");

            Assert.AreEqual(10, result);
        }