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

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -