<s> """<STR_LIT>""" <EOL> from nltk . compat import string_types <EOL> from nltk . corpus . reader import WordListCorpusReader <EOL> from nltk . corpus . reader . api import * <EOL> class IgnoreReadmeCorpusView ( StreamBackedCorpusView ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> StreamBackedCorpusView . __init__ ( self , * args , ** kwargs ) <EOL> self . _open ( ) <EOL> read_blankline_block ( self . _stream ) <EOL> self . _filepos = [ self . _stream . tell ( ) ] <EOL> class OpinionLexiconCorpusReader ( WordListCorpusReader ) : <EOL> """<STR_LIT>""" <EOL> CorpusView = IgnoreReadmeCorpusView <EOL> def words ( self , fileids = None ) : <EOL> """<STR_LIT>""" <EOL> if fileids is None : fileids = self . _fileids <EOL> elif isinstance ( fileids , compat . string_types ) : fileids = [ fileids ] <EOL> return concat ( [ self . CorpusView ( path , self . _read_word_block , encoding = enc ) <EOL> for ( path , enc , fileid ) in self . abspaths ( fileids , True , True ) ] ) <EOL> def positive ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . words ( '<STR_LIT>' ) <EOL> def negative ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . words ( '<STR_LIT>' ) <EOL> def _read_word_block ( self , stream ) : <EOL> words = [ ] <EOL> for i in range ( <NUM_LIT:20> ) : <EOL> line = stream . readline ( ) <EOL> if not line : <EOL> continue <EOL> words . append ( line . strip ( ) ) <EOL> return words </s>
