summaryrefslogtreecommitdiff
path: root/python/pkg/cdec
diff options
context:
space:
mode:
authorVictor Chahuneau <vchahune@cs.cmu.edu>2012-09-06 11:17:00 +0100
committerVictor Chahuneau <vchahune@cs.cmu.edu>2012-09-06 11:17:00 +0100
commitaf8b109ad49222bc56527e5e75b8267134233bd4 (patch)
treeced5356aa5b8932686b02ecba864397bf8c0ccb9 /python/pkg/cdec
parentb674c40505f48bfc3aafe4df9e116321c89342fa (diff)
[cdec.sa] Make list of word ids <-> sentence string mapping easy
Diffstat (limited to 'python/pkg/cdec')
-rw-r--r--python/pkg/cdec/sa/__init__.py2
-rw-r--r--python/pkg/cdec/sa/extractor.py5
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)