diff options
author | Rico Sennrich <rico.sennrich@gmx.ch> | 2013-09-08 01:04:20 +0400 |
---|---|---|
committer | Rico Sennrich <rico.sennrich@gmx.ch> | 2013-09-08 01:04:40 +0400 |
commit | b421f7c9b0a784d7cde6214cda0e5789b044122c (patch) | |
tree | dc60b4cfcb7ad15d855eb2164f1316cebd8b785c /phrase-extract/extract-main.cpp | |
parent | 7138056b8fd60b4572f016f038360dd5fb19a39c (diff) |
refactoring to minimize overhead from flexibility score code (if off)
Diffstat (limited to 'phrase-extract/extract-main.cpp')
-rw-r--r-- | phrase-extract/extract-main.cpp | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/phrase-extract/extract-main.cpp b/phrase-extract/extract-main.cpp index 5bc018173..a13cd41b4 100644 --- a/phrase-extract/extract-main.cpp +++ b/phrase-extract/extract-main.cpp @@ -706,8 +706,6 @@ void ExtractTask::addPhrase( SentenceAlignment &sentence, int startE, int endE, ostringstream outextractstr; ostringstream outextractstrInv; ostringstream outextractstrOrientation; - ostringstream outextractstrContext; - ostringstream outextractstrContextInv; if (m_options.isOnlyOutputSpanInfo()) { cout << startF << " " << endF << " " << startE << " " << endE << endl; @@ -721,25 +719,19 @@ void ExtractTask::addPhrase( SentenceAlignment &sentence, int startE, int endE, for(int fi=startF; fi<=endF; fi++) { if (m_options.isTranslationFlag()) outextractstr << sentence.source[fi] << " "; if (m_options.isOrientationFlag()) outextractstrOrientation << sentence.source[fi] << " "; - if (m_options.isFlexScoreFlag()) outextractstrContext << sentence.source[fi] << " "; } if (m_options.isTranslationFlag()) outextractstr << "||| "; if (m_options.isOrientationFlag()) outextractstrOrientation << "||| "; - if (m_options.isFlexScoreFlag()) outextractstrContext << "||| "; // target for(int ei=startE; ei<=endE; ei++) { if (m_options.isTranslationFlag()) outextractstr << sentence.target[ei] << " "; if (m_options.isTranslationFlag()) outextractstrInv << sentence.target[ei] << " "; if (m_options.isOrientationFlag()) outextractstrOrientation << sentence.target[ei] << " "; - if (m_options.isFlexScoreFlag()) outextractstrContext << sentence.target[ei] << " "; - if (m_options.isFlexScoreFlag()) outextractstrContextInv << sentence.target[ei] << " "; } if (m_options.isTranslationFlag()) outextractstr << "|||"; if (m_options.isTranslationFlag()) outextractstrInv << "||| "; if (m_options.isOrientationFlag()) outextractstrOrientation << "||| "; - if (m_options.isFlexScoreFlag()) outextractstrContext << "||| "; - if (m_options.isFlexScoreFlag()) outextractstrContextInv << "||| "; // source (for inverse) @@ -748,11 +740,6 @@ void ExtractTask::addPhrase( SentenceAlignment &sentence, int startE, int endE, outextractstrInv << sentence.source[fi] << " "; outextractstrInv << "|||"; } - if (m_options.isFlexScoreFlag()) { - for(int fi=startF; fi<=endF; fi++) - outextractstrContextInv << sentence.source[fi] << " "; - outextractstrContextInv << "|||"; - } // alignment if (m_options.isTranslationFlag()) { @@ -788,6 +775,27 @@ void ExtractTask::addPhrase( SentenceAlignment &sentence, int startE, int endE, // once with left, once with right context if (m_options.isFlexScoreFlag()) { + ostringstream outextractstrContext; + ostringstream outextractstrContextInv; + + for(int fi=startF; fi<=endF; fi++) { + outextractstrContext << sentence.source[fi] << " "; + } + outextractstrContext << "||| "; + + // target + for(int ei=startE; ei<=endE; ei++) { + outextractstrContext << sentence.target[ei] << " "; + outextractstrContextInv << sentence.target[ei] << " "; + } + outextractstrContext << "||| "; + outextractstrContextInv << "||| "; + + for(int fi=startF; fi<=endF; fi++) + outextractstrContextInv << sentence.source[fi] << " "; + + outextractstrContextInv << "|||"; + string strContext = outextractstrContext.str(); string strContextInv = outextractstrContextInv.str(); @@ -862,8 +870,10 @@ void ExtractTask::writePhrasesToFile() m_extractFile << outextractFile.str(); m_extractFileInv << outextractFileInv.str(); m_extractFileOrientation << outextractFileOrientation.str(); - m_extractFileContext << outextractFileContext.str(); - m_extractFileContextInv << outextractFileContextInv.str(); + if (m_options.isFlexScoreFlag()) { + m_extractFileContext << outextractFileContext.str(); + m_extractFileContextInv << outextractFileContextInv.str(); + } } // if proper conditioning, we need the number of times a source phrase occured |