Move packages
Signed-off-by: András Schmelczer <andras@schmelczer.dev>
This commit is contained in:
parent
cef2e51c67
commit
acbdd96883
1 changed files with 123 additions and 27 deletions
18
good_ai/src/good_ai/utilities/get_sentences.py
Normal file
18
good_ai/src/good_ai/utilities/get_sentences.py
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
from typing import List
|
||||
|
||||
from .data import sentence_ending_punctuations
|
||||
from .nlp import nlp
|
||||
|
||||
|
||||
def get_sentences(text: str, ignore_partial: bool = False) -> List[str]:
|
||||
doc = nlp(text)
|
||||
possible_sentences = [s.text for s in doc.sents]
|
||||
|
||||
if ignore_partial:
|
||||
possible_sentences = [
|
||||
s
|
||||
for s in possible_sentences
|
||||
if s[0].isupper() and s[-1] in sentence_ending_punctuations
|
||||
]
|
||||
|
||||
return possible_sentences
|
||||
Loading…
Reference in a new issue