def __add_document(self, raw_tweet):

        raw_label = None
        if raw_tweet[1] == "1" or raw_tweet[1] == "\"1\"":
            if (raw_tweet[3] == "1" or raw_tweet[3] == "\"1\"") and (
                    raw_tweet[2] == "0" or raw_tweet[2] == "\"0\""):
                raw_label = "negative"
            elif (raw_tweet[2] == "1"
                  or raw_tweet[2] == "\"1\"") and (raw_tweet[3] == "0"
                                                   or raw_tweet[3] == "\"0\""):
                raw_label = "positive"
            elif ((raw_tweet[3] == "0" or raw_tweet[3] == "\"0\"") and
                  (raw_tweet[2] == "0" or raw_tweet[2] == "\"0\"")) or (
                      (raw_tweet[3] == "1" or raw_tweet[3] == "\"1\"") and
                      (raw_tweet[2] == "1" or raw_tweet[2] == "\"1\"")):
                raw_label = "neutral"

        label_index = self.__allow_labels.get_label_index(raw_label)
        if label_index is not None:
            tweet = Document()
            tweet.id = raw_tweet[0][1:-1]
            tweet.raw_text = raw_tweet[-1][1:-1]
            tweet.raw_label = self.__allow_labels.get_label_name(label_index)
            tweet.sparse_label = label_index
            self.__doc_x_labels[label_index] += 1
            self.__corpus[tweet.id] = tweet
            self.__doc_ids.append(tweet.id)
Esempio n. 2
0
    def __add_document(self, id_doc, label, raw_text):

        doc = Document()
        doc.id = id_doc
        doc.raw_text = raw_text
        doc.sparse_label = self.__allow_labels.get_label_index(label)
        doc.raw_label = self.__allow_labels.get_label_name(doc.sparse_label)
        self.__doc_x_labels[doc.sparse_label] += 1
        self.__corpus[doc.id] = doc
Esempio n. 3
0
 def __add_document(self, raw_tweet):
     label_index = self.__allow_labels.get_label_index(raw_tweet["label"])
     if label_index is not None:
         tweet = Document()
         tweet.id = raw_tweet["id"]
         tweet.raw_text = raw_tweet["content"]
         tweet.raw_label = self.__allow_labels.get_label_name(label_index)
         tweet.sparse_label = label_index
         self.__doc_x_labels[label_index] += 1
         self.__corpus[raw_tweet["id"]] = tweet
Esempio n. 4
0
 def __add_document(self, raw_tweet):
     own_strip = str.strip
     label_index = self.__allow_labels.get_label_index(raw_tweet[1])
     if label_index is not None:
         tweet = Document()
         tweet.id = own_strip(raw_tweet[0])
         tweet.raw_text = own_strip(raw_tweet[-1])
         tweet.raw_label = self.__allow_labels.get_label_name(label_index)
         tweet.sparse_label = label_index
         if own_strip(raw_tweet[0]) in self.__corpus:
             raw_tweet[0] = own_strip(raw_tweet[0]) + "_2"
         elif own_strip(raw_tweet[0]) + "_2" in self.__corpus:
             raw_tweet[0] = own_strip(raw_tweet[0]) + "_3"
         self.__doc_x_labels[label_index] += 1
         self.__corpus[raw_tweet[0]] = tweet
         self.__doc_ids.append(own_strip(raw_tweet[0]))
    def __add_document(self, raw_tweet):

        raw_label = None
        if raw_tweet[0][1:] == "0":
            raw_label = "negative"
        elif raw_tweet[0][1:] == "1":
            raw_label = "positive"

        label_index = self.__allow_labels.get_label_index(raw_label)
        if label_index is not None:
            tweet = Document()
            tweet.id = raw_tweet[1]
            tweet.raw_text = raw_tweet[-1][:-1]
            tweet.raw_label = self.__allow_labels.get_label_name(label_index)
            tweet.sparse_label = label_index
            self.__doc_x_labels[label_index] += 1
            self.__corpus[tweet.id] = tweet