Package nltk :: Package model :: Module api
[hide private]
[frames] | no frames]

Source Code for Module nltk.model.api

 1   
 2  # subclass of ConditionalProbDistI? 
 3   
4 -class ModelI(object):
5 """ 6 A processing interface for assigning a probability to the next word. 7 """ 8
9 - def __init__(self):
10 '''Create a new language model.''' 11 raise NotImplementedError()
12
13 - def prob(self, word, context):
14 '''Evaluate the probability of this word in this context.''' 15 raise NotImplementedError()
16
17 - def logprob(self, word, context):
18 '''Evaluate the log probability of this word in this context.''' 19 raise NotImplementedError()
20
21 - def choose_random_word(self, context):
22 '''Randomly select a word that is likely to appear in this context.''' 23 raise NotImplementedError()
24
25 - def generate(self, n):
26 '''Generate n words of text from the language model.''' 27 raise NotImplementedError()
28
29 - def entropy(self, text):
30 '''Evaluate the total entropy of a message with respect to the model. 31 This is the sum of the log probability of each word in the message.''' 32 raise NotImplementedError()
33