Exemplo n.º 1
0
    def __init__(self, config):
        # parse config file
        parser = SafeConfigParser()
        parser.read(config)

	self.Aligner_object = Aligner_IBM1(parser)
	self.Extractor_object = Extractor_Moses(parser)
	self.Annotator_object = Annotator_onlinecache(parser)
        self.logger = logging.getLogger('translation_log.updater')
    def __init__(self, config):
        # parse config file
        parser = SafeConfigParser()
        parser.read(config)

	self.Aligner_object = Aligner_GIZA(parser)
	self.Extractor_object = Extractor_Moses(parser)
	self.Annotator_object = Annotator_onlinecache(parser)
        self.logger = logging.getLogger('translation_log.updater')
Exemplo n.º 3
0
class UpdaterProc(object):
    def __init__(self, config):
        # parse config file
        parser = SafeConfigParser()
        parser.read(config)

        self.Aligner_object = Aligner_onlineGIZA(parser)
        self.Extractor_object = Extractor_Moses(parser)
        self.Annotator_object = Annotator_onlinecache(parser)
        self.logger = logging.getLogger('translation_log.updater')

    def update(self, source="", target=""):
        # get alignment information for the (source,correction)
        self.log("ALIGNER_INPUT source: " + str(source))
        self.log("ALIGNER_INPUT correction: " + str(target))
        aligner_output = self.Aligner_object.align(source=source,
                                                   correction=target)
        self.log("ALIGNER_OUTPUT: " + str(aligner_output))

        # get phrase pairs form the alignment information
        bias, new, full = self.Extractor_object.extract_phrases(
            source, target, aligner_output)
        self.log("BIAS: " + str(bias))
        self.log("NEW: " + str(new))
        self.log("FULL: " + str(full))

        self.Annotator_object.cbtm_update(new=new, bias=bias, full=full)
        self.Annotator_object.cblm_update(target)

        # read and annotate the next sentence
        dummy_source = ""
        annotated_source = self.Annotator_object.annotate(dummy_source)

        return annotated_source

    def reset(self):
        annotated_source = ''
        annotated_source = annotated_source + '<dlt cblm-command="clear"/>'
        annotated_source = annotated_source + '<dlt cbtm-command="clear"/>'
        return annotated_source

    def log(self, message):
        self.logger.info(message)
class UpdaterProc(object):
    def __init__(self, config):
        # parse config file
        parser = SafeConfigParser()
        parser.read(config)

	self.Aligner_object = Aligner_GIZA(parser)
	self.Extractor_object = Extractor_Moses(parser)
	self.Annotator_object = Annotator_onlinecache(parser)
        self.logger = logging.getLogger('translation_log.updater')

    def update(self, source="", target=""):
        # get alignment information for the (source,correction)
        self.log("ALIGNER_INPUT source: "+str(source))
        self.log("ALIGNER_INPUT correction: "+str(target))
        aligner_output = self.Aligner_object.align(source=source,correction=target)
        self.log("ALIGNER_OUTPUT: "+str(aligner_output))

        # get phrase pairs form the alignment information
        bias, new, full = self.Extractor_object.extract_phrases(source,target,aligner_output)
        self.log("BIAS: "+str(bias))
        self.log("NEW: "+str(new))
        self.log("FULL: "+str(full))

        self.Annotator_object.cbtm_update(new=new, bias=bias, full=full)
        self.Annotator_object.cblm_update(target)

        # read and annotate the next sentence
        dummy_source = ""
        annotated_source = self.Annotator_object.annotate(dummy_source)

	return annotated_source

    def reset(self):
        annotated_source = ''
        annotated_source = annotated_source + '<dlt cblm-command="clear"/>'
        annotated_source = annotated_source + '<dlt cbtm-command="clear"/>'
	return annotated_source

    def log(self, message):
        self.logger.info(message)
Exemplo n.º 5
0
        elif aligner_type == "onlineGIZA" :
                Aligner_object = Aligner_onlineGIZA(parser)
        elif aligner_type == "Constrained_Search" :
        	Aligner_object = Aligner_Constrained_Search(parser)
		if not decoder_type == "Moses":
                	logging.info("This alignment tool requires Moses as decoder")
                	sys.exit(1)
        elif aligner_type == "Dummy" :
        	Aligner_object = Aligner_Dummy(parser)
		
        else:
                logging.info("This alignment tool  is UNKNOWN")
                sys.exit(1)

        if extractor_type == "Moses" :
                Extractor_object = Extractor_Moses(parser)
        elif extractor_type == "Constrained_Search" :
                Extractor_object = Extractor_Constrained_Search(parser)
        elif extractor_type == "Dummy" :
                Extractor_object = Extractor_Dummy(parser)
        else:
                logging.info("This extractor tool  is UNKNOWN")
                sys.exit(1)

        if annotator_type == "onlinexml" :
        	Annotator_object = Annotator_onlinexml(parser)
        elif annotator_type == "onlinecache" :
        	Annotator_object = Annotator_onlinecache(parser)
        else:
                logging.info("This annotation tool  is UNKNOWN:")
                sys.exit(1)
Exemplo n.º 6
0
    elif aligner_type == "onlineGIZA":
        Aligner_object = Aligner_onlineGIZA(parser)
    elif aligner_type == "Constrained_Search":
        Aligner_object = Aligner_Constrained_Search(parser)
        if not decoder_type == "Moses":
            logging.info("This alignment tool requires Moses as decoder")
            sys.exit(1)
    elif aligner_type == "Dummy":
        Aligner_object = Aligner_Dummy(parser)

    else:
        logging.info("This alignment tool  is UNKNOWN")
        sys.exit(1)

    if extractor_type == "Moses":
        Extractor_object = Extractor_Moses(parser)
    elif extractor_type == "Constrained_Search":
        Extractor_object = Extractor_Constrained_Search(parser)
    elif extractor_type == "Dummy":
        Extractor_object = Extractor_Dummy(parser)
    else:
        logging.info("This extractor tool  is UNKNOWN")
        sys.exit(1)

    if annotator_type == "onlinexml":
        Annotator_object = Annotator_onlinexml(parser)
    elif annotator_type == "onlinecache":
        Annotator_object = Annotator_onlinecache(parser)
    else:
        logging.info("This annotation tool  is UNKNOWN:")
        sys.exit(1)