I have a dataset named news_collection.csv where that has news and what I was struggling to do is that to replace words.
def similarity():
tweets = pd.read_csv(r'news_collection.csv')
df = pd.DataFrame(tweets, columns=['created_at', 'text'])
df['created_at'] = pd.to_datetime(df['created_at'])
df['text'] = df['text'].apply(lambda x: str(x))
df["text"] = df["text"].apply(lambda x: replacesynonyms(x))
return df
def replacesynonyms(text):
file = open('syno.txt', 'r', encoding="utf8")
//code to be added
Can someone help to solve this algorithm?