diff options
author | Michael Denkowski <mdenkows@cs.cmu.edu> | 2013-09-23 08:21:58 -0700 |
---|---|---|
committer | Michael Denkowski <mdenkows@cs.cmu.edu> | 2013-09-23 08:21:58 -0700 |
commit | ae3cfd5700d20d30a06f5c27ea1c5e39a458c783 (patch) | |
tree | f7070a910891e8d9861b182cc286b2c0e66e5172 /python/cdec/sa/extractor.py | |
parent | 60013ff62cee092db5f85eb5ecb2ea6119f2da6d (diff) |
One extractor, multiple online contexts.
Diffstat (limited to 'python/cdec/sa/extractor.py')
-rw-r--r-- | python/cdec/sa/extractor.py | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/python/cdec/sa/extractor.py b/python/cdec/sa/extractor.py index acc13cbc..23534712 100644 --- a/python/cdec/sa/extractor.py +++ b/python/cdec/sa/extractor.py @@ -84,23 +84,17 @@ class GrammarExtractor: for fn in cdec.sa._SA_CONFIGURE: fn(config) - def grammar(self, sentence): + def grammar(self, sentence, ctx_name=None): if isinstance(sentence, unicode): sentence = sentence.encode('utf8') words = tuple(chain(('<s>',), sentence.split(), ('</s>',))) meta = cdec.sa.annotate(words) cnet = cdec.sa.make_lattice(words) - return self.factory.input(cnet, meta) + return self.factory.input(cnet, meta, ctx_name) # Add training instance to data - def add_instance(self, sentence, reference, alignment): + def add_instance(self, sentence, reference, alignment, ctx_name=None): f_words = cdec.sa.encode_words(sentence.split()) e_words = cdec.sa.encode_words(reference.split()) al = sorted(tuple(int(i) for i in pair.split('-')) for pair in alignment.split()) - self.factory.add_instance(f_words, e_words, al) - - # Debugging - def dump_online_stats(self): - self.factory.dump_online_stats() - def dump_online_rules(self): - self.factory.dump_online_rules()
\ No newline at end of file + self.factory.add_instance(f_words, e_words, al, ctx_name) |