Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sentence = splitSentences[0]
- words = re.findall("\p{L}+", sentence)
- probUniSentence = 1
- meanUniSentence = 0
- print("Unigram model\n=====================================================")
- print("wi C(wi) #words P(wi)\n=====================================================")
- for word in words:
- probSentence = probUnigrams[word] * probUniSentence
- meanUniSentence = meanUniSentence + probUnigrams[word]/len(words)
- print(word,freqUnigrams[word], nbrUnigrams, probUnigrams[word])
- print("=====================================================")
- print("Prob. unigrams: ", probUniSentence)
- print("Geometric mean prob.: ", meanUniSentence)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement