This commit is contained in:
Simon committed 2023-05-28 15:38:06 +02:00
1 parent 0a1ba17d0e
commit 280b125505
5 files changed
+20 -50

No files matched your search

+8 -7
View File
@@ -1,5 +1,6 @@
import os
import re
import time
from typing import List
import spacy
@@ -9,19 +10,19 @@ from utils.voice import sanitize_text
# working good
def posttextparser(obj,*,tried:bool=False) -> List[str]:
text:str = re.sub("\n", " ", obj)
def posttextparser(obj, *, tried: bool = False) -> List[str]:
text: str = re.sub("\n", " ", obj)
try:
nlp = spacy.load("en_core_web_sm")
except OSError as e:
if not tried:
os.system("python -m spacy download en_core_web_sm")
return posttextparser(obj,tried=True)
print_step(" The spacy model can't load. You need to install it with the command \npython -m spacy download en_core_web_sm ")
time.sleep(5)
return posttextparser(obj, tried=True)
print_step(
"The spacy model can't load. You need to install it with the command \npython -m spacy download en_core_web_sm ")
raise e
doc = nlp(text)
newtext: list = []