Package nltk_lite :: Package contrib :: Module concord :: Class SentencesIndex
[hide private]
[frames] | no frames]

Class SentencesIndex

source code

object --+
         |
        SentencesIndex

Class implementing an index of a collection of sentences.

Given a list of sentences, where each sentence is a list of words, this class generates an index of the list. Each word should be a (word, POS tag) pair. The index is stored as a dictionary, with the hashable items as keys and a list of (sentence number, word number) tuples as values. This class also generates a list of sentence lengths.

Instance Methods [hide private]
 
__init__(self, sentences)
Constructor.
source code
dictionary
getIndex(self)
Returns the index dictionary.
source code
list
getSentenceLengths(self)
Returns the list of sentence lengths.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, sentences)
(Constructor)

source code 

Constructor. Takes the list of sentences to index.

Parameters:
  • sentences (list) - List of sentences to index. Sentences should be lists of (string, string) pairs.
Overrides: object.__init__

getIndex(self)

source code 

Returns the index dictionary.

Returns: dictionary
The dictionary containing the index.

getSentenceLengths(self)

source code 

Returns the list of sentence lengths.

Element 0 is the length of the first sentence, element 1 the second, etc.

Returns: list
List of lengths of sentences.