from zope.interface import Interface, Attribute class TokenizerError(Exception): pass class MyInterface(Interface): def setDict(self, attr, key, value): dict=self.get(attr) dict[key]=value try: self.set(attr,dict) except: self.setTaggedValue(attr,dict) class TokenizerPlugin(MyInterface): """ A python interface to a tokenizer of some sort """ running = Attribute(""" The tokenizer has been started """) displayName = Attribute(""" The name of the tokenizer """) preferences = Attribute(""" A dictionary of config values and their types """) values = Attribute(""" A dictionary of configurable options and their values """) def __init__(self): for p in self.preferences: p = Attribute(""" An on-the-fly storage spot for %s" % p""") def start(self): """ Start the tokenizer """ def stop(self): """ Stop the tokenizer """ def tokenize(self, text): """ Split the text """ def version(self): """ Return the version string of the tokenizer """