diff options
author | Chris Dyer <cdyer@cs.cmu.edu> | 2012-07-28 12:11:44 -0400 |
---|---|---|
committer | Chris Dyer <cdyer@cs.cmu.edu> | 2012-07-28 12:11:44 -0400 |
commit | 306e0ba4754c6c4f460536cfe8c3f118dc1cc175 (patch) | |
tree | ad5ea3b0a5370ac613d1bad715fe0f5ab8c91c11 /python/src/hypergraph.pxi | |
parent | 934e55dc12c3f374684bc6a0797e6f85c7abb85a (diff) | |
parent | ee5e376e263d9aeabdeee6968b4457f53d3fc772 (diff) |
Merge branch 'master' of github.com:redpony/cdec
Diffstat (limited to 'python/src/hypergraph.pxi')
-rw-r--r-- | python/src/hypergraph.pxi | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/python/src/hypergraph.pxi b/python/src/hypergraph.pxi index 86751cc9..b210f440 100644 --- a/python/src/hypergraph.pxi +++ b/python/src/hypergraph.pxi @@ -21,7 +21,7 @@ cdef class Hypergraph: return (f_tree, e_tree) def viterbi_features(self): - cdef SparseVector fmap = SparseVector() + cdef SparseVector fmap = SparseVector.__new__(SparseVector) fmap.vector = new FastSparseVector[weight_t](hypergraph.ViterbiFeatures(self.hg[0])) return fmap @@ -67,7 +67,7 @@ cdef class Hypergraph: for k in range(size): derivation = derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) if not derivation: break - fmap = SparseVector() + fmap = SparseVector.__new__(SparseVector) fmap.vector = new FastSparseVector[weight_t](derivation._yield) yield fmap finally: @@ -130,12 +130,12 @@ cdef class Hypergraph: return self.hg.NumberOfPaths() def inside_outside(self): - cdef FastSparseVector[LogVal[double]]* result = new FastSparseVector[LogVal[double]]() - cdef LogVal[double] z = hypergraph.InsideOutside(self.hg[0], result) + cdef FastSparseVector[prob_t]* result = new FastSparseVector[prob_t]() + cdef prob_t z = hypergraph.InsideOutside(self.hg[0], result) result[0] /= z - cdef SparseVector vector = SparseVector() + cdef SparseVector vector = SparseVector.__new__(SparseVector) vector.vector = new FastSparseVector[double]() - cdef FastSparseVector[LogVal[double]].const_iterator* it = new FastSparseVector[LogVal[double]].const_iterator(result[0], False) + cdef FastSparseVector[prob_t].const_iterator* it = new FastSparseVector[prob_t].const_iterator(result[0], False) cdef unsigned i for i in range(result.size()): vector.vector.set_value(it[0].ptr().first, log(it[0].ptr().second)) @@ -147,12 +147,12 @@ cdef class Hypergraph: cdef class HypergraphEdge: cdef hypergraph.Hypergraph* hg cdef hypergraph.HypergraphEdge* edge - cdef public BaseTRule trule + cdef public TRule trule cdef init(self, hypergraph.Hypergraph* hg, unsigned i): self.hg = hg self.edge = &hg.edges_[i] - self.trule = BaseTRule() + self.trule = TRule.__new__(TRule) self.trule.rule = new shared_ptr[grammar.TRule](self.edge.rule_) return self @@ -175,7 +175,7 @@ cdef class HypergraphEdge: property feature_values: def __get__(self): - cdef SparseVector vector = SparseVector() + cdef SparseVector vector = SparseVector.__new__(SparseVector) vector.vector = new FastSparseVector[double](self.edge.feature_values_) return vector |