Package nltk_lite :: Package model
[hide private]
[frames] | no frames]

Source Code for Package nltk_lite.model

 1  # Natural Language Toolkit: Language Models 
 2  # 
 3  # Copyright (C) 2001-2007 University of Pennsylvania 
 4  # Author: Steven Bird <sb@csse.unimelb.edu.au> 
 5  # URL: <http://nltk.sf.net> 
 6  # For license information, see LICENSE.TXT 
 7   
8 -class ModelI(object):
9 """ 10 A processing interface for assigning a probability to the next word. 11 """ 12
13 - def __init__(self):
14 '''Create a new language model.''' 15 raise NotImplementedError()
16
17 - def train(self, text):
18 '''Train the model on the text.''' 19 raise NotImplementedError()
20
21 - def probability(self, word, context):
22 '''Evaluate the probability of this word in this context.''' 23 raise NotImplementedError()
24
25 - def choose_random_word(self, context):
26 '''Randomly select a word that is likely to appear in this context.''' 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