00001 // $Id$ 00002 // vim:tabstop=2 00003 00004 /*********************************************************************** 00005 Moses - factored phrase-based language decoder 00006 Copyright (C) 2006 University of Edinburgh 00007 00008 This library is free software; you can redistribute it and/or 00009 modify it under the terms of the GNU Lesser General Public 00010 License as published by the Free Software Foundation; either 00011 version 2.1 of the License, or (at your option) any later version. 00012 00013 This library is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 Lesser General Public License for more details. 00017 00018 You should have received a copy of the GNU Lesser General Public 00019 License along with this library; if not, write to the Free Software 00020 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00021 ***********************************************************************/ 00022 00023 #include <iostream> 00024 #include "SentenceStats.h" 00025 #include "InputPath.h" 00026 #include "TranslationOption.h" 00027 00028 using std::cout; 00029 using std::endl; 00030 00031 namespace Moses 00032 { 00033 /*** 00034 * to be called after decoding a sentence 00035 */ 00036 void SentenceStats::CalcFinalStats(const Hypothesis& bestHypo) 00037 { 00038 //deleted words 00039 AddDeletedWords(bestHypo); 00040 //inserted words--not implemented yet 8/1 TODO 00041 } 00042 00043 void SentenceStats::AddDeletedWords(const Hypothesis& hypo) 00044 { 00045 //don't check either a null pointer or the empty initial hypothesis (if we were given the empty hypo, the null check will save us) 00046 if(hypo.GetPrevHypo() != NULL && hypo.GetPrevHypo()->GetCurrSourceWordsRange().GetNumWordsCovered() > 0) AddDeletedWords(*hypo.GetPrevHypo()); 00047 00048 if(hypo.GetPrevHypo() && hypo.GetCurrTargetWordsRange().GetNumWordsCovered() == 0) { 00049 00050 m_deletedWords.push_back(&hypo.GetTranslationOption().GetInputPath().GetPhrase()); 00051 } 00052 } 00053 00054 } 00055