<commit_before><commit_msg>added tf feature<commit_after>from features import abstract_feature as af
import words_processing as wp
import nltk

class Tf(af.AbstractFeature):

    def __repr__(self):
        return "<Tf>"

    def __str__(self):
        return "TF"

    def extract(self, tweet):
        freq_max = 0
        text = wp.preprocessing(tweet.text)
        tokens = nltk.word_tokenize(text)

        for word in tokens:
            v = self.data[word]
            if v > freq_max:
                freq_max = v

        return "tf",v
{'fraction_non_alphanumeric': 0.08639705882352941, 'fraction_numerical': 0.001838235294117647, 'mean_word_length': 2.1871345029239766, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3798674', 'n_tokens_mistral': 175, 'n_tokens_neox': 164, 'n_words': 46}