Skip to content

Instantly share code, notes, and snippets.

Last active Aug 24, 2020
What would you like to do?
import nltk'punkt')
from nltk.tokenize import word_tokenize
import numpy as np
sentences = ["I ate dinner.",
"We had a three-course meal.",
"Brad came to dinner with us.",
"He loves fish tacos.",
"In the end, we all felt like we ate too much.",
"We all agreed; it was a magnificent evening."]
# Tokenization of each document
tokenized_sent = []
for s in sentences:
def cosine(u, v):
return, v) / (np.linalg.norm(u) * np.linalg.norm(v))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment