Esempio n. 1
0
        private static void ProcessResults(SentimentBatchEntry item)
        {
            ConsoleColor appropriateColour = ConsoleColor.Red;

            if (item.Sentiment == Sentiment.Neutral)
            {
                appropriateColour = ConsoleColor.DarkYellow;
            }
            if (item.Sentiment == Sentiment.Positive)
            {
                appropriateColour = ConsoleColor.Green;
            }
            if (item.Sentiment == Sentiment.Negative)
            {
                appropriateColour = ConsoleColor.Cyan;
            }
            ConCol("{0} was analysed. Sentiment Score was {1}. Sentiment is {2}", appropriateColour, item.FileName, item.SentimentScore.ToString(), item.Sentiment.ToString().ToUpper());
            if (item.Sentiment == Sentiment.Error)
            {
                if (item.Error == null)
                {
                    item.Error = "Error field unexpectedly null";
                }
                ConCol(item.Error, appropriateColour);
            }
            else
            {
                string trimmedTextToAnalyse = item.TextToAnalyse;
                if (item.TextToAnalyse.Length > 100)
                {
                    trimmedTextToAnalyse = item.TextToAnalyse.Substring(0, 99);
                }
                ConCol("Text: {0}", appropriateColour, trimmedTextToAnalyse);
            }
        }
Esempio n. 2
0
        private static void ProcessText(string fullFilePath)
        {
            ConCol("Processing text file: {0}", ConsoleColor.Gray, Path.GetFileName(fullFilePath));

            string textToProcess = File.ReadAllText(fullFilePath);

            if (textToProcess.Length > Global.MaxDocumentSizeInCharacters)
            {
                textToProcess = textToProcess.Substring(0, Global.MaxDocumentSizeInCharacters);
            }

            SentimentBatchEntry sbe = new SentimentBatchEntry(SentimentBatchEntryType.Audio, textToProcess, Path.GetFileName(fullFilePath));

            batch.Add(sbe);
            ProcessBatchIfEnoughEntries();
        }
Esempio n. 3
0
        private static void ProcessTwitter(string fullFilePath)
        {
            ConCol("Processing twitter trigger file: {0}", ConsoleColor.Gray, Path.GetFileName(fullFilePath));

            string[] twitterFileContent = File.ReadAllLines(fullFilePath);
            foreach (var hashTag in twitterFileContent)
            {
                ConCol("Processing HashTag: {0}", one: hashTag);

                List <string> tweets = PrepareTwitterBatch(hashTag);
                foreach (var tweet in tweets)
                {
                    SentimentBatchEntry sbe = new SentimentBatchEntry(SentimentBatchEntryType.Tweet, tweet, Path.GetFileName(fullFilePath));
                    batch.Add(sbe);
                }

                ConCol("Added {0} tweets to batch", one: tweets.Count.ToString());
            }

            ProcessBatchIfEnoughEntries();
        }