Exemple #1
0
        public void StreamData(StreamReader reader, StreamWriter writer)
        {
            KeySentiments server = new KeySentiments();

            do
            {
                string inputLine = reader.ReadLine();
                server.Sentiment(inputLine, writer);
            } while (reader.EndOfStream == false);
        }
Exemple #2
0
        public void performSentimentTest()
        {
            string input  = "The quick brown fox jumps over the lazy dog";
            string answer = "Negative, 0.00, 0.99, 0.01, \"quick brown fox jumps\", \"lazy dog\"";

            using (System.IO.MemoryStream memory = new System.IO.MemoryStream())
            {
                System.IO.StreamWriter writer = new System.IO.StreamWriter(memory, Console.OutputEncoding);
                analyzer.Sentiment(input, writer);
                memory.Seek(0, System.IO.SeekOrigin.Begin);
                System.IO.StreamReader reader = new System.IO.StreamReader(memory, Console.InputEncoding);
                string result = reader.ReadLine();
                Assert.AreEqual(answer, result);
            }
        }
Exemple #3
0
        public void PromptForInput(StreamWriter writer)
        {
            KeySentiments server = new KeySentiments();

            do
            {
                Console.Write("Enter text <empty to quit>: ");
                string inputLine = Console.ReadLine();
                if (inputLine == null || inputLine.Length == 0)
                {
                    break;
                }
                else
                {
                    server.Sentiment(inputLine, writer);
                }
            } while (true);
        }