Saving Taxonomies

32 views
Skip to first unread message

Alex

unread,
Nov 20, 2011, 11:39:56 AM11/20/11
to pattern-f...@googlegroups.com
What is the best way to save a taxonomy?  I tried to Pickle it, but got "TypeError: can't pickle instancemethod objects".  Should I save a CSV and create a new taxonomy each time I need it?

Thanks,
Alex

Tom De Smedt

unread,
Nov 30, 2011, 6:24:56 PM11/30/11
to Pattern
It can't be pickled when it uses classifiers, I believe, because they
contain lambda (anonymous) functions. Do you happen to use
WordNetClassifier in your taxonomy? I think the best approach would be
to save the actual data that goes into the classifier (e.g., as a CSV
with term;type;value lines), and have a script that reads in the data,
and then appends the classifiers. Reading from text file is not always
slower than reading from a pickle.

If you happen to come up with code that does this, let me know then
I'll add it to the module. For example, there could be a
Taxonomy.read_csv() classmethod and a Taxonomy.write_csv() method.

Best,
Tom

Reply all
Reply to author
Forward
0 new messages