diff options
author | Chris Dyer <cdyer@cab.ark.cs.cmu.edu> | 2012-08-09 01:36:36 -0400 |
---|---|---|
committer | Chris Dyer <cdyer@cab.ark.cs.cmu.edu> | 2012-08-09 01:36:36 -0400 |
commit | 0ec6eab158320dc87054057a5a6aaa3536d2fc91 (patch) | |
tree | 7bfebbbeda0e770e0e20b0a28049dd707649f04f | |
parent | 8ab7731dc55c55272300eafbde2c085b31f886d7 (diff) |
fixes for new word api
-rw-r--r-- | decoder/ff_charset.cc | 6 | ||||
-rw-r--r-- | decoder/ff_csplit.cc | 2 | ||||
-rw-r--r-- | decoder/ff_wordalign.cc | 2 | ||||
-rw-r--r-- | decoder/hg_intersect.cc | 2 | ||||
-rw-r--r-- | decoder/hg_io.cc | 2 | ||||
-rw-r--r-- | gi/pf/base_distributions.cc | 2 | ||||
-rw-r--r-- | gi/pf/cfg_wfst_composer.cc | 2 | ||||
-rw-r--r-- | mteval/ns.cc | 2 |
8 files changed, 10 insertions, 10 deletions
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<WordID, bool> big_enough; map<WordID,bool>::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<string>(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<string>(i)) * -1; diff --git a/gi/pf/base_distributions.cc b/gi/pf/base_distributions.cc index d9761005..57e0bbe1 100644 --- a/gi/pf/base_distributions.cc +++ b/gi/pf/base_distributions.cc @@ -37,7 +37,7 @@ TableLookupBase::TableLookupBase(const string& fname) { } else if (cc == 1) { x.e_.push_back(cur); } else if (cc == 2) { - table[x].logeq(atof(TD::Convert(cur))); + table[x].logeq(atof(TD::Convert(cur).c_str())); ++cc; } else { if (flag) cerr << endl; diff --git a/gi/pf/cfg_wfst_composer.cc b/gi/pf/cfg_wfst_composer.cc index 19c0875d..21d5ec5b 100644 --- a/gi/pf/cfg_wfst_composer.cc +++ b/gi/pf/cfg_wfst_composer.cc @@ -410,7 +410,7 @@ class CFG_WFSTComposerImpl { std::cerr << "TERMINAL SYMBOL: " << TD::Convert(git->first) << endl; abort(); } - std::vector<std::pair<const WFSTNode*, TRulePtr> > extensions = r->ExtendInput(atoi(TD::Convert(git->first))); + std::vector<std::pair<const WFSTNode*, TRulePtr> > extensions = r->ExtendInput(atoi(TD::Convert(git->first).c_str())); for (unsigned nsi = 0; nsi < extensions.size(); ++nsi) { const WFSTNode* next_r = extensions[nsi].first; const EGrammarNode* next_dot = &git->second; diff --git a/mteval/ns.cc b/mteval/ns.cc index 33952da7..3af7cc63 100644 --- a/mteval/ns.cc +++ b/mteval/ns.cc @@ -252,7 +252,7 @@ EvaluationMetric* EvaluationMetric::Instance(const string& imetric_id) { } else if (metric_id == "TER") { m = new TERMetric; } else if (metric_id == "METEOR") { - m = new ExternalMetric("METEOR", "java -Xmx1536m -jar /Users/cdyer/software/meteor/meteor-1.3.jar - - -mira -lower -t tune -l en"); + m = new ExternalMetric("METEOR", "java -Xmx1536m -jar /cab0/tools/meteor-1.3/meteor-1.3.jar - - -mira -lower -t tune -l en"); } else if (metric_id.find("COMB:") == 0) { m = new CombinationMetric(metric_id); } else if (metric_id == "CER") { |