def create_lexicon(self, data_set_reader, n_grams, min_total_occurrences, min_sentiment_value, filters):
        """
         Generates sentiment lexicon using PMI on words and classification of context they are in.
         
         :param: dataSetReader       Dataset containing tweets and their sentiment classification
         :param: nGrams              n-grams to calculate sentiment for (with n>1, singletons are calculated automatically)
         :param: minTotalOccurrences minimum number of times n-gram must have appeared in dataset before a sentiment value
                                     is assigned (higher value gives more accurate sentiment value)
         :param: minSentimentValue   minimum sentiment value required to be included in lexicon (values close to 0 are
                                     often words that are used equally in positive or negative context, possibly even
                                     different words, but with same spelling, and thus having uncertain value)
         :param: filters             filters to apply to tweets before searching for n-grams
         :return: map of n-grams and their sentiment values, sentiment values are in [-5, 5]
        """
        counter = self.count_n_grams_py_polarity(data_set_reader, n_grams, filters)
        lexicon = {}

        pos = sum(map(lambda i: i.num_positive, counter.values()))
        neg = sum(map(lambda i: i.num_negative, counter.values()))
        ratio = neg / float(pos)

        for key, value in counter.items():
            if value.get_total_occurrences() <= min_total_occurrences:
                continue

            over = value.num_positive
            under = value.num_negative

            sentiment_value = math.log(ratio * over / under)
            if abs(sentiment_value) >= min_sentiment_value:
                lexicon[key] = sentiment_value

                if RegexFilters.WHITESPACE.split(key).length == 1 and not classifier_options.is_special_class_word(key):
                    for related_word in adjectives.get_adverb_and_adjectives(key):
                        if related_word in counter and related_word not in lexicon:
                            lexicon[related_word] = sentiment_value

        return map_utils.normalize_map_between(lexicon, -5, 5)
def create_lexicon ( self , data_set_reader , n_grams , min_total_occurrences , min_sentiment_value , filters ) : counter = self . count_n_grams_py_polarity ( data_set_reader , n_grams , filters ) lexicon = { } pos = sum ( map ( lambda i : i . num_positive , counter . values ( ) ) ) neg = sum ( map ( lambda i : i . num_negative , counter . values ( ) ) ) ratio = neg / float ( pos ) for key , value in counter . items ( ) : if value . get_total_occurrences ( ) <= min_total_occurrences : continue over = value . num_positive under = value . num_negative sentiment_value = math . log ( ratio * over / under ) if abs ( sentiment_value ) >= min_sentiment_value : lexicon [ key ] = sentiment_value if RegexFilters . WHITESPACE . split ( key ) . length == 1 and not classifier_options . is_special_class_word ( key ) : for related_word in adjectives . get_adverb_and_adjectives ( key ) : if related_word in counter and related_word not in lexicon : lexicon [ related_word ] = sentiment_value return map_utils . normalize_map_between ( lexicon , - 5 , 5 )
Generates sentiment lexicon using PMI on words and classification of context they are in.
         
         :param: dataSetReader       Dataset containing tweets and their sentiment classification
         :param: nGrams              n-grams to calculate sentiment for (with n>1, singletons are calculated automatically)
         :param: minTotalOccurrences minimum number of times n-gram must have appeared in dataset before a sentiment value
                                     is assigned (higher value gives more accurate sentiment value)
         :param: minSentimentValue   minimum sentiment value required to be included in lexicon (values close to 0 are
                                     often words that are used equally in positive or negative context, possibly even
                                     different words, but with same spelling, and thus having uncertain value)
         :param: filters             filters to apply to tweets before searching for n-grams
         :return: map of n-grams and their sentiment values, sentiment values are in [-5, 5]