本文整理汇总了Python中nltk.corpus.reader.ChunkedCorpusReader.chunked_para方法的典型用法代码示例。如果您正苦于以下问题:Python ChunkedCorpusReader.chunked_para方法的具体用法?Python ChunkedCorpusReader.chunked_para怎么用?Python ChunkedCorpusReader.chunked_para使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nltk.corpus.reader.ChunkedCorpusReader
的用法示例。
在下文中一共展示了ChunkedCorpusReader.chunked_para方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Tree
# 需要导入模块: from nltk.corpus.reader import ChunkedCorpusReader [as 别名]
# 或者: from nltk.corpus.reader.ChunkedCorpusReader import chunked_para [as 别名]
########## CHUNKED CORPUS READER ###############
###Implementing CCR
from nltk.corpus.reader import ChunkedCorpusReader
root="C:\\Users\\Matrix\\AppData\\Roaming\\nltk_data\\corpora\\cookbook\\"
reader=ChunkedCorpusReader(root,r'.*\.chunk')
#Each chunk-represented in braces is considered as a word
print reader.chunked_words()
#Each sentence will be included in a Tree()
print reader.chunked_sents()
print reader.chunked_paras()
#Getting tagged tokens for each chunk (each chunk is a word but each word is not a chunk)
print reader.chunked_words()[0].leaves()
print reader.chunked_sents()[1].leaves()
#Cant apply leaves directly to a para - but we can access a sentence of a given para.
print reader.chunked_para()[0][0].leaves()
###Implementing CCCR
from nltk.corpus.reader import ConllChunkCorpusReader
root="C:\\Users\\Matrix\\AppData\\Roaming\\nltk_data\\corpora\\cookbook\\"
reader=ConllChunkCorpusReader(root,r'.*\.iob',('NP','VP'.'PP'))
print reader.chunked_words()
print reader.chunked_sents()
print reader.iob_words()
print reader.iob_sents()