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 __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')
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)
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)
Esempio n. 5
0
	annotator_type = parser.get('tools', 'annotator_type')

	input = open(parser.get('data', 'source'), 'r')
	edit = open(parser.get('data', 'reference'), 'r')


	if decoder_type == "Moses" :
        	Decoder_object = Decoder_Moses(parser)
	elif decoder_type == "Deterministic" :
	        Decoder_object = Decoder_Deterministic(parser)
	else:
		logging.info("This decoder is UNKNOWN")
		sys.exit(1)
	
        if aligner_type == "GIZA" :
        	Aligner_object = Aligner_GIZA(parser)
        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" :
Esempio n. 6
0
    extractor_type = parser.get('tools', 'extractor_type')
    annotator_type = parser.get('tools', 'annotator_type')

    input = open(parser.get('data', 'source'), 'r')
    edit = open(parser.get('data', 'reference'), 'r')

    if decoder_type == "Moses":
        Decoder_object = Decoder_Moses(parser)
    elif decoder_type == "Deterministic":
        Decoder_object = Decoder_Deterministic(parser)
    else:
        logging.info("This decoder is UNKNOWN")
        sys.exit(1)

    if aligner_type == "GIZA":
        Aligner_object = Aligner_GIZA(parser)
    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":