diff options
author | Victor Chahuneau <vchahune@cs.cmu.edu> | 2012-09-06 11:17:00 +0100 |
---|---|---|
committer | Victor Chahuneau <vchahune@cs.cmu.edu> | 2012-09-06 11:17:00 +0100 |
commit | 5cffab2b8e200aa47a382f19327cc021ec64723b (patch) | |
tree | 9d6b988729aaa57a29b68283d465c9373abb8759 /python/pkg/cdec/sa | |
parent | 93366dab4afd7d6a28bc6d65f1a721b8ddd98f2a (diff) |
[cdec.sa] Make list of word ids <-> sentence string mapping easy
Diffstat (limited to 'python/pkg/cdec/sa')
-rw-r--r-- | python/pkg/cdec/sa/__init__.py | 2 | ||||
-rw-r--r-- | python/pkg/cdec/sa/extractor.py | 5 |
2 files changed, 3 insertions, 4 deletions
diff --git a/python/pkg/cdec/sa/__init__.py b/python/pkg/cdec/sa/__init__.py index cc532fb9..d4b94484 100644 --- a/python/pkg/cdec/sa/__init__.py +++ b/python/pkg/cdec/sa/__init__.py @@ -1,4 +1,4 @@ -from cdec.sa._sa import sym_fromstring,\ +from cdec.sa._sa import make_lattice, decode_lattice, decode_sentence,\ SuffixArray, DataArray, LCP, Precomputation, Alignment, BiLex,\ HieroCachingRuleFactory, Sampler, Scorer from cdec.sa.extractor import GrammarExtractor diff --git a/python/pkg/cdec/sa/extractor.py b/python/pkg/cdec/sa/extractor.py index 940544fb..94392c30 100644 --- a/python/pkg/cdec/sa/extractor.py +++ b/python/pkg/cdec/sa/extractor.py @@ -75,7 +75,6 @@ class GrammarExtractor: def grammar(self, sentence): if isinstance(sentence, unicode): sentence = sentence.encode('utf8') - cnet = chain(('<s>',), sentence.split(), ('</s>',)) - cnet = (cdec.sa.sym_fromstring(word, terminal=True) for word in cnet) - cnet = tuple(((word, None, 1), ) for word in cnet) + words = chain(('<s>',), sentence.split(), ('</s>',)) + cnet = cdec.sa.make_lattice(words) return self.factory.input(cnet) |