Monday, January 17, 2011

FYP Post 3: Finding relations betweeen nouns

I am trying to create a hierarchy tree for my nouns but somehow it doesn't seem to go well

>>> sentence = [('The', 'DT'), ('average', 'JJ'), ('compact', 'NN'), ('point-and-shoot', 'NN'), ('camera', 'NN'), ('has', 'VBZ'), ('a', 'DT'), ('4x', 'CD'), ('or', 'CC'), ('5x', 'CD'), ('zoom', 'NN'), ('lens', 'NNS'), ('in', 'IN'), ('it', 'PRP')]
>>> print cp.parse(sentence)
(S
The/DT
average/JJ
(NP compact/NN point-and-shoot/NN camera/NN)
has/VBZ
a/DT
4x/CD
or/CC
5x/CD
zoom/NN
lens/NNS
in/IN
it/PRP)
>>> tree = nltk.tree('NP', ['camera'])

No comments:

Post a Comment