Beispiel #1
0
    def to_picklable_dict(self):
        """ Produces a picklable representation of model as a dict. """
        from jazzparser.utils.nltk.storage import object_to_dict

        if self.backoff_model is not None:
            backoff_model = self.backoff_model.to_picklable_dict()
        else:
            backoff_model = None

        return {
            'order':
            self.order,
            'root_transition_counts':
            object_to_dict(self.root_transition_counts),
            'schema_transition_counts':
            object_to_dict(self.schema_transition_counts),
            'emission_counts':
            object_to_dict(self.emission_counts),
            'estimator':
            self._estimator,
            'backoff_model':
            backoff_model,
            'chord_vocab':
            self.chord_vocab,
            'schemata':
            self.schemata,
            'history':
            self.history,
        }
Beispiel #2
0
 def to_picklable_dict(self):
     """
     Produces a picklable representation of model as a dict.
     
     """
     from jazzparser.utils.nltk.storage import object_to_dict
     
     return {
         'label_dom' : self.label_dom,
         'emission_dom' : self.emission_dom,
         'label_dist' : object_to_dict(self.label_dist),
         'emission_dist' : object_to_dict(self.emission_dist),
     }
Beispiel #3
0
    def to_picklable_dict(self):
        """
        Produces a picklable representation of model as a dict.
        
        """
        from jazzparser.utils.nltk.storage import object_to_dict

        return {
            'label_dom': self.label_dom,
            'emission_dom': self.emission_dom,
            'label_dist': object_to_dict(self.label_dist),
            'emission_dist': object_to_dict(self.emission_dist),
        }
Beispiel #4
0
 def _get_model_data(self):
     data = {
         'parents' : object_to_dict(self._parent_counts),
         'expansions' : object_to_dict(self._expansion_type_counts),
         'heads' : object_to_dict(self._head_expansion_counts),
         'non_heads' : object_to_dict(self._non_head_expansion_counts),
         'words' : object_to_dict(self._lexical_counts),
         'cutoff' : self.cutoff,
         'cat_bins' : self.cat_bins,
         'estimator': self._estimator,
         'grammar' : self.grammar,
         'lexical' : self.lexical,
         'chordmap' : self.chordmap.name,
     }
     return data
Beispiel #5
0
 def _get_model_data(self):
     data = {
         'parents': object_to_dict(self._parent_counts),
         'expansions': object_to_dict(self._expansion_type_counts),
         'heads': object_to_dict(self._head_expansion_counts),
         'non_heads': object_to_dict(self._non_head_expansion_counts),
         'words': object_to_dict(self._lexical_counts),
         'cutoff': self.cutoff,
         'cat_bins': self.cat_bins,
         'estimator': self._estimator,
         'grammar': self.grammar,
         'lexical': self.lexical,
         'chordmap': self.chordmap.name,
     }
     return data
Beispiel #6
0
 def to_picklable_dict(self):
     """
     Produces a picklable representation of model as a dict.
     You can't just pickle the object directly because some of the 
     NLTK classes can't be pickled. You can pickle this dict and 
     reconstruct the model using NgramModel.from_picklable_dict(dict).
     
     """
     from jazzparser.utils.nltk.storage import object_to_dict
     return {
         'key_transition_dist' : object_to_dict(self.key_transition_dist),
         'chord_transition_dist' : object_to_dict(self.chord_transition_dist),
         'emission_dist' : object_to_dict(self.emission_dist),
         'chord_dist' : object_to_dict(self.chord_dist),
         'history' : self.history,
         'description' : self.description,
         'chord_set' : self.chord_set,
     }
Beispiel #7
0
 def to_picklable_dict(self):
     """
     Produces a picklable representation of model as a dict.
     You can't just pickle the object directly because some of the 
     NLTK classes can't be pickled. You can pickle this dict and 
     reconstruct the model using NgramModel.from_picklable_dict(dict).
     
     """
     from jazzparser.utils.nltk.storage import object_to_dict
     return {
         'key_transition_dist': object_to_dict(self.key_transition_dist),
         'chord_transition_dist':
         object_to_dict(self.chord_transition_dist),
         'emission_dist': object_to_dict(self.emission_dist),
         'chord_dist': object_to_dict(self.chord_dist),
         'history': self.history,
         'description': self.description,
         'chord_set': self.chord_set,
     }
