Skip to content

Instantly share code, notes, and snippets.

Avatar

Adam Bannister AtomsForPeace

View GitHub Profile
@AtomsForPeace
AtomsForPeace / nltk-intro.py
Last active Mar 10, 2016 — forked from alexbowe/nltk-intro.py
Demonstration of extracting key phrases with NLTK in Python
View nltk-intro.py
import nltk
text = """The Buddha, the Godhead, resides quite as comfortably in the circuits of a digital
computer or the gears of a cycle transmission as he does at the top of a mountain
or in the petals of a flower. To think otherwise is to demean the Buddha...which is
to demean oneself."""
# Used when tokenizing words
sentence_re = r'(?:(?:[A-Z])(?:.[A-Z])+.?)|(?:\w+(?:-\w+)*)|(?:\$?\d+(?:.\d+)?%?)|(?:...|)(?:[][.,;"\'?():-_`])'