Skip to content

Instantly share code, notes, and snippets.

View rmax's full-sized avatar
:octocat:
ヾ(⌐■_■)ノ♪

R Max Espinoza rmax

:octocat:
ヾ(⌐■_■)ノ♪
View GitHub Profile
@mallamanis
mallamanis / texttilling.py
Created December 31, 2011 18:47
Text-tilling implementation with nltk
#!/usr/bin/env python
import nltk
from nltk.stem.porter import PorterStemmer
def preprocessText(text):
# To lower case
text = text.lower();
# Tokenize text
@rgaidot
rgaidot / gist:792451
Created January 23, 2011 21:24
Entity Extraction using NLTK
import nltk
text = """Barack Hussein Obama II (born August 4, 1961) is the 44th and current President of the United States. He is the first African American to hold the office. Obama previously served as a United States Senator from Illinois, from January 2005 until he resigned after his election to the presidency in November 2008."""
sentences = nltk.sent_tokenize(text)
tokenized_sentences = [nltk.word_tokenize(sentence) for sentence in sentences]
tagged_sentences = [nltk.pos_tag(sentence) for sentence in tokenized_sentences]
chunked_sentences = nltk.batch_ne_chunk(tagged_sentences, binary=True)
def extract_entity_names(t):