MCPcopy Index your code
hub / github.com/elebumm/RedditVideoMakerBot / posttextparser

Function posttextparser

utils/posttextparser.py:13–35  ·  view source on GitHub ↗
(obj, *, tried: bool = False)

Source from the content-addressed store, hash-verified

11
12# working good
13def 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

Callers 1

get_subreddit_threadsFunction · 0.90

Calls 2

print_stepFunction · 0.90
sanitize_textFunction · 0.90

Tested by

no test coverage detected