diff options
author | redpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-10-21 01:27:58 +0000 |
---|---|---|
committer | redpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-10-21 01:27:58 +0000 |
commit | ed364db2699dec02f5bd18b9c15147e0a02efee1 (patch) | |
tree | 80db871258b3d769da3e06cb299857832315c60c /decoder/ff_wordalign.cc | |
parent | eb43ccf1e1a7d59a0f672956230644ebb7a5cbf1 (diff) |
bit more alignment stuff
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@686 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder/ff_wordalign.cc')
-rw-r--r-- | decoder/ff_wordalign.cc | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/decoder/ff_wordalign.cc b/decoder/ff_wordalign.cc index b4981961..f8b8060c 100644 --- a/decoder/ff_wordalign.cc +++ b/decoder/ff_wordalign.cc @@ -574,3 +574,39 @@ void BlunsomSynchronousParseHack::TraversalFeaturesImpl(const SentenceMetadata& SetStateMask(it->second, it->second + yield.size(), state); } +InputIdentity::InputIdentity(const std::string& param) {} + +void InputIdentity::FireFeature(WordID src, + SparseVector<double>* features) const { + int& fid = fmap_[src]; + if (!fid) { + static map<WordID, WordID> escape; + if (escape.empty()) { + escape[TD::Convert("=")] = TD::Convert("__EQ"); + escape[TD::Convert(";")] = TD::Convert("__SC"); + escape[TD::Convert(",")] = TD::Convert("__CO"); + } + if (escape.count(src)) src = escape[src]; + ostringstream os; + os << "S:" << TD::Convert(src); + fid = FD::Convert(os.str()); + } + features->set_value(fid, 1.0); +} + +void InputIdentity::TraversalFeaturesImpl(const SentenceMetadata& smeta, + const Hypergraph::Edge& edge, + const std::vector<const void*>& ant_contexts, + SparseVector<double>* features, + SparseVector<double>* estimated_features, + void* context) const { + const vector<WordID>& fw = edge.rule_->f_; + for (int i = 0; i < fw.size(); ++i) { + const WordID& f = fw[i]; + if (f > 0) FireFeature(f, features); + } +} + + + + |