Skip to content

Commit

Permalink
initial parsing with nltk
Browse files Browse the repository at this point in the history
  • Loading branch information
tomviner committed Jul 7, 2011
1 parent 61507af commit f45693e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions parse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import nltk

def get_parts(text):
text = nltk.word_tokenize(text)
parts = nltk.pos_tag(text)
dic = {}
for work, part in parts:
if part in dic:
dic[part].append(work)
else:
dic[part] = [work]
return dic

get_parts("hi how are you")

0 comments on commit f45693e

Please sign in to comment.