Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHieu Hoang <hieu@hoang.co.uk>2013-05-29 21:16:15 +0400
committerHieu Hoang <hieu@hoang.co.uk>2013-05-29 21:16:15 +0400
commit6249432407af8730c10bccc7894c0725fcaf5e47 (patch)
tree3ac1f094b9fdc199b04bc5ef209ce00e3596e37d /biconcor/PhrasePairCollection.cpp
parent59bd7deb4b6b9c4f7b3b7dbb055783528fbc31ca (diff)
beautify
Diffstat (limited to 'biconcor/PhrasePairCollection.cpp')
-rw-r--r--biconcor/PhrasePairCollection.cpp175
1 files changed, 86 insertions, 89 deletions
diff --git a/biconcor/PhrasePairCollection.cpp b/biconcor/PhrasePairCollection.cpp
index 7497b2af8..dd21faad3 100644
--- a/biconcor/PhrasePairCollection.cpp
+++ b/biconcor/PhrasePairCollection.cpp
@@ -47,15 +47,15 @@ int PhrasePairCollection::GetCollection( const vector< string >& sourceString )
int sentence_length = m_suffixArray->GetSentenceLength( sentence_id );
int target_length = m_targetCorpus->GetSentenceLength( sentence_id );
//cerr << "match " << (i-first_match)
- //<< " in sentence " << sentence_id
- //<< ", starting at word " << source_start
- //<< " of " << sentence_length
- //<< ". target sentence has " << target_length << " words.";
+ //<< " in sentence " << sentence_id
+ //<< ", starting at word " << source_start
+ //<< " of " << sentence_length
+ //<< ". target sentence has " << target_length << " words.";
int target_start, target_end, pre_null, post_null;
if (m_alignment->PhraseAlignment( sentence_id, target_length, source_start, source_end, target_start, target_end, pre_null, post_null)) {
//cerr << " aligned to [" << (int)target_start << "," << (int)target_end << "]";
//cerr << " +(" << (int)pre_null << "," << (int)post_null << ")";
- bool null_boundary_words = false;
+ bool null_boundary_words = false;
for (int pre = 0; pre <= pre_null && (pre == 0 || null_boundary_words); pre++ ) {
for (int post = 0; post <= post_null && (post == 0 || null_boundary_words); post++ ) {
vector< WORD_ID > targetString;
@@ -75,19 +75,18 @@ int PhrasePairCollection::GetCollection( const vector< string >& sourceString )
m_size++;
}
}
+ } else {
+ //cerr << "mismatch " << (i-first_match)
+ // << " in sentence " << sentence_id
+ // << ", starting at word " << source_start
+ // << " of " << sentence_length
+ // << ". target sentence has " << target_length << " words.";
+ Mismatch *mismatch = new Mismatch( m_suffixArray, m_targetCorpus, m_alignment, sentence_id, position, sentence_length, target_length, source_start, source_end );
+ if (mismatch->Unaligned())
+ m_unaligned.push_back( mismatch );
+ else
+ m_mismatch.push_back( mismatch );
}
- else {
- //cerr << "mismatch " << (i-first_match)
- // << " in sentence " << sentence_id
- // << ", starting at word " << source_start
- // << " of " << sentence_length
- // << ". target sentence has " << target_length << " words.";
- Mismatch *mismatch = new Mismatch( m_suffixArray, m_targetCorpus, m_alignment, sentence_id, position, sentence_length, target_length, source_start, source_end );
- if (mismatch->Unaligned())
- m_unaligned.push_back( mismatch );
- else
- m_mismatch.push_back( mismatch );
- }
//cerr << endl;
if (found > (INDEX)m_max_lookup) {
@@ -111,8 +110,7 @@ void PhrasePairCollection::Print(bool pretty) const
for(int j=0; j<ppWithSameTarget->size() && j<m_max_example; j++, p++ ) {
if (pretty) {
(*p)->PrintPretty( &cout, 100 );
- }
- else {
+ } else {
(*p)->Print( &cout );
}
if (ppWithSameTarget->size() > m_max_example) {
@@ -125,33 +123,32 @@ void PhrasePairCollection::Print(bool pretty) const
void PhrasePairCollection::PrintHTML() const
{
int pp_target = 0;
- bool singleton = false;
- // loop over all translations
+ bool singleton = false;
+ // loop over all translations
vector< vector<PhrasePair*> >::const_iterator ppWithSameTarget;
for( ppWithSameTarget = m_collection.begin(); ppWithSameTarget != m_collection.end() && pp_target<m_max_translation; ppWithSameTarget++, pp_target++ ) {
- int count = ppWithSameTarget->size();
- if (!singleton) {
- if (count == 1) {
- singleton = true;
- cout << "<p class=\"pp_singleton_header\">singleton"
- << (m_collection.end() - ppWithSameTarget==1?"":"s") << " ("
- << (m_collection.end() - ppWithSameTarget)
- << "/" << m_size << ")</p>";
- }
- else {
- cout << "<p class=\"pp_target_header\">";
- (*(ppWithSameTarget->begin()))->PrintTarget( &cout );
- cout << " (" << count << "/" << m_size << ")" << endl;
- cout << "<p><div id=\"pp_" << pp_target << "\">";
- }
- cout << "<table align=\"center\">";
- }
+ int count = ppWithSameTarget->size();
+ if (!singleton) {
+ if (count == 1) {
+ singleton = true;
+ cout << "<p class=\"pp_singleton_header\">singleton"
+ << (m_collection.end() - ppWithSameTarget==1?"":"s") << " ("
+ << (m_collection.end() - ppWithSameTarget)
+ << "/" << m_size << ")</p>";
+ } else {
+ cout << "<p class=\"pp_target_header\">";
+ (*(ppWithSameTarget->begin()))->PrintTarget( &cout );
+ cout << " (" << count << "/" << m_size << ")" << endl;
+ cout << "<p><div id=\"pp_" << pp_target << "\">";
+ }
+ cout << "<table align=\"center\">";
+ }
vector< PhrasePair* >::const_iterator p;
- // loop over all sentences where translation occurs
+ // loop over all sentences where translation occurs
int pp=0;
- int i=0;
+ int i=0;
for(p = ppWithSameTarget->begin(); i<10 && pp<count && p != ppWithSameTarget->end(); p++, pp++, i++ ) {
(*p)->PrintClippedHTML( &cout, 160 );
if (count > m_max_example) {
@@ -159,54 +156,54 @@ void PhrasePairCollection::PrintHTML() const
pp += count/m_max_example-1;
}
}
- if (i == 10 && pp < count) {
- // extended table
- cout << "<tr><td colspan=7 align=center class=\"pp_more\" onclick=\"javascript:document.getElementById('pp_" << pp_target << "').style.display = 'none'; document.getElementById('pp_ext_" << pp_target << "').style.display = 'block';\">(more)</td></tr></table></div>";
- cout << "<div id=\"pp_ext_" << pp_target << "\" style=\"display:none;\";\">";
- cout << "<table align=\"center\">";
- for(i=0, pp=0, p = ppWithSameTarget->begin(); i<m_max_example && pp<count && p != ppWithSameTarget->end(); p++, pp++, i++ ) {
- (*p)->PrintClippedHTML( &cout, 160 );
- if (count > m_max_example) {
- p += count/m_max_example-1;
- pp += count/m_max_example-1;
- }
- }
- }
- if (!singleton) cout << "</table></div>\n";
-
- if (!singleton && pp_target == 9) {
- cout << "<div id=\"pp_toggle\" onclick=\"javascript:document.getElementById('pp_toggle').style.display = 'none'; document.getElementById('pp_additional').style.display = 'block';\">";
- cout << "<p class=\"pp_target_header\">(more)</p></div>";
- cout << "<div id=\"pp_additional\" style=\"display:none;\";\">";
- }
+ if (i == 10 && pp < count) {
+ // extended table
+ cout << "<tr><td colspan=7 align=center class=\"pp_more\" onclick=\"javascript:document.getElementById('pp_" << pp_target << "').style.display = 'none'; document.getElementById('pp_ext_" << pp_target << "').style.display = 'block';\">(more)</td></tr></table></div>";
+ cout << "<div id=\"pp_ext_" << pp_target << "\" style=\"display:none;\";\">";
+ cout << "<table align=\"center\">";
+ for(i=0, pp=0, p = ppWithSameTarget->begin(); i<m_max_example && pp<count && p != ppWithSameTarget->end(); p++, pp++, i++ ) {
+ (*p)->PrintClippedHTML( &cout, 160 );
+ if (count > m_max_example) {
+ p += count/m_max_example-1;
+ pp += count/m_max_example-1;
+ }
+ }
+ }
+ if (!singleton) cout << "</table></div>\n";
+
+ if (!singleton && pp_target == 9) {
+ cout << "<div id=\"pp_toggle\" onclick=\"javascript:document.getElementById('pp_toggle').style.display = 'none'; document.getElementById('pp_additional').style.display = 'block';\">";
+ cout << "<p class=\"pp_target_header\">(more)</p></div>";
+ cout << "<div id=\"pp_additional\" style=\"display:none;\";\">";
+ }
+ }
+ if (singleton) cout << "</table></div>\n";
+ else if (pp_target > 9) cout << "</div>";
+
+ size_t max_mismatch = m_max_example/3;
+ // unaligned phrases
+ if (m_unaligned.size() > 0) {
+ cout << "<p class=\"pp_singleton_header\">unaligned"
+ << " (" << (m_unaligned.size()) << ")</p>";
+ cout << "<table align=\"center\">";
+ int step_size = 1;
+ if (m_unaligned.size() > max_mismatch)
+ step_size = (m_unaligned.size()+max_mismatch-1) / max_mismatch;
+ for(size_t i=0; i<m_unaligned.size(); i+=step_size)
+ m_unaligned[i]->PrintClippedHTML( &cout, 160 );
+ cout << "</table>";
+ }
+
+ // mismatched phrases
+ if (m_mismatch.size() > 0) {
+ cout << "<p class=\"pp_singleton_header\">mismatched"
+ << " (" << (m_mismatch.size()) << ")</p>";
+ cout << "<table align=\"center\">";
+ int step_size = 1;
+ if (m_mismatch.size() > max_mismatch)
+ step_size = (m_mismatch.size()+max_mismatch-1) / max_mismatch;
+ for(size_t i=0; i<m_mismatch.size(); i+=step_size)
+ m_mismatch[i]->PrintClippedHTML( &cout, 160 );
+ cout << "</table>";
}
- if (singleton) cout << "</table></div>\n";
- else if (pp_target > 9) cout << "</div>";
-
- size_t max_mismatch = m_max_example/3;
- // unaligned phrases
- if (m_unaligned.size() > 0) {
- cout << "<p class=\"pp_singleton_header\">unaligned"
- << " (" << (m_unaligned.size()) << ")</p>";
- cout << "<table align=\"center\">";
- int step_size = 1;
- if (m_unaligned.size() > max_mismatch)
- step_size = (m_unaligned.size()+max_mismatch-1) / max_mismatch;
- for(size_t i=0;i<m_unaligned.size();i+=step_size)
- m_unaligned[i]->PrintClippedHTML( &cout, 160 );
- cout << "</table>";
- }
-
- // mismatched phrases
- if (m_mismatch.size() > 0) {
- cout << "<p class=\"pp_singleton_header\">mismatched"
- << " (" << (m_mismatch.size()) << ")</p>";
- cout << "<table align=\"center\">";
- int step_size = 1;
- if (m_mismatch.size() > max_mismatch)
- step_size = (m_mismatch.size()+max_mismatch-1) / max_mismatch;
- for(size_t i=0;i<m_mismatch.size();i+=step_size)
- m_mismatch[i]->PrintClippedHTML( &cout, 160 );
- cout << "</table>";
- }
}