<commit_before>#include <stdexcept>
#include "InputFeature.h"
#include "moses/Util.h"
#include "moses/ScoreComponentCollection.h"
#include "moses/InputPath.h"
#include "moses/StaticData.h"
#include "moses/TranslationModel/PhraseDictionaryTreeAdaptor.h"
#include "util/check.hh"

using namespace std;

namespace Moses
{
InputFeature::InputFeature(const std::string &line)
  :StatelessFeatureFunction("InputFeature", line)
{
  ReadParameters();
}

void InputFeature::Load()
{
	const StaticData &staticData = StaticData::Instance();
	const PhraseDictionary *pt = staticData.GetTranslationScoreProducer(0);
	const PhraseDictionaryTreeAdaptor *ptBin = dynamic_cast<const PhraseDictionaryTreeAdaptor*>(pt);

	m_legacy = (ptBin != NULL);
}

void InputFeature::SetParameter(const std::string& key, const std::string& value)
{
  if (key == "num-input-features") {
    m_numInputScores = Scan<size_t>(value);
  } else if (key == "real-word-count") {
    m_numRealWordCount = Scan<size_t>(value);
  } else {
    StatelessFeatureFunction::SetParameter(key, value);
  }

}

void InputFeature::Evaluate(const InputType &input
                            , const InputPath &inputPath
                            , const TargetPhrase &targetPhrase
                            , ScoreComponentCollection &scoreBreakdown) const
{
	if (m_legacy) {
		//binary phrase-table does input feature itself
		return;
	}

  const ScorePair *scores = inputPath.GetInputScore();
  if (scores) {
	  scoreBreakdown.PlusEquals(this, *scores);
  }
}

} // namespace
<commit_msg>input feature score error when using anything other than bin pt<commit_after>#include <stdexcept>
#include "InputFeature.h"
#include "moses/Util.h"
#include "moses/ScoreComponentCollection.h"
#include "moses/InputPath.h"
#include "moses/StaticData.h"
#include "moses/TranslationModel/PhraseDictionaryTreeAdaptor.h"
#include "util/check.hh"

using namespace std;

namespace Moses
{
InputFeature::InputFeature(const std::string &line)
  :StatelessFeatureFunction("InputFeature", line)
{
  ReadParameters();
}

void InputFeature::Load()
{
	const StaticData &staticData = StaticData::Instance();
	const PhraseDictionary *pt = staticData.GetTranslationScoreProducer(0);
	const PhraseDictionaryTreeAdaptor *ptBin = dynamic_cast<const PhraseDictionaryTreeAdaptor*>(pt);

	m_legacy = (ptBin != NULL);
}

void InputFeature::SetParameter(const std::string& key, const std::string& value)
{
  if (key == "num-input-features") {
    m_numInputScores = Scan<size_t>(value);
  } else if (key == "real-word-count") {
    m_numRealWordCount = Scan<size_t>(value);
  } else {
    StatelessFeatureFunction::SetParameter(key, value);
  }

}

void InputFeature::Evaluate(const InputType &input
                            , const InputPath &inputPath
                            , const TargetPhrase &targetPhrase
                            , ScoreComponentCollection &scoreBreakdown) const
{
	if (m_legacy) {
		//binary phrase-table does input feature itself
		return;
	}
	/*
  const ScorePair *scores = inputPath.GetInputScore();
  if (scores) {
  	  scoreBreakdown.PlusEquals(this, *scores);
  }
	*/
}

} // namespace

{'fraction_non_alphanumeric': 0.12019077901430843, 'fraction_numerical': 0.0006359300476947536, 'mean_word_length': 4.208609271523179, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1276712', 'n_tokens_mistral': 1005, 'n_tokens_neox': 972, 'n_words': 204}