Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. sentence = splitSentences[0]
  2. words = re.findall("\p{L}+", sentence)
  3. probUniSentence = 1
  4. meanUniSentence = 0
  5. print("Unigram model\n=====================================================")
  6. print("wi C(wi) #words P(wi)\n=====================================================")
  7. for word in words:
  8. probSentence = probUnigrams[word] * probUniSentence
  9. meanUniSentence = meanUniSentence + probUnigrams[word]/len(words)
  10. print(word,freqUnigrams[word], nbrUnigrams, probUnigrams[word])
  11.  
  12. print("=====================================================")
  13. print("Prob. unigrams: ", probUniSentence)
  14. print("Geometric mean prob.: ", meanUniSentence)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement