<s> """<STR_LIT>""" <EOL> from __future__ import unicode_literals <EOL> from nltk import compat <EOL> from nltk . corpus . reader . util import * <EOL> from nltk . corpus . reader . api import * <EOL> @ compat . python_2_unicode_compatible <EOL> class PPAttachment ( object ) : <EOL> def __init__ ( self , sent , verb , noun1 , prep , noun2 , attachment ) : <EOL> self . sent = sent <EOL> self . verb = verb <EOL> self . noun1 = noun1 <EOL> self . prep = prep <EOL> self . noun2 = noun2 <EOL> self . attachment = attachment <EOL> def __repr__ ( self ) : <EOL> return ( '<STR_LIT>' <EOL> '<STR_LIT>' % <EOL> ( self . sent , self . verb , self . noun1 , self . prep , <EOL> self . noun2 , self . attachment ) ) <EOL> class PPAttachmentCorpusReader ( CorpusReader ) : <EOL> """<STR_LIT>""" <EOL> def attachments ( self , fileids ) : <EOL> return concat ( [ StreamBackedCorpusView ( fileid , self . _read_obj_block , <EOL> encoding = enc ) <EOL> for ( fileid , enc ) in self . abspaths ( fileids , True ) ] ) <EOL> def tuples ( self , fileids ) : <EOL> return concat ( [ StreamBackedCorpusView ( fileid , self . _read_tuple_block , <EOL> encoding = enc ) <EOL> for ( fileid , enc ) in self . abspaths ( fileids , True ) ] ) <EOL> def raw ( self , fileids = None ) : <EOL> if fileids is None : fileids = self . _fileids <EOL> elif isinstance ( fileids , compat . string_types ) : fileids = [ fileids ] <EOL> return concat ( [ self . open ( f ) . read ( ) for f in fileids ] ) <EOL> def _read_tuple_block ( self , stream ) : <EOL> line = stream . readline ( ) <EOL> if line : <EOL> return [ tuple ( line . split ( ) ) ] <EOL> else : <EOL> return [ ] <EOL> def _read_obj_block ( self , stream ) : <EOL> line = stream . readline ( ) <EOL> if line : <EOL> return [ PPAttachment ( * line . split ( ) ) ] <EOL> else : <EOL> return [ ] </s>
