Spaces:
Runtime error
Runtime error
Download preprocessor.py from Shoaib-33/News-Summarizer: direct link, hf CLI and curl.
- Browser
- Download file 443 Bytes
-
https://huggingface.co/spaces/Shoaib-33/News-Summarizer/resolve/main/preprocessor.py
- Command line
-
hf download hf://spaces/Shoaib-33/News-Summarizer/preprocessor.py
-
curl -L -o preprocessor.py https://huggingface.co/spaces/Shoaib-33/News-Summarizer/resolve/main/preprocessor.py
443 Bytes
| import spacy | |
| nlp = spacy.load('en_core_web_sm') | |
| def preprocesser(text_array): | |
| preprocessed_texts = [] | |
| for text in text_array: | |
| doc = nlp(text) | |
| words_lst = [] | |
| for token in doc: | |
| if not token.is_stop and not token.is_punct: | |
| words_lst.append(token.lemma_) | |
| preprocessed_text = " ".join(words_lst) | |
| preprocessed_texts.append(preprocessed_text) | |
| return preprocessed_texts |