diff options
author | Hieu Hoang <hieuhoang@gmail.com> | 2012-10-25 22:11:03 +0400 |
---|---|---|
committer | Hieu Hoang <hieuhoang@gmail.com> | 2012-10-25 22:11:03 +0400 |
commit | d13c761505acbae7a421d70ae968ed125d0c3a2b (patch) | |
tree | f86803d9f2e1dfee1ec99133bbbca25ed9abace1 /scripts/fuzzy-match | |
parent | 9aeb368af20301a80e50f67b5ba2e3a442245205 (diff) |
perl to cpp
Diffstat (limited to 'scripts/fuzzy-match')
-rw-r--r-- | scripts/fuzzy-match/Alignments.h | 2 | ||||
-rw-r--r-- | scripts/fuzzy-match/create_xml.cpp | 66 | ||||
-rwxr-xr-x | scripts/fuzzy-match/create_xml.perl | 2 |
3 files changed, 34 insertions, 36 deletions
diff --git a/scripts/fuzzy-match/Alignments.h b/scripts/fuzzy-match/Alignments.h index bd9c9f764..f54372d27 100644 --- a/scripts/fuzzy-match/Alignments.h +++ b/scripts/fuzzy-match/Alignments.h @@ -9,7 +9,7 @@ class Alignments public: std::vector< std::map<int, int> > m_alignS2T, m_alignT2S; - Alignments(const std::string &str, size_t sourceSize, size_t targetSize); + Alignments(const std::string &align, size_t sourceSize, size_t targetSize); protected: diff --git a/scripts/fuzzy-match/create_xml.cpp b/scripts/fuzzy-match/create_xml.cpp index cb56bc372..eec334528 100644 --- a/scripts/fuzzy-match/create_xml.cpp +++ b/scripts/fuzzy-match/create_xml.cpp @@ -90,10 +90,7 @@ int main(int argc, char **argv) step = 0; break; - } - - } delete input; @@ -204,38 +201,39 @@ CreateXMLRetValues createXML(const string &source, const string &input, const st currently_matching = 1; } // if (start_i < i ) { + } // else if ( !currently_matching - cerr << action << " " << s << " " << i - << "(" << start_s << " " << start_i << ")" - << currently_matching; + cerr << action << " " << s << " " << i + << "(" << start_s << " " << start_i << ")" + << currently_matching; - if ( action != "I" ) { - cerr << " ->"; + if ( action != "I" ) { + cerr << " ->"; - const std::map<int, int> &targets = alignments.m_alignS2T[s]; + const std::map<int, int> &targets = alignments.m_alignS2T[s]; + + std::map<int, int>::const_iterator iter; + for (iter = targets.begin(); iter != targets.end(); ++iter) { + size_t tt = iter->first; + cerr << " " << tt; + } + } + cerr << endl; + + if (action != "I") + s++; + if (action != "D") { + i++; + alignI2S[i] = s; + } + + if (action == "M") { + inputBitmap.push_back(1); + } + else if (action == "I" || action == "S") { + inputBitmap.push_back(0); + } - std::map<int, int>::const_iterator iter; - for (iter = targets.begin(); iter != targets.end(); ++iter) { - size_t tt = iter->first; - cerr << " " << tt; - } - } - cerr << endl; - - if (action != "I") - s++; - if (action != "D") { - i++; - alignI2S[i] = s; - } - - if (action == "M") { - inputBitmap.push_back(1); - } - else if (action == "I" || action == "S") { - inputBitmap.push_back(0); - } - } // else if ( !currently_matching } // for ( size_t p = 0 cerr << target << endl; @@ -262,7 +260,7 @@ CreateXMLRetValues createXML(const string &source, const string &input, const st for (size_t j = 0; j < nonTerms.size(); ++j) { map<string, int> &nt = nonTerms[j]; if (i == nt["start_i"]) { - ret.ruleS += "[X][X]"; + ret.ruleS += "[X][X] "; nt["rule_pos_s"] = rule_pos_s++; } } @@ -313,10 +311,10 @@ CreateXMLRetValues createXML(const string &source, const string &input, const st ruleAlignment = Trim(ruleAlignment); */ - vector<string> ruleAlignmentToks = Tokenize(ret.ruleAlignment, "-"); + vector<string> ruleAlignmentToks = Tokenize(ret.ruleAlignment); for (size_t i = 0; i < ruleAlignmentToks.size(); ++i) { const string &alignPoint = ruleAlignmentToks[i]; - vector<string> toks = Tokenize(alignPoint); + vector<string> toks = Tokenize(alignPoint, "-"); assert(toks.size() == 2); ret.ruleAlignmentInv += toks[1] + "-" +toks[0]; } diff --git a/scripts/fuzzy-match/create_xml.perl b/scripts/fuzzy-match/create_xml.perl index 4adc97ca2..9efc91b60 100755 --- a/scripts/fuzzy-match/create_xml.perl +++ b/scripts/fuzzy-match/create_xml.perl @@ -1,4 +1,4 @@ -#!/usr/bin/perl -w +#!/usr/bin/perl -w -d binmode( STDIN, ":utf8" ); binmode( STDOUT, ":utf8" ); |