Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import nltk
- #from nltk.corpus import senseval as ss
- # This shows what files from senseval are in NLTK. sadly there's only 4.
- print nltk.corpus.senseval.fileids()
- # This yields the line by line xml version of the senseval data.
- # note the "\n" are also in each line.
- print nltk.corpus.senseval.raw()
- # Most probably the individual instances are what you wanted to get.
- for id in nltk.corpus.senseval.fileids():
- # This access all instances from each file.
- insts = nltk.corpus.senseval.instances(id)
- # Looping through the instances.
- for i in insts:
- print i
- # SensevalInstance returns (word, position, context, senses),
- # so you can each variable as such:
- print i.word, i.position, i.senses
- print i.context
Advertisement
Add Comment
Please, Sign In to add comment