Class twitter.Data


  • public class twitter.Data
    extends java.lang.Object
    Class to manipulate data such as write a csv file containing a collection of tweets to train a model or wirte a csv file with the result of sentiment analysis.
    • Constructor Summary

      Constructors 
      Constructor Description
      twitter.Data()
      Constructor - initializes the api and properties.
    • Method Summary

      Modifier and Type Method Description
      void predictEmotionFromCsv()
      Reads a csv file containing a text and a machine learning tool, and does sentiment analysis.
      void predictEmotionFromKafka​(java.lang.String tweet)
      Applies sentiment analysis into a tweet read it from Kafka server.
      void writeCsv​(java.lang.String tweet)
      Writes a tweet into csv file to collect a group of tweets and apply sentiment analysis with the objective of making a csv containing all the tweets to train a model.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • twitter.Data

        public kafka.Data()
        Constructor - initializes the api and properties.
    • Method Detail

      • predictEmotionFromCsv

        public void predictEmotionFromCsv()
        Reads a csv file containing a text and a machine learning tool, and does sentiment analysis. The result is an other csv file containing the text and a json string with the result of the emotions weighted.
      • predictEmotionFromKafka

        public void predictEmotionFromKafka​(java.lang.String tweet)
                                     throws java.io.IOException,
                                            org.json.simple.parser.ParseException
        Applies sentiment analysis into a tweet read it from Kafka server. The result at the end of execution is a csv file containing the text of all tweets and a json string for each one with six emotions weighted (sentiment analysis result).
        Parameters:
        tweet - Tweet to apply sentiment analysis.
        Throws:
        java.io.IOException - caused by an error during the call to apply sentiment analysis or translate the text.
        org.json.simple.parser.ParseException - caused by an error during the call to apply sentiment analysis or translate the text.
      • writeCsv

        public void writeCsv​(java.lang.String tweet)
                      throws java.io.IOException,
                             org.json.simple.parser.ParseException
        Writes a tweet into csv file to collect a group of tweets and apply sentiment analysis with the objective of making a csv containing all the tweets to train a model.
        Parameters:
        tweet - Tweet to write into csv file and translate if necessary.
        Throws:
        java.io.IOException - caused by an error during the call to translate the text.
        org.json.simple.parser.ParseException - caused by an error during the call to translate the text.