使用python提取句子 [英] extract a sentence using python

查看:309
本文介绍了使用python提取句子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果某个句子中存在某个特定单词,我想提取出确切的句子.谁能让我知道如何使用python做到这一点.我使用了concordance(),但是它只打印单词匹配的行.

I would like to extract the exact sentence if a particular word is present in that sentence. Could anyone let me know how to do it with python. I used concordance() but it only prints lines where the word matches.

推荐答案

快速提醒一下:断句实际上是一件非常复杂的事情,句号规则也有例外,例如先生".或博士"还有各种各样的句子结尾标点符号.但是例外也有例外(例如,如果下一个单词用大写字母表示,并且不是专有名词,那么Dr.可以结束一个句子.)

Just a quick reminder: Sentence breaking is actually a pretty complex thing, there's exceptions to the period rule, such as "Mr." or "Dr." There's also a variety of sentence ending punctuation marks. But there's also exceptions to the exception (if the next word is Capitalized and is not a proper noun, then Dr. can end a sentence, for example).

如果您对此感兴趣(这是自然语言处理主题),可以签出:
自然语言工具包(nltk) punkt模块

If you're interested in this (it's a natural language processing topic) you could check out:
the natural language tool kit's (nltk) punkt module.

这篇关于使用python提取句子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