From b6474b5cdbf870725371b32670c9dc28671e394c Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Thu, 9 Aug 2012 01:36:36 -0400 Subject: fixes for new word api --- decoder/ff_charset.cc | 6 +++--- decoder/ff_csplit.cc | 2 +- decoder/ff_wordalign.cc | 2 +- decoder/hg_intersect.cc | 2 +- decoder/hg_io.cc | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) (limited to 'decoder') diff --git a/decoder/ff_charset.cc b/decoder/ff_charset.cc index 33afc1a7..472de82b 100644 --- a/decoder/ff_charset.cc +++ b/decoder/ff_charset.cc @@ -7,9 +7,9 @@ using namespace std; NonLatinCount::NonLatinCount(const string& param) : FeatureFunction(), fid_(FD::Convert("NonLatinCount")) {} -bool ContainsNonLatin(const char* word) { - int cur = 0; - while(word[cur]) { +bool ContainsNonLatin(const string& word) { + unsigned cur = 0; + while(cur < word.size()) { const int size = UTF8Len(word[cur]); if (size > 1) return true; cur += size; diff --git a/decoder/ff_csplit.cc b/decoder/ff_csplit.cc index c9ed996c..252dbf8c 100644 --- a/decoder/ff_csplit.cc +++ b/decoder/ff_csplit.cc @@ -88,7 +88,7 @@ void BasicCSplitFeaturesImpl::TraversalFeaturesImpl( features->set_value(letters_sq_, (edge.j_ - edge.i_) * (edge.j_ - edge.i_)); features->set_value(letters_sqrt_, sqrt(edge.j_ - edge.i_)); const WordID word = edge.rule_->e_[1]; - const char* sword = TD::Convert(word); + const char* sword = TD::Convert(word).c_str(); const int len = strlen(sword); int cur = 0; int chars = 0; diff --git a/decoder/ff_wordalign.cc b/decoder/ff_wordalign.cc index decdf9bc..1491819d 100644 --- a/decoder/ff_wordalign.cc +++ b/decoder/ff_wordalign.cc @@ -549,7 +549,7 @@ void IdentityCycleDetector::TraversalFeaturesImpl(const SentenceMetadata& smeta, static map big_enough; map::iterator it = big_enough_.find(word); if (it == big_enough_.end()) { - out_is_identity = big_enough_[word] = strlen(TD::Convert(word)) >= length_min_; + out_is_identity = big_enough_[word] = TD::Convert(word).size() >= length_min_; } else { out_is_identity = it->second; } diff --git a/decoder/hg_intersect.cc b/decoder/hg_intersect.cc index 6e3bfee6..e9a91061 100644 --- a/decoder/hg_intersect.cc +++ b/decoder/hg_intersect.cc @@ -101,7 +101,7 @@ bool HG::Intersect(const Lattice& target, Hypergraph* hg) { // grammar, create the labels here const string kSEP = "_"; for (unsigned i = 0; i < nnodes; ++i) { - const char* pstr = "CAT"; + string pstr = "CAT"; if (hg->nodes_[i].cat_ < 0) pstr = TD::Convert(-hg->nodes_[i].cat_); cats[i] = TD::Convert(pstr + kSEP + lexical_cast(i)) * -1; diff --git a/decoder/hg_io.cc b/decoder/hg_io.cc index 8bd40387..3a68a429 100644 --- a/decoder/hg_io.cc +++ b/decoder/hg_io.cc @@ -600,7 +600,7 @@ void HypergraphIO::WriteAsCFG(const Hypergraph& hg) { // grammar, create the labels here const string kSEP = "_"; for (int i = 0; i < hg.nodes_.size(); ++i) { - const char* pstr = "CAT"; + string pstr = "CAT"; if (hg.nodes_[i].cat_ < 0) pstr = TD::Convert(-hg.nodes_[i].cat_); cats[i] = TD::Convert(pstr + kSEP + boost::lexical_cast(i)) * -1; -- cgit v1.2.3