Пример #1
0
   def remove_from_database(self, glyphs):
      """**remove_from_database** (ImageList *glyphs*)

Removes the given glyphs from the classifier training data.  Ignores silently
if a given glyph is not in the training data.
"""
      glyphs = util.make_sequence(glyphs)
      for glyph in glyphs:
         if glyph in self.database:
            self.database.remove(glyph)
Пример #2
0
    def remove_from_database(self, glyphs):
        """**remove_from_database** (ImageList *glyphs*)

Removes the given glyphs from the classifier training data.  Ignores silently
if a given glyph is not in the training data.
"""
        glyphs = util.make_sequence(glyphs)
        for glyph in glyphs:
            if glyph in self.database:
                self.database.remove(glyph)
Пример #3
0
   def add_to_database(self, glyphs):
      """**add_to_database** (ImageList *glyphs*)

Adds the given glyph (or list of glyphs) to the classifier training data.  Will not add duplicates
to the training data.  Unlike classify_glyph_manual_, no grouping support is performed.
"""
      glyphs = util.make_sequence(glyphs)
      new_glyphs = []
      for glyph in glyphs:
         if (glyph.classification_state == core.MANUAL and
             not glyph in self.database):
            self.generate_features(glyph)
            new_glyphs.append(glyph)
      self.database.extend(new_glyphs)
Пример #4
0
    def add_to_database(self, glyphs):
        """**add_to_database** (ImageList *glyphs*)

Adds the given glyph (or list of glyphs) to the classifier training data.  Will not add duplicates
to the training data.  Unlike classify_glyph_manual_, no grouping support is performed.
"""
        glyphs = util.make_sequence(glyphs)
        new_glyphs = []
        for glyph in glyphs:
            if (glyph.classification_state == core.MANUAL
                    and not glyph in self.database):
                self.generate_features(glyph)
                new_glyphs.append(glyph)
        self.database.extend(new_glyphs)
Пример #5
0
 def get_feature_functions(cls, features='all'):
     from gamera import plugin
     global all_features
     if all_features is None:
         all_features = plugin.methods_flat_category('Features', ONEBIT)
         all_features.sort()
     if features == 'all' or features is None:
         functions = all_features
         return functions, cls._get_feature_vector_size(functions)
     features = util.make_sequence(features)
     all_strings = True
     for feature in features:
         if not util.is_string_or_unicode(feature):
             all_strings = False
             break
     if not all_strings:
         import plugin
         all_functions = False
         if (type(features) == tuple and len(features) == 2
                 and type(features[0]) == list
                 and type(features[1]) == int):
             all_functions = True
             for feature in features[0]:
                 if not (type(feature) == tuple
                         and util.is_string_or_unicode(feature[0])
                         and issubclass(feature[1], plugin.PluginFunction)):
                     all_functions = False
                     break
         if not all_functions:
             raise ValueError(
                 "'%s' is not a valid way to specify a list of features." %
                 str(features))
         else:
             return features
     else:
         features.sort()
         functions = []
         for feature in features:
             found = 0
             for i in all_features:
                 if feature == i[0]:
                     functions.append(i)
                     found = 1
                     break
             if not found:
                 raise ValueError("'%s' is not a known feature function." %
                                  feature)
         functions.sort()
         return functions, cls._get_feature_vector_size(functions)
Пример #6
0
 def __init__(self, list=[], name="Arguments", function=None, title=None):
    self.list = util.make_sequence(list)
    self.valid = 1
    self.name = name
    self.function = function
    self.title = title
Пример #7
0
 def merge_glyphs(self, glyphs):
    glyphs = util.make_sequence(glyphs)
    self.generate_features_on_glyphs(glyphs)
    self.database.extend(glyphs)
Пример #8
0
 def set_glyphs(self, glyphs):
    glyphs = util.make_sequence(glyphs)
    self.clear_glyphs()
    self.generate_features_on_glyphs(glyphs)
    self.database.extend(glyphs)
Пример #9
0
 def merge_glyphs(self, glyphs):
     glyphs = util.make_sequence(glyphs)
     self.generate_features_on_glyphs(glyphs)
     self.database.extend(glyphs)
Пример #10
0
 def set_glyphs(self, glyphs):
     glyphs = util.make_sequence(glyphs)
     self.clear_glyphs()
     self.generate_features_on_glyphs(glyphs)
     self.database.extend(glyphs)
Пример #11
0
 def __init__(self, list=[], name="Arguments", function=None, title=None):
     self.list = util.make_sequence(list)
     self.valid = 1
     self.name = name
     self.function = function
     self.title = title