如何检查一个句子是否是一个带有空格的问题? [英] How to check if a sentence is a question with spacy?
问题描述
我正在使用 spacy 库来构建聊天机器人.如何有把握地检查文档是否是问题?我知道如何做相关性,但不确定如何从问题中过滤陈述.
I am using spacy library to build a chat bot. How do I check if a document is a question with a certain confidence? I know how to do relevance, but not sure how to filter statements from questions.
我正在寻找如下内容:
spacy.load('en_core_web_lg')('Is this a question?').is_question
推荐答案
我的第一反应是建议在句尾找问号.
My first response is to suggest looking for question marks at the end of the sentence.
否则,大多数问题都以{is、does、do、what、when、where、who、why、what、how}开头.
Otherwise, most questions start with {is, does, do, what, when, where, who, why, what, how}.
有一个更复杂的答案,涉及包含助动词及其相对于动词的位置,但如果您的数据格式正确,这可能就足够了(而且速度很快).
There is a more complex answer involving the inclusion of auxiliary verbs and their placement relative to the verb, but if your data is well-formed, this may be sufficient (and fast).
这篇关于如何检查一个句子是否是一个带有空格的问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!