summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Denkowski <mdenkows@cs.cmu.edu>2013-08-21 14:23:04 -0700
committerMichael Denkowski <mdenkows@cs.cmu.edu>2013-08-21 14:23:04 -0700
commit9d5071692ceab8d09c2bfdba24f6b927ec84b7f9 (patch)
treeb3f58ff9bf9600687abd0473ee35bbde39508a91
parentcd666f441d91109d402e4f3993a9ec3c45306dd0 (diff)
Add instances to grammar extractor
-rwxr-xr-xrealtime/realtime.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/realtime/realtime.py b/realtime/realtime.py
index a6b3ed52..c42b52ab 100755
--- a/realtime/realtime.py
+++ b/realtime/realtime.py
@@ -30,11 +30,12 @@ class RealtimeDecoder:
# Grammar extractor
sa_config = os.path.join(configdir, 'sa.ini')
- self.extractor = cdec.sa.GrammarExtractor(sa_config)
+ self.extractor = cdec.sa.GrammarExtractor(sa_config, online=True)
# Decoder
decoder_config = os.path.join(configdir, 'cdec.ini')
decoder_weights = os.path.join(configdir, 'weights.final')
+ #TODO: run MIRA instead
self.decoder = CdecDecoder(decoder_config, decoder_weights)
def close(self):
@@ -61,7 +62,11 @@ class RealtimeDecoder:
return hyp
def learn(self, source, target):
- pass
+ alignment = self.aligner.align('{} ||| {}'.format(source, target))
+ logging.info('Adding instance: {} ||| {} ||| {}'.format(source, target, alignment))
+ self.extractor.add_instance(source, target, alignment)
+ # TODO: Add to LM
+ # TODO: MIRA update
def main():