class documentation

Wrapper for the LISP-formatted thesauruses distributed by Dekang Lin.

Method __contains__ Determines whether or not the given ngram is in the thesaurus.
Method __init__ Initialize the thesaurus.
Method scored_synonyms Returns a list of scored synonyms (tuples of synonyms and scores) for the current ngram
Method similarity Returns the similarity score for two ngrams.
Method synonyms Returns a list of synonyms for the current ngram.
Static Method __defaultdict_factory Factory for creating defaultdict of defaultdict(dict)s
Class Variable _key_re Undocumented
Instance Variable _badscore Undocumented
Instance Variable _thesaurus Undocumented

Inherited from CorpusReader:

Method __repr__ Undocumented
Method abspath Return the absolute path for the given file.
Method abspaths Return a list of the absolute paths for all fileids in this corpus; or for the given list of fileids, if specified.
Method citation Return the contents of the corpus citation.bib file, if it exists.
Method encoding Return the unicode encoding for the given corpus file, if known. If the encoding is unknown, or if the given file should be processed using byte strings (str), then return None.
Method ensure_loaded Load this corpus (if it has not already been loaded). This is used by LazyCorpusLoader as a simple method that can be used to make sure a corpus is loaded -- e.g., in case a user wants to do help(some_corpus).
Method fileids Return a list of file identifiers for the fileids that make up this corpus.
Method license Return the contents of the corpus LICENSE file, if it exists.
Method open Return an open stream that can be used to read the given file. If the file's encoding is not None, then the stream will automatically decode the file's contents into unicode.
Method readme Return the contents of the corpus README file, if it exists.
Class Variable root Undocumented
Method _get_root Undocumented
Instance Variable _encoding The default unicode encoding for the fileids that make up this corpus. If encoding is None, then the file contents are processed using byte strings.
Instance Variable _fileids A list of the relative paths for the fileids that make up this corpus.
Instance Variable _root The root directory for this corpus.
Instance Variable _tagset Undocumented
def __contains__(self, ngram): (source)

Determines whether or not the given ngram is in the thesaurus.

Parameters
ngram:C{string}ngram to lookup
Returns
whether the given ngram is in the thesaurus.
def __init__(self, root, badscore=0.0): (source)

Initialize the thesaurus.

Parameters
root:C{string}root directory containing thesaurus LISP files
badscore:C{float}the score to give to words which do not appear in each other's sets of synonyms
def scored_synonyms(self, ngram, fileid=None): (source)

Returns a list of scored synonyms (tuples of synonyms and scores) for the current ngram

Parameters
ngram:C{string}ngram to lookup
fileid:C{string}thesaurus fileid to search in. If None, search all fileids.
Returns
If fileid is specified, list of tuples of scores and synonyms; otherwise, list of tuples of fileids and lists, where inner lists consist of tuples of scores and synonyms.
def similarity(self, ngram1, ngram2, fileid=None): (source)

Returns the similarity score for two ngrams.

Parameters
ngram1:C{string}first ngram to compare
ngram2:C{string}second ngram to compare
fileid:C{string}thesaurus fileid to search in. If None, search all fileids.
Returns
If fileid is specified, just the score for the two ngrams; otherwise, list of tuples of fileids and scores.
def synonyms(self, ngram, fileid=None): (source)

Returns a list of synonyms for the current ngram.

Parameters
ngram:C{string}ngram to lookup
fileid:C{string}thesaurus fileid to search in. If None, search all fileids.
Returns
If fileid is specified, list of synonyms; otherwise, list of tuples of fileids and lists, where inner lists contain synonyms.
@staticmethod
def __defaultdict_factory(): (source)

Factory for creating defaultdict of defaultdict(dict)s

Undocumented

_badscore = (source)

Undocumented

_thesaurus = (source)

Undocumented