~kenneth-arnold/luminoso/divisi2-port

« back to all changes in this revision

Viewing changes to luminoso/lib/standalone_nlp/local_unpickle.py

  • Committer: Robert Speer
  • Date: 2010-02-24 21:03:39 UTC
  • Revision ID: rspeer@new-caledonia.media.mit.edu-20100224210339-3fha4qwfh0lkfp1i
making the mac build work better

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from pickle import Unpickler
 
2
from StringIO import StringIO
 
3
 
 
4
module_subst = {
 
5
    'csc.nl': 'nl',
 
6
    'csc.nl.en': 'nl',
 
7
    'csc.nl.euro': 'euro',
 
8
    'csc.nl.mblem.trie': 'trie'
 
9
}
 
10
 
 
11
class LocalUnpickler(Unpickler):
 
12
    def find_class(self, module, name):
 
13
        return Unpickler.find_class(self, module_subst.get(module, module), name)
 
14
 
 
15
def loads(str):
 
16
    file = StringIO(str)
 
17
    return LocalUnpickler(file).load()