CoolFace
Apppublic

gr8testgad-1/Movie-Review-Analysis

sourceHugging Facemitupdated 2y agoView on Hugging Face
0likes
text_preprocessing.py27 linesDownload Raw Back to root
1# text_preprocessing.py2 3# import spacy4# import string5 6# nlp = spacy.load("en_core_web_sm")7# stopwords = set(spacy.lang.en.STOP_WORDS)8# punctuations = string.punctuation9 10# def process_text(text):11#     doc = nlp(text)12#     tokens = [token.text for token in doc if token.text not in stopwords and token.text not in punctuations]13#     return ' '.join(tokens)14 15import spacy16import string17from spacy.lang.en import English18 19nlp = English()20stopwords = set(spacy.lang.en.STOP_WORDS)21punctuations = string.punctuation22 23def process_text(text):24    doc = nlp(text)25    tokens = [token.text for token in doc if token.text not in stopwords and token.text not in punctuations]26    return ' '.join(tokens)27