From af8b109ad49222bc56527e5e75b8267134233bd4 Mon Sep 17 00:00:00 2001 From: Victor Chahuneau Date: Thu, 6 Sep 2012 11:17:00 +0100 Subject: [cdec.sa] Make list of word ids <-> sentence string mapping easy --- python/pkg/cdec/sa/__init__.py | 2 +- python/pkg/cdec/sa/extractor.py | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'python/pkg/cdec') 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(('',), sentence.split(), ('',)) - cnet = (cdec.sa.sym_fromstring(word, terminal=True) for word in cnet) - cnet = tuple(((word, None, 1), ) for word in cnet) + words = chain(('',), sentence.split(), ('',)) + cnet = cdec.sa.make_lattice(words) return self.factory.input(cnet) -- cgit v1.2.3