class SlinketWrapper(ComponentWrapper): """Wrapper for Slinket. See ComponentWrapper for more details on how component wrappers work. Instance variables parser - an instance of the Slinket parser see ComponentWrapper for other variables.""" def __init__(self, tag, xmldoc, tarsqi_instance): """Calls __init__ of the base class and sets component_name, parser, CREATION_EXTENSION and RETRIEVAL_EXTENSION.""" ComponentWrapper.__init__(self, tag, xmldoc, tarsqi_instance) self.component_name = SLINKET self.parser = Slinket() self.CREATION_EXTENSION = 'sli.i' self.RETRIEVAL_EXTENSION = 'sli.o' def process_fragments(self): """Apply the Slinket parser to each fragment. No arguments and no return value.""" for fragment in self.fragments: base = fragment[0] infile = "%s%s%s.%s" % (self.DIR_DATA, os.sep, base, self.CREATION_EXTENSION) outfile = "%s%s%s.%s" % (self.DIR_DATA, os.sep, base, self.RETRIEVAL_EXTENSION) self.parser.process(infile, outfile)
def __init__(self, tag, xmldoc, tarsqi_instance): """Calls __init__ of the base class and sets component_name, parser, CREATION_EXTENSION and RETRIEVAL_EXTENSION.""" ComponentWrapper.__init__(self, tag, xmldoc, tarsqi_instance) self.component_name = SLINKET self.parser = Slinket() self.CREATION_EXTENSION = 'sli.i' self.RETRIEVAL_EXTENSION = 'sli.o'
def process(self): """Create a TarsqiTree instance for each docelement slice of the TarsqiDocument and hand them to Slinket for processing. Slinket processing will update the tags in the TarsqiDocument when slinks are added.""" self.document.tags.index_events() self.document.tags.index_timexes() for element in self.document.elements(): doctree = tree.create_tarsqi_tree(self.document, element) Slinket().process_doctree(doctree)