class documentation

Reader for the Comparative Sentence Dataset by Jindal and Liu (2006).

>>> from nltk.corpus import comparative_sentences
>>> comparison = comparative_sentences.comparisons()[0]
>>> comparison.text
['its', 'fast-forward', 'and', 'rewind', 'work', 'much', 'more', 'smoothly',
'and', 'consistently', 'than', 'those', 'of', 'other', 'models', 'i', "'ve",
'had', '.']
>>> comparison.entity_2
'models'
>>> (comparison.feature, comparison.keyword)
('rewind', 'more')
>>> len(comparative_sentences.comparisons())
853
Method __init__ No summary
Method comparisons Return all comparisons in the corpus.
Method keywords Return a set of all keywords used in the corpus.
Method keywords_readme Return the list of words and constituents considered as clues of a comparison (from listOfkeywords.txt).
Method raw No summary
Method readme Return the contents of the corpus readme file.
Method sents Return all sentences in the corpus.
Method words Return all words and punctuation symbols in the corpus.
Method _read_comparison_block Undocumented
Method _read_keyword_block Undocumented
Method _read_sent_block Undocumented
Method _read_word_block Undocumented
Instance Variable _sent_tokenizer Undocumented
Instance Variable _word_tokenizer 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.
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 __init__(self, root, fileids, word_tokenizer=WhitespaceTokenizer(), sent_tokenizer=None, encoding='utf8'): (source)
Parameters
rootThe root directory for this corpus.
fileidsa list or regexp specifying the fileids in this corpus.
word_tokenizertokenizer for breaking sentences or paragraphs into words. Default: WhitespaceTokenizer
sent_tokenizertokenizer for breaking paragraphs into sentences.
encodingthe encoding that should be used to read the corpus.
def comparisons(self, fileids=None): (source)

Return all comparisons in the corpus.

Parameters
fileidsa list or regexp specifying the ids of the files whose comparisons have to be returned.
Returns
list(Comparison)the given file(s) as a list of Comparison objects.
def keywords(self, fileids=None): (source)

Return a set of all keywords used in the corpus.

Parameters
fileidsa list or regexp specifying the ids of the files whose keywords have to be returned.
Returns
set(str)the set of keywords and comparative phrases used in the corpus.
def keywords_readme(self): (source)

Return the list of words and constituents considered as clues of a comparison (from listOfkeywords.txt).

def raw(self, fileids=None): (source)
Parameters
fileidsa list or regexp specifying the fileids that have to be returned as a raw string.
Returns
strthe given file(s) as a single string.
def readme(self): (source)

Return the contents of the corpus readme file.

def sents(self, fileids=None): (source)

Return all sentences in the corpus.

Parameters
fileidsa list or regexp specifying the ids of the files whose sentences have to be returned.
Returns
list(list(str)) or list(str)all sentences of the corpus as lists of tokens (or as plain strings, if no word tokenizer is specified).
def words(self, fileids=None): (source)

Return all words and punctuation symbols in the corpus.

Parameters
fileidsa list or regexp specifying the ids of the files whose words have to be returned.
Returns
list(str)the given file(s) as a list of words and punctuation symbols.
def _read_comparison_block(self, stream): (source)

Undocumented

def _read_keyword_block(self, stream): (source)

Undocumented

def _read_sent_block(self, stream): (source)

Undocumented

def _read_word_block(self, stream): (source)

Undocumented

_sent_tokenizer = (source)

Undocumented

_word_tokenizer = (source)

Undocumented