<commit_before>#include "AlignmentInfo.h"
#include "PhrasePairFeature.h"
#include "TargetPhrase.h"


using namespace std;

namespace Moses {


PhrasePairFeature::PhrasePairFeature
  (FactorType sourceFactorId, FactorType targetFactorId) :
  StatelessFeatureFunction("pp", ScoreProducer::unlimited),
  m_sourceFactorId(sourceFactorId),
  m_targetFactorId(targetFactorId) {}

string PhrasePairFeature::GetScoreProducerWeightShortName(unsigned) const
{
  return "pp";
}

size_t PhrasePairFeature::GetNumInputScores() const 
{
  return 0;
}

void PhrasePairFeature::Evaluate(
  const TargetPhrase& cur_hypo,
  ScoreComponentCollection* accumulator) const {
   const Phrase& source = cur_hypo.GetSourcePhrase();
   const AlignmentInfo& align = cur_hypo.GetAlignmentInfo();
  for (AlignmentInfo::const_iterator i = align.begin(); i != align.end(); ++i) {
    const Factor* sourceFactor = source.GetWord(i->first).GetFactor(m_sourceFactorId);
    const Factor* targetFactor = cur_hypo.GetWord(i->second).GetFactor(m_targetFactorId);
    ostringstream namestr;
    namestr << sourceFactor->GetString();
    namestr << ":";
    namestr << targetFactor->GetString();
    accumulator->PlusEquals(this,namestr.str(),1);
  }
}

bool PhrasePairFeature::ComputeValueInTranslationOption() const {
  return false;
} 


}
<commit_msg>modify phrase pair feature<commit_after>#include "AlignmentInfo.h"
#include "PhrasePairFeature.h"
#include "TargetPhrase.h"


using namespace std;

namespace Moses {


PhrasePairFeature::PhrasePairFeature
  (FactorType sourceFactorId, FactorType targetFactorId) :
  StatelessFeatureFunction("pp", ScoreProducer::unlimited),
  m_sourceFactorId(sourceFactorId),
  m_targetFactorId(targetFactorId) {}

string PhrasePairFeature::GetScoreProducerWeightShortName(unsigned) const
{
  return "pp";
}

size_t PhrasePairFeature::GetNumInputScores() const 
{
  return 0;
}

void PhrasePairFeature::Evaluate(const TargetPhrase& target, ScoreComponentCollection* accumulator) const {
   const Phrase& source = target.GetSourcePhrase();
/*   const AlignmentInfo& align = cur_hypo.GetAlignmentInfo();
   for (AlignmentInfo::const_iterator i = align.begin(); i != align.end(); ++i) {
    const Factor* sourceFactor = source.GetWord(i->first).GetFactor(m_sourceFactorId);
    const Factor* targetFactor = cur_hypo.GetWord(i->second).GetFactor(m_targetFactorId);
    ostringstream namestr;
    namestr << sourceFactor->GetString();
    namestr << ":";
    namestr << targetFactor->GetString();
    accumulator->PlusEquals(this,namestr.str(),1);
  }*/
   ostringstream namestr;
   namestr << source.GetWord(0).GetFactor(m_sourceFactorId)->GetString();
   for (size_t i = 1; i < source.GetSize(); ++i) {
  	 const Factor* sourceFactor = source.GetWord(i).GetFactor(m_sourceFactorId);
  	 namestr << ",";
  	 namestr << sourceFactor->GetString();
   }
   namestr << "~";
   namestr << target.GetWord(0).GetFactor(m_targetFactorId)->GetString();
   for (size_t i = 1; i < target.GetSize(); ++i) {
  	 const Factor* targetFactor = target.GetWord(i).GetFactor(m_targetFactorId);
  	 namestr << ",";
  	 namestr << targetFactor->GetString();
   }
   accumulator->PlusEquals(this,namestr.str(),1);
}

bool PhrasePairFeature::ComputeValueInTranslationOption() const {
  return false;
} 


}

{'fraction_non_alphanumeric': 0.1301829268292683, 'fraction_numerical': 0.00274390243902439, 'mean_word_length': 5.655172413793103, 'pattern_counts': {'":': 2, '<': 31, '<?xml version=': 0, '>': 18, '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': '3374286', 'n_tokens_mistral': 1068, 'n_tokens_neox': 1053, 'n_words': 186}