From c3619d27a6e64d2f13fc16d8959ad7ea70486eb8 Mon Sep 17 00:00:00 2001 From: Victor Chahuneau Date: Thu, 14 Jun 2012 09:27:53 -0400 Subject: Detect boost location before building the python module --- python/src/_cdec.pyx | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) (limited to 'python/src/_cdec.pyx') diff --git a/python/src/_cdec.pyx b/python/src/_cdec.pyx index 45320c46..664724dd 100644 --- a/python/src/_cdec.pyx +++ b/python/src/_cdec.pyx @@ -41,28 +41,14 @@ cdef class Decoder: def __cinit__(self, char* config): decoder.register_feature_functions() - cdef istringstream* config_stream = new istringstream(config) # ConfigStream(kwargs) - #cdef ReadFile* config_file = new ReadFile(string(config)) - #cdef istream* config_stream = config_file.stream() + cdef istringstream* config_stream = new istringstream(config) self.dec = new decoder.Decoder(config_stream) del config_stream - #del config_file self.weights = Weights(self) def __dealloc__(self): del self.dec - @classmethod - def fromconfig(cls, ini): - cdef dict config = {} - with open(ini) as fp: - for line in fp: - line = line.strip() - if not line or line.startswith('#'): continue - param, value = line.split('=') - config[param.strip()] = value.strip() - return cls(**config) - def read_weights(self, cfg): with open(cfg) as fp: for line in fp: @@ -73,10 +59,9 @@ cdef class Decoder: def translate(self, unicode sentence, grammar=None): if grammar: self.dec.SetSentenceGrammarFromString(string( grammar)) - #sgml = '%s' % (grammar, sentence.encode('utf8')) - sgml = sentence.strip().encode('utf8') + inp = sentence.strip().encode('utf8') cdef decoder.BasicObserver observer = decoder.BasicObserver() - self.dec.Decode(string(sgml), &observer) + self.dec.Decode(string(inp), &observer) if observer.hypergraph == NULL: raise ParseFailed() cdef Hypergraph hg = Hypergraph() @@ -169,12 +154,3 @@ cdef class Lattice: del self.lattice # TODO: wrap SparseVector - -""" -def params_str(params): - return '\n'.join('%s=%s' % (param, value) for param, value in params.iteritems()) - -cdef istringstream* ConfigStream(dict params): - ini = params_str(params) - return new istringstream( ini) -""" -- cgit v1.2.3