(obj, *, tried: bool = False)
| 11 | |
| 12 | # working good |
| 13 | def posttextparser(obj, *, tried: bool = False) -> List[str]: |
| 14 | text: str = re.sub("\n", " ", obj) |
| 15 | try: |
| 16 | nlp = spacy.load("en_core_web_sm") |
| 17 | except OSError as e: |
| 18 | if not tried: |
| 19 | os.system("python -m spacy download en_core_web_sm") |
| 20 | time.sleep(5) |
| 21 | return posttextparser(obj, tried=True) |
| 22 | print_step( |
| 23 | "The spacy model can't load. You need to install it with the command \npython -m spacy download en_core_web_sm " |
| 24 | ) |
| 25 | raise e |
| 26 | |
| 27 | doc = nlp(text) |
| 28 | |
| 29 | newtext: list = [] |
| 30 | |
| 31 | for line in doc.sents: |
| 32 | if sanitize_text(line.text): |
| 33 | newtext.append(line.text) |
| 34 | |
| 35 | return newtext |
no test coverage detected