Spaces:
Runtime error
Runtime error
Commit History
-
main.py
Verified signaturefrom contextlib import asynccontextmanager from fastapi import FastAPI, HTTPException from pydantic import BaseModel, ValidationError from fastapi.encoders import jsonable_encoder # TEXT PREPROCESSING # -------------------------------------------------------------------- import re import string import nltk nltk.download('punkt') nltk.download('wordnet') nltk.download('omw-1.4') from nltk.stem import WordNetLemmatizer # Function to remove URLs from text def remove_urls(text): return re.sub(r'http[s]?://\S+', '', text) # Function to remove punctuations from text def remove_punctuation(text): regular_punct = string.punctuation return str(re.sub(r'['+regular_punct+']', '', str(text))) # Function to convert the text into lower case def lower_case(text): return text.lower() # Function to lemmatize text def lemmatize(text): wordnet_lemmatizer = WordNetLemmatizer() tokens = nltk.word_tokenize(text) lemma_txt = '' for w in tokens: lemma_txt = lemma_…02703ea