mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-08-16 23:10:31 +03:00
change dynamic to static cast
This commit is contained in:
parent
f296078607
commit
b7d947ebf6
@ -619,7 +619,7 @@ void ChartManager::OutputDetailedTranslationReport(
|
||||
const StaticData &staticData = StaticData::Instance();
|
||||
|
||||
if (staticData.IsDetailedAllTranslationReportingEnabled()) {
|
||||
const Sentence &sentence = dynamic_cast<const Sentence &>(m_source);
|
||||
const Sentence &sentence = static_cast<const Sentence &>(m_source);
|
||||
size_t nBestSize = staticData.options().nbest.nbest_size;
|
||||
std::vector<boost::shared_ptr<ChartKBestExtractor::Derivation> > nBestList;
|
||||
CalcNBest(nBestSize, nBestList, staticData.options().nbest.nbest_size);
|
||||
@ -720,7 +720,7 @@ void ChartManager::OutputDetailedTreeFragmentsTranslationReport(OutputCollector
|
||||
std::ostringstream out;
|
||||
ApplicationContext applicationContext;
|
||||
|
||||
const Sentence &sentence = dynamic_cast<const Sentence &>(m_source);
|
||||
const Sentence &sentence = static_cast<const Sentence &>(m_source);
|
||||
const size_t translationId = m_source.GetTranslationId();
|
||||
|
||||
OutputTreeFragmentsTranslationOptions(out, applicationContext, hypo, sentence, translationId);
|
||||
@ -731,7 +731,7 @@ void ChartManager::OutputDetailedTreeFragmentsTranslationReport(OutputCollector
|
||||
const vector<const StatefulFeatureFunction*>& sff = StatefulFeatureFunction::GetStatefulFeatureFunctions();
|
||||
for( size_t i=0; i<sff.size(); i++ ) {
|
||||
if (sff[i] == treeStructure) {
|
||||
const TreeState* tree = dynamic_cast<const TreeState*>(hypo->GetFFState(i));
|
||||
const TreeState* tree = static_cast<const TreeState*>(hypo->GetFFState(i));
|
||||
out << "Full Tree " << translationId << ": " << tree->GetTree()->GetString() << "\n";
|
||||
break;
|
||||
}
|
||||
|
@ -503,7 +503,7 @@ FFState* BleuScoreFeature::EvaluateWhenApplied(const Hypothesis& cur_hypo,
|
||||
if (!m_enabled) return new BleuScoreState();
|
||||
|
||||
NGrams::const_iterator reference_ngrams_iter;
|
||||
const BleuScoreState& ps = dynamic_cast<const BleuScoreState&>(*prev_state);
|
||||
const BleuScoreState& ps = static_cast<const BleuScoreState&>(*prev_state);
|
||||
BleuScoreState* new_state = new BleuScoreState(ps);
|
||||
|
||||
float old_bleu, new_bleu;
|
||||
@ -579,13 +579,13 @@ FFState* BleuScoreFeature::EvaluateWhenApplied(const ChartHypothesis& cur_hypo,
|
||||
new_state = new BleuScoreState();
|
||||
else {
|
||||
const FFState* prev_state_zero = cur_hypo.GetPrevHypo(0)->GetFFState(featureID);
|
||||
const BleuScoreState& ps_zero = dynamic_cast<const BleuScoreState&>(*prev_state_zero);
|
||||
const BleuScoreState& ps_zero = static_cast<const BleuScoreState&>(*prev_state_zero);
|
||||
new_state = new BleuScoreState(ps_zero);
|
||||
num_words_first_prev = ps_zero.m_target_length;
|
||||
|
||||
for (size_t i = 0; i < cur_hypo.GetPrevHypos().size(); ++i) {
|
||||
const FFState* prev_state = cur_hypo.GetPrevHypo(i)->GetFFState(featureID);
|
||||
const BleuScoreState* ps = dynamic_cast<const BleuScoreState*>(prev_state);
|
||||
const BleuScoreState* ps = static_cast<const BleuScoreState*>(prev_state);
|
||||
BleuScoreState* ps_nonConst = const_cast<BleuScoreState*>(ps);
|
||||
// cerr << "prev phrase: " << cur_hypo.GetPrevHypo(i)->GetOutputPhrase()
|
||||
// << " ( " << cur_hypo.GetPrevHypo(i)->GetTargetLHS() << ")" << endl;
|
||||
|
@ -19,7 +19,7 @@ size_t PhraseBoundaryState::hash() const
|
||||
}
|
||||
bool PhraseBoundaryState::operator==(const FFState& other) const
|
||||
{
|
||||
const PhraseBoundaryState& rhs = dynamic_cast<const PhraseBoundaryState&>(other);
|
||||
const PhraseBoundaryState& rhs = static_cast<const PhraseBoundaryState&>(other);
|
||||
bool ret = *m_targetWord == *rhs.m_targetWord && *m_sourceWord == *rhs.m_sourceWord;
|
||||
return ret;
|
||||
}
|
||||
@ -78,7 +78,7 @@ FFState* PhraseBoundaryFeature::EvaluateWhenApplied
|
||||
(const Hypothesis& cur_hypo, const FFState* prev_state,
|
||||
ScoreComponentCollection* scores) const
|
||||
{
|
||||
const PhraseBoundaryState* pbState = dynamic_cast<const PhraseBoundaryState*>(prev_state);
|
||||
const PhraseBoundaryState* pbState = static_cast<const PhraseBoundaryState*>(prev_state);
|
||||
const Phrase& targetPhrase = cur_hypo.GetCurrTargetPhrase();
|
||||
if (targetPhrase.GetSize() == 0) {
|
||||
return new PhraseBoundaryState(*pbState);
|
||||
|
@ -178,7 +178,7 @@ void SparseHieroReorderingFeature::EvaluateWhenApplied(
|
||||
|
||||
//Iterate through block pairs
|
||||
const Sentence& sentence =
|
||||
dynamic_cast<const Sentence&>(cur_hypo.GetManager().GetSource());
|
||||
static_cast<const Sentence&>(cur_hypo.GetManager().GetSource());
|
||||
//const TargetPhrase& targetPhrase = cur_hypo.GetCurrTargetPhrase();
|
||||
for (size_t i = 0; i < sourceBlocks.size()-1; ++i) {
|
||||
Block& leftSourceBlock = sourceBlocks[i];
|
||||
|
@ -19,7 +19,7 @@ size_t TargetBigramState::hash() const
|
||||
|
||||
bool TargetBigramState::operator==(const FFState& other) const
|
||||
{
|
||||
const TargetBigramState& rhs = dynamic_cast<const TargetBigramState&>(other);
|
||||
const TargetBigramState& rhs = static_cast<const TargetBigramState&>(other);
|
||||
return m_word == rhs.m_word;
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ FFState* TargetBigramFeature::EvaluateWhenApplied(const Hypothesis& cur_hypo,
|
||||
const FFState* prev_state,
|
||||
ScoreComponentCollection* accumulator) const
|
||||
{
|
||||
const TargetBigramState* tbState = dynamic_cast<const TargetBigramState*>(prev_state);
|
||||
const TargetBigramState* tbState = static_cast<const TargetBigramState*>(prev_state);
|
||||
assert(tbState);
|
||||
|
||||
// current hypothesis target phrase
|
||||
|
@ -20,7 +20,7 @@ size_t TargetNgramState::hash() const
|
||||
|
||||
bool TargetNgramState::operator==(const FFState& other) const
|
||||
{
|
||||
const TargetNgramState& rhs = dynamic_cast<const TargetNgramState&>(other);
|
||||
const TargetNgramState& rhs = static_cast<const TargetNgramState&>(other);
|
||||
bool result;
|
||||
if (m_words.size() == rhs.m_words.size()) {
|
||||
for (size_t i = 0; i < m_words.size(); ++i) {
|
||||
|
@ -34,7 +34,7 @@ FFState* TreeStructureFeature::EvaluateWhenApplied(const ChartHypothesis& cur_hy
|
||||
if (word.IsNonTerminal()) {
|
||||
size_t nonTermInd = cur_hypo.GetCurrTargetPhrase().GetAlignNonTerm().GetNonTermIndexMap()[pos];
|
||||
const ChartHypothesis *prevHypo = cur_hypo.GetPrevHypo(nonTermInd);
|
||||
const TreeState* prev = dynamic_cast<const TreeState*>(prevHypo->GetFFState(featureID));
|
||||
const TreeState* prev = static_cast<const TreeState*>(prevHypo->GetFFState(featureID));
|
||||
const TreePointer prev_tree = prev->GetTree();
|
||||
previous_trees.push_back(prev_tree);
|
||||
}
|
||||
|
@ -450,7 +450,7 @@ void Manager::OutputDetailedTreeFragmentsTranslationReport(OutputCollector *coll
|
||||
}
|
||||
|
||||
const search::Applied *applied = &Completed()[0];
|
||||
const Sentence &sentence = dynamic_cast<const Sentence &>(m_source);
|
||||
const Sentence &sentence = static_cast<const Sentence &>(m_source);
|
||||
const size_t translationId = m_source.GetTranslationId();
|
||||
|
||||
std::ostringstream out;
|
||||
|
@ -167,7 +167,7 @@ public:
|
||||
}
|
||||
virtual bool operator==(const FFState& o) const {
|
||||
const LanguageModelChartState &other =
|
||||
dynamic_cast<const LanguageModelChartState &>( o );
|
||||
static_cast<const LanguageModelChartState &>( o );
|
||||
|
||||
// prefix
|
||||
if (m_hypo.GetCurrSourceRange().GetStartPos() > 0) { // not for "<s> ..."
|
||||
|
@ -521,7 +521,7 @@ void Manager::OutputWordGraph(std::ostream &outputWordGraphStream, const Hypothe
|
||||
const std::vector<const StatefulFeatureFunction*> &statefulFFs = StatefulFeatureFunction::GetStatefulFeatureFunctions();
|
||||
for (size_t i = 0; i < statefulFFs.size(); ++i) {
|
||||
const StatefulFeatureFunction *ff = statefulFFs[i];
|
||||
const LanguageModel *lm = dynamic_cast<const LanguageModel*>(ff);
|
||||
const LanguageModel *lm = static_cast<const LanguageModel*>(ff);
|
||||
|
||||
vector<float> scores = hypo->GetScoreBreakdown().GetScoresForProducer(lm);
|
||||
|
||||
|
@ -143,7 +143,7 @@ InputPathList &TranslationOptionCollectionConfusionNet::GetInputPathList(size_t
|
||||
*/
|
||||
void TranslationOptionCollectionConfusionNet::ProcessUnknownWord(size_t sourcePos)
|
||||
{
|
||||
ConfusionNet const& source=dynamic_cast<ConfusionNet const&>(m_source);
|
||||
ConfusionNet const& source=static_cast<ConfusionNet const&>(m_source);
|
||||
|
||||
ConfusionNet::Column const& coll=source.GetColumn(sourcePos);
|
||||
const InputPathList &inputPathList = GetInputPathList(sourcePos, sourcePos);
|
||||
|
@ -75,7 +75,7 @@ void TranslationOptionCollectionText::ProcessUnknownWord(size_t sourcePos)
|
||||
*/
|
||||
bool TranslationOptionCollectionText::HasXmlOptionsOverlappingRange(size_t startPosition, size_t endPosition) const
|
||||
{
|
||||
Sentence const& source=dynamic_cast<Sentence const&>(m_source);
|
||||
Sentence const& source=static_cast<Sentence const&>(m_source);
|
||||
return source.XmlOverlap(startPosition,endPosition);
|
||||
}
|
||||
|
||||
@ -85,7 +85,7 @@ bool TranslationOptionCollectionText::HasXmlOptionsOverlappingRange(size_t start
|
||||
bool TranslationOptionCollectionText::ViolatesXmlOptionsConstraint(size_t startPosition, size_t endPosition, TranslationOption *transOpt) const
|
||||
{
|
||||
// skip if there is no overlap
|
||||
Sentence const& source=dynamic_cast<Sentence const&>(m_source);
|
||||
Sentence const& source=static_cast<Sentence const&>(m_source);
|
||||
if (!source.XmlOverlap(startPosition,endPosition)) {
|
||||
return false;
|
||||
}
|
||||
@ -135,7 +135,7 @@ bool TranslationOptionCollectionText::ViolatesXmlOptionsConstraint(size_t startP
|
||||
*/
|
||||
void TranslationOptionCollectionText::CreateXmlOptionsForRange(size_t startPos, size_t endPos)
|
||||
{
|
||||
Sentence const& source=dynamic_cast<Sentence const&>(m_source);
|
||||
Sentence const& source=static_cast<Sentence const&>(m_source);
|
||||
InputPath &inputPath = GetInputPath(startPos,endPos);
|
||||
|
||||
vector <TranslationOption*> xmlOptions;
|
||||
|
Loading…
Reference in New Issue
Block a user