我做了一个基于马尔可夫链的python项目来创建句子。现在我必须做同样的事情,但在处理中。这是我需要帮助的python代码def createProbabilityHash(words)
:
def createProbabilityHash(words):
numWords = len(words)
wordCount = {}
for word in words:
if wordCount.has_key(word):
wordCount[word] += 1
else:
wordCount[word] = 1