本文整理匯總了Python中nltk.corpus.reader.xmldocs.XMLCorpusView.read_block方法的典型用法代碼示例。如果您正苦於以下問題:Python XMLCorpusView.read_block方法的具體用法?Python XMLCorpusView.read_block怎麽用?Python XMLCorpusView.read_block使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類nltk.corpus.reader.xmldocs.XMLCorpusView
的用法示例。
在下文中一共展示了XMLCorpusView.read_block方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: read_block
# 需要導入模塊: from nltk.corpus.reader.xmldocs import XMLCorpusView [as 別名]
# 或者: from nltk.corpus.reader.xmldocs.XMLCorpusView import read_block [as 別名]
def read_block(self, stream, tagspec=None, elt_handler=None):
return list(
filter(
lambda x: x is not None,
XMLCorpusView.read_block(self, stream, tagspec, elt_handler),
)
)
示例2: handle_query
# 需要導入模塊: from nltk.corpus.reader.xmldocs import XMLCorpusView [as 別名]
# 或者: from nltk.corpus.reader.xmldocs.XMLCorpusView import read_block [as 別名]
def handle_query(self):
self._open()
header = []
while True:
segm = XMLCorpusView.read_block(self, self._stream)
if len(segm) == 0:
break
header.extend(segm)
self.close()
return header
示例3: read_block
# 需要導入模塊: from nltk.corpus.reader.xmldocs import XMLCorpusView [as 別名]
# 或者: from nltk.corpus.reader.xmldocs.XMLCorpusView import read_block [as 別名]
def read_block(self, stream, tagspec=None, elt_handler=None):
"""
Returns text as a list of sentences.
"""
txt = []
while True:
segm = XMLCorpusView.read_block(self, stream)
if len(segm) == 0:
break
for part in segm:
txt.append(part)
return [' '.join([segm for segm in txt])]