Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- emoticons = [":'(", ";)", ":p", ":s", "(:"]
- def get_w_w_e(doc,emo):
- words = set()
- for word in re.split('\\W+', doc):
- if 2 < len(word) < 20:
- words.add(word.lower())
- for word in re.split(' ',doc):
- if word in emo:
- words.add(word)
- return words
- def helper_fun(doc):
- return get_w_w_e(doc,emoticons)
- if __name__ == '__main__':
- sample_ind = int(input())
- test_case=data.pop(sample_ind)
- c1=NaiveBayes(get_words)
- c2=NaiveBayes(helper_fun)
- for x in data:
- c1.train(x[1],x[0])
- c2.train(x[1],x[0])
- print(test_case[1])
- print(f'Vistinska klasa: {test_case[0]}')
- print(f'Klasa predvidena so Naiven Baes (bez emotikoni): {c1.classify_document(test_case[1])}')
- print(f'Klasa predvidena so Naiven Baes (so emotikoni): {c2.classify_document(test_case[1])}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement