mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-27 05:55:02 +03:00
78 lines
2.7 KiB
C++
78 lines
2.7 KiB
C++
// $Id$
|
|
|
|
/***********************************************************************
|
|
Moses - factored phrase-based language decoder
|
|
Copyright (C) 2006 University of Edinburgh
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with this library; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
***********************************************************************/
|
|
|
|
#include "TranslationOptionCollectionText.h"
|
|
#include "Sentence.h"
|
|
#include "DecodeStep.h"
|
|
#include "moses/TranslationModel/PhraseDictionaryMemory.h"
|
|
#include "FactorCollection.h"
|
|
#include "WordsRange.h"
|
|
|
|
using namespace std;
|
|
|
|
namespace Moses
|
|
{
|
|
/** constructor; just initialize the base class */
|
|
TranslationOptionCollectionText::TranslationOptionCollectionText(const TranslationSystem* system, Sentence const &inputSentence, size_t maxNoTransOptPerCoverage, float translationOptionThreshold)
|
|
: TranslationOptionCollection(system, inputSentence, maxNoTransOptPerCoverage, translationOptionThreshold) {}
|
|
|
|
/* forcibly create translation option for a particular source word.
|
|
* For text, this function is easy, just call the base class' ProcessOneUnknownWord()
|
|
*/
|
|
void TranslationOptionCollectionText::ProcessUnknownWord(size_t sourcePos)
|
|
{
|
|
const Word &sourceWord = m_source.GetWord(sourcePos);
|
|
ProcessOneUnknownWord(sourceWord,sourcePos);
|
|
}
|
|
|
|
/**
|
|
* Check the source sentence for coverage data
|
|
*/
|
|
bool TranslationOptionCollectionText::HasXmlOptionsOverlappingRange(size_t startPosition, size_t endPosition) const
|
|
{
|
|
Sentence const& source=dynamic_cast<Sentence const&>(m_source);
|
|
return source.XmlOverlap(startPosition,endPosition);
|
|
}
|
|
|
|
/**
|
|
* Create xml-based translation options for the specific input span
|
|
*/
|
|
void TranslationOptionCollectionText::CreateXmlOptionsForRange(size_t startPosition, size_t endPosition)
|
|
{
|
|
Sentence const& source=dynamic_cast<Sentence const&>(m_source);
|
|
|
|
vector <TranslationOption*> xmlOptions;
|
|
|
|
source.GetXmlTranslationOptions(xmlOptions,startPosition,endPosition);
|
|
|
|
//get vector of TranslationOptions from Sentence
|
|
for(size_t i=0; i<xmlOptions.size(); i++) {
|
|
xmlOptions[i]->CalcScore(m_system);
|
|
Add(xmlOptions[i]);
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|