python - 如何从文本中删除一组 pos 标签(块)
问题描述
我想删除文本中的所有问题,所以我做了一些块来检测文本中的问题
sample_text = """
where did you go ?
is there anybody out there?
can you tell me where i can find you ? please.
do you know me?
"""
sentences=sent_tokenize(sample_text)
for s in sentences:
tagged = pos_tag(word_tokenize(s))
chunker = RegexpParser(r"""
normalQuestion: {<WRB|WP.?><.*>*}
Question: {<VBP|VBZ.?>+<.*>*}
canQuestion:{<MD><PRP><VB><.*>*}
doQuesiton: {<VB><PRP><VB><.*>*}
""")
output = chunker.parse(tagged)
for a in chunked:
if isinstance(a, nltk.tree.Tree):
if a.label() == "Question":
a.draw()
现在我想从原文中删除它
解决方案
推荐阅读
- ios - 使用 Facebook 注册 Cognito 不会创建用户
- pic - PicKit3 和 PIC16F1829 编程,MCLR 电压
- javascript - 如何使用 NUXT.js 为我的传单地图设置自定义标记图标
- ionic-framework - 离子深度链接在推送深度链接/页面之前显示空白页面
- python - Python:从命令行运行小型多行脚本
- xml - 解析 XML 并重命名文件名中的特殊字符(XML 和位置)
- python - 每当任何 ERROR 单词出现在 pyspark 的一行中时,我如何获取文件中的下一行?
- android - 未解决的类 .MainActivity (以及我所有的其他类)
- ssh - 主从节点之间的无密码连接
- c# - 如何在子类中访问父类的某些属性(不是全部)?