python - I write analyze function to return count of token -
i write analyze function return count of token
def analyze(self, text): tokenizer = nltk.tokenize.tweettokenizer() open(text, 'r') lines: tokens = tokenizer.tokenize(str(lines)) score = 0 token in tokens: if token.lower() in self.negatives: score -= 1 elif token.lower() in self.positives: score += 1 return score
call:
print(search.analyze('cat.txt'))
output: 0
there little information functions , file.
try debugging code. example, print each token , score (+1 or -1) , see how model works.
Comments
Post a Comment