storing dataset from a Conditional FreqDist

13 views
Skip to first unread message

Jose

unread,
Jan 19, 2015, 5:09:28 AM1/19/15
to nltk-...@googlegroups.com
Hello,  i, have been trying to store all  the information in an arff file using python, Any idea of how can i do that?


with open('fileids3.txt', 'r') as f:
   
genres=[word.strip() for word in f.next().split(',')]  

with open('adjectifs2.txt', 'r') as g:
adj = [word.strip() for word in g.next().split(',')]
freq = nltk.ConditionalFreqDist(
     (genre, m)
      for genre in brown.fileids()
      for m in brown.words(fileids=genre))


freq.tabulate(conditions=genres, samples=adj)


Alexis Dimitriadis

unread,
Jan 20, 2015, 4:49:31 PM1/20/15
to nltk-...@googlegroups.com
A ConditionalFreqDist is a collection of python dictionaries (one per condition), so you can extract them and write them out using the ordinary dictionary iteration methods (items(), keys(), etc.)

Alexis

Dr. Alexis Dimitriadis | Assistant Professor and Senior Research Fellow | Utrecht Institute of Linguistics OTS | Utrecht University | Trans 10, 3512 JK Utrecht, room 2.33 | +31 30 253 65 68 | a.dimi...@uu.nl | www.hum.uu.nl/medewerkers/a.dimitriadis

--
You received this message because you are subscribed to the Google Groups "nltk-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nltk-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages