Skip to content

Instantly share code, notes, and snippets.

@nanotroy
Created June 12, 2019 22:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nanotroy/b3b267b1d5615764db97df36fad930e8 to your computer and use it in GitHub Desktop.
Save nanotroy/b3b267b1d5615764db97df36fad930e8 to your computer and use it in GitHub Desktop.
def process_text(text):
doc = nlp(text.lower())
result = []
for token in doc:
if token.text in nlp.Defaults.stop_words:
continue
if token.is_punct:
continue
if token.lemma_ == '-PRON-'
continue
result.append(token.lemma_)
return " ".join(result)
@andyembleton
Copy link

Line 9 needs a colon at the end.
[I got here via https://medium.com/better-programming/the-beginners-guide-to-similarity-matching-using-spacy-782fc2922f7c]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment