Skip to content

Instantly share code, notes, and snippets.

@mohdsanadzakirizvi
Created February 6, 2019 05:26
Show Gist options
  • Save mohdsanadzakirizvi/b81a65d1dfde36f9ef07e5a1093989ce to your computer and use it in GitHub Desktop.
Save mohdsanadzakirizvi/b81a65d1dfde36f9ef07e5a1093989ce to your computer and use it in GitHub Desktop.
import pandas as pd
def extract_lemma(doc):
parsed_text = {'word':[], 'lemma':[]}
for sent in doc.sentences:
for wrd in sent.words:
#extract text and lemma
parsed_text['word'].append(wrd.text)
parsed_text['lemma'].append(wrd.lemma)
#return a dataframe
return pd.DataFrame(parsed_text)
extract_lemma(doc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment