Package jazzparser :: Package utils :: Package nltk :: Module storage
[hide private]
[frames] | no frames]

Module storage

source code

Elaborate ruse to allow NLTK's probability models to be stored to disk.

NLTK's classes can't all be pickled and it doesn't provide any other way of storing things like probability distributions. This module provides procedures to produce a picklable representation of various NLTK classes.


Author: Mark Granroth-Wilding <mark.granroth-wilding@ed.ac.uk>

Classes [hide private]
  ObjectStorer
Interface for various storers that take certain types of objects and produce a dictionary with the essential data needed to recreate them.
  ObjectStorerError
  FreqDistStorer
  ConditionalProbDistStorer
  MLEProbDistStorer
  LaplaceProbDistStorer
  WittenBellProbDistStorer
  GoodTuringProbDistStorer
  ConditionalFreqDistStorer
  DictionaryProbDistStorer
  MutableProbDistStorer
  DictionaryConditionalProbDistStorer
Functions [hide private]
 
is_picklable(obj)
Returns True is the given object can be successfully pickled, False otherwise.
source code
 
get_storer(cls)
Returns an ObjectStorer subclass that store's the given type if one is found.
source code
 
object_to_dict(obj) source code
 
dict_to_object(dic) source code
Variables [hide private]
  __package__ = 'jazzparser.utils.nltk'
Function Details [hide private]

is_picklable(obj)

source code 

Returns True is the given object can be successfully pickled, False otherwise. This is just a neat way of catching a pickling error and usually you'll be better off trying to pickle and catching the exception.

get_storer(cls)

source code 

Returns an ObjectStorer subclass that store's the given type if one is found. Raises an ObjectStorerError otherwise.