#NEWLINE# def _words( self , fileid , bracket_sent , tag , strip_space , stem ) : #NEWLINE# #INDENT# '\n        Helper used to implement the view methods -- returns a list of\n        words or a list of sentences, optionally tagged.\n\n        :param fileid: The name of the underlying file.\n        :param bracket_sent: If true, include sentence bracketing.\n        :param tag: The name of the tagset to use, or None for no tags.\n        :param strip_space: If true, strip spaces from word tokens.\n        :param stem: If true, then substitute stems for words.\n        ' #NEWLINE# result = [ ] #NEWLINE# xmldoc = ElementTree . parse ( fileid ) . getroot ( ) #NEWLINE# for xmlsent in xmldoc . findall ( './/s' ) : #NEWLINE# #INDENT# sent = [ ] #NEWLINE# for xmlword in _all_xmlwords_in ( xmlsent ) : #NEWLINE# #INDENT# word = xmlword . text #NEWLINE# if ( not word ) : #NEWLINE# #INDENT# word = '' #NEWLINE# #UNINDENT# if ( strip_space or stem ) : #NEWLINE# #INDENT# word = word . strip ( ) #NEWLINE# #UNINDENT# if stem : #NEWLINE# #INDENT# word = xmlword . get ( 'hw' , word ) #NEWLINE# #UNINDENT# if ( tag == 'c5' ) : #NEWLINE# #INDENT# word = ( word , xmlword . get ( 'c5' ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( tag == 'pos' ) : #NEWLINE# #INDENT# word = ( word , xmlword . get ( 'pos' , xmlword . get ( 'c5' ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# sent . append ( word ) #NEWLINE# #UNINDENT# if bracket_sent : #NEWLINE# #INDENT# result . append ( BNCSentence ( xmlsent . attrib [ 'n' ] , sent ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# result . extend ( sent ) #NEWLINE# #UNINDENT# #UNINDENT# assert ( None not in result ) #NEWLINE# return result