Skip to content

Instantly share code, notes, and snippets.

@himlohiya
Created June 29, 2018 19:02
Show Gist options
  • Select an option

  • Save himlohiya/7babed0c3a662f180818fbd5b6a0b073 to your computer and use it in GitHub Desktop.

Select an option

Save himlohiya/7babed0c3a662f180818fbd5b6a0b073 to your computer and use it in GitHub Desktop.
pos_tagging_spacy(sentence) {
sentence_nlp = nlp(sentence)
# POS tagging with Spacy
spacy_pos_tagged = [(word, word.tag_, word.pos_) for word in sentence_nlp]
pd.DataFrame(spacy_pos_tagged, columns=['Word', 'POS tag', 'Tag type'])
}
pos_tagging_nltk(sentence) {
# POS tagging with nltk
nltk_pos_tagged = nltk.pos_tag(sentence.split())
pd.DataFrame(nltk_pos_tagged, columns=['Word', 'POS tag'])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment