【发布时间】:2018-11-04 11:24:43
【问题描述】:
我是 NLTK
的新手这是我用过的代码,
text="The pizza was 66 and brilliant"
pattern = r"""
P: {<NN>+<VBD>+<CD>+}
"""
for sent in sent_tokenize(text):
sentence = sent.split()
PChunker = RegexpParser(pattern)
output= PChunker.parse(pos_tag(sentence))
print(output)
我得到了输出,
(S The/DT (P pizza/NN was/VBD 66/CD) and/CC brilliant/VB)
我需要输出,
pizza was 66
我怎样才能得到这个?
【问题讨论】:
-
看起来
output是一种匹配对象。文档是否有关于如何从中获取匹配文本的任何信息? -
我没有找到任何相关信息
标签: python regex python-3.x nltk