def check_sentence(text):
"""
Check, that only one sentence was provided.
>>> QASystem.check_sentence("Example sentence.")
>>> QASystem.check_sentence("Example sentence. Another example.")
Traceback (most recent call last):
core.MultipleSentences: ['Example sentence.', 'Another example.']
Args:
text (str): provided question/answer.
Returns:
None
Raises:
MultipleSentenceQuestion: in case of more than one sentence inside
of the text string.
"""
sent_tokenize_list = sent_tokenize(text) # nltk tokenize sentence
if len(sent_tokenize_list) > 1:
raise MultipleSentences(sent_tokenize_list)
评论列表
文章目录