Beispiel #8
0
 def to_picklable_dict(self):
     """ Produces a picklable representation of model as a dict. """
     from jazzparser.utils.nltk.storage import object_to_dict
     
     if self.backoff_model is not None:
         backoff_model = self.backoff_model.to_picklable_dict()
     else:
         backoff_model = None
     
     return {
         'order' : self.order, 
         'root_transition_counts' : object_to_dict(self.root_transition_counts),
         'schema_transition_counts' : object_to_dict(self.schema_transition_counts),
         'emission_counts' : object_to_dict(self.emission_counts),
         'estimator' : self._estimator,
         'backoff_model' : backoff_model,
         'chord_vocab' : self.chord_vocab,
         'schemata' : self.schemata, 
         'history' : self.history,
     }
Beispiel #9
0
 def to_picklable_dict(self):
     from jazzparser.utils.nltk.storage import object_to_dict
     
     if self.backoff_model is not None:
         backoff_model = self.backoff_model.to_picklable_dict()
     else:
         backoff_model = None
     
     return {
         'order' : self.order, 
         'point_transition_counts' : object_to_dict(self.point_transition_counts),
         'fn_transition_counts' : object_to_dict(self.fn_transition_counts),
         'type_emission_counts' : object_to_dict(self.type_emission_counts),
         'subst_emission_counts' : object_to_dict(self.subst_emission_counts),
         'estimator' : self._estimator,
         'backoff_model' : backoff_model,
         'chord_map' : self.chord_map.name,
         'vector_dom' : self.vector_dom, 
         'point_dom' : self.point_dom,
         'history' : self.history,
     }
Beispiel #10
0
    def to_picklable_dict(self):
        from jazzparser.utils.nltk.storage import object_to_dict

        if self.backoff_model is not None:
            backoff_model = self.backoff_model.to_picklable_dict()
        else:
            backoff_model = None

        return {
            'order': self.order,
            'point_transition_counts':
            object_to_dict(self.point_transition_counts),
            'fn_transition_counts': object_to_dict(self.fn_transition_counts),
            'type_emission_counts': object_to_dict(self.type_emission_counts),
            'subst_emission_counts':
            object_to_dict(self.subst_emission_counts),
            'estimator': self._estimator,
            'backoff_model': backoff_model,
            'chord_map': self.chord_map.name,
            'vector_dom': self.vector_dom,
            'point_dom': self.point_dom,
            'history': self.history,
        }
Beispiel #11
0
 def to_picklable_dict(self):
     """
     Produces a picklable representation of model as a dict.
     You can't just pickle the object directly because some of the 
     NLTK classes can't be pickled. You can pickle this dict and 
     reconstruct the model using NgramModel.from_picklable_dict(dict).
     
     """
     from jazzparser.utils.nltk.storage import object_to_dict
     return {
         'schema_transition_dist' : object_to_dict(self.schema_transition_dist),
         'root_transition_dist' : object_to_dict(self.root_transition_dist),
         'emission_dist' : object_to_dict(self.emission_dist),
         'emission_number_dist' : object_to_dict(self.emission_number_dist),
         'initial_state_dist' : object_to_dict(self.initial_state_dist),
         'schemata' : self.schemata,
         'history' : self.history,
         'description' : self.description,
         'chord_class_mapping' : self.chord_class_mapping,
         'chord_classes' : self.chord_classes,
         'illegal_transitions' : self.illegal_transitions,
         'fixed_root_transitions' : self.fixed_root_transitions,
     }
Beispiel #12
0
 def _object_to_dict(obj):
     if type(obj) == MutableProbDist:
         # Convert to a normal dict prob dist
         obj = prob_dist_to_dictionary_prob_dist(obj)
     return object_to_dict(obj)