2015-01-27 01:12:44 +03:00
|
|
|
#pragma once
|
2011-08-13 06:40:54 +04:00
|
|
|
|
|
|
|
#include <string>
|
2013-04-25 22:42:30 +04:00
|
|
|
#include <boost/unordered_set.hpp>
|
2011-08-13 06:40:54 +04:00
|
|
|
|
2013-05-24 21:02:49 +04:00
|
|
|
#include "moses/FactorCollection.h"
|
|
|
|
#include "moses/Sentence.h"
|
2013-05-24 22:11:15 +04:00
|
|
|
#include "FFState.h"
|
|
|
|
#include "StatelessFeatureFunction.h"
|
2012-02-29 00:22:09 +04:00
|
|
|
|
2011-08-13 06:40:54 +04:00
|
|
|
namespace Moses
|
|
|
|
{
|
|
|
|
|
|
|
|
/** Sets the features for word translation
|
|
|
|
*/
|
2013-05-29 21:16:15 +04:00
|
|
|
class WordTranslationFeature : public StatelessFeatureFunction
|
|
|
|
{
|
2012-02-29 00:22:09 +04:00
|
|
|
|
2012-03-20 17:45:25 +04:00
|
|
|
typedef std::map< char, short > CharHash;
|
2013-04-25 22:42:30 +04:00
|
|
|
typedef std::vector< boost::unordered_set<std::string> > DocumentVector;
|
2013-05-29 21:16:15 +04:00
|
|
|
|
2011-08-13 06:40:54 +04:00
|
|
|
private:
|
2013-04-25 22:42:30 +04:00
|
|
|
boost::unordered_set<std::string> m_vocabSource;
|
|
|
|
boost::unordered_set<std::string> m_vocabTarget;
|
2012-07-26 20:32:50 +04:00
|
|
|
DocumentVector m_vocabDomain;
|
2011-08-13 06:40:54 +04:00
|
|
|
FactorType m_factorTypeSource;
|
|
|
|
FactorType m_factorTypeTarget;
|
|
|
|
bool m_unrestricted;
|
2012-03-07 18:04:25 +04:00
|
|
|
bool m_simple;
|
2012-02-27 00:14:49 +04:00
|
|
|
bool m_sourceContext;
|
2012-03-07 18:04:25 +04:00
|
|
|
bool m_targetContext;
|
2012-07-26 20:32:50 +04:00
|
|
|
bool m_domainTrigger;
|
2012-03-20 17:45:25 +04:00
|
|
|
bool m_ignorePunctuation;
|
|
|
|
CharHash m_punctuationHash;
|
2013-06-09 23:23:10 +04:00
|
|
|
std::string m_filePathSource;
|
|
|
|
std::string m_filePathTarget;
|
2013-05-29 21:16:15 +04:00
|
|
|
|
2011-08-13 06:40:54 +04:00
|
|
|
public:
|
2013-01-03 01:26:56 +04:00
|
|
|
WordTranslationFeature(const std::string &line);
|
2013-05-29 21:16:15 +04:00
|
|
|
|
2013-08-30 18:49:00 +04:00
|
|
|
void SetParameter(const std::string& key, const std::string& value);
|
2013-05-30 15:41:08 +04:00
|
|
|
bool IsUseable(const FactorMask &mask) const;
|
|
|
|
|
2013-06-09 23:23:10 +04:00
|
|
|
void Load();
|
2013-05-29 21:16:15 +04:00
|
|
|
|
2012-02-29 00:22:09 +04:00
|
|
|
const FFState* EmptyHypothesisState(const InputType &) const {
|
2012-10-03 21:53:55 +04:00
|
|
|
return new DummyState();
|
2012-02-29 00:22:09 +04:00
|
|
|
}
|
2013-05-29 21:16:15 +04:00
|
|
|
|
2014-07-10 02:06:54 +04:00
|
|
|
void EvaluateWithSourceContext(const InputType &input
|
2015-01-14 14:07:42 +03:00
|
|
|
, const InputPath &inputPath
|
|
|
|
, const TargetPhrase &targetPhrase
|
|
|
|
, const StackVec *stackVec
|
|
|
|
, ScoreComponentCollection &scoreBreakdown
|
|
|
|
, ScoreComponentCollection *estimatedFutureScore = NULL) const;
|
2014-10-13 13:42:25 +04:00
|
|
|
|
2014-07-10 01:35:59 +04:00
|
|
|
void EvaluateInIsolation(const Phrase &source
|
2015-01-14 14:07:42 +03:00
|
|
|
, const TargetPhrase &targetPhrase
|
|
|
|
, ScoreComponentCollection &scoreBreakdown
|
|
|
|
, ScoreComponentCollection &estimatedFutureScore) const {
|
|
|
|
}
|
2013-08-30 18:49:00 +04:00
|
|
|
|
2014-10-13 13:42:25 +04:00
|
|
|
void EvaluateWhenApplied(const Hypothesis& hypo,
|
2015-01-14 14:07:42 +03:00
|
|
|
ScoreComponentCollection* accumulator) const {
|
|
|
|
}
|
2014-10-13 13:42:25 +04:00
|
|
|
|
|
|
|
void EvaluateWhenApplied(const ChartHypothesis &hypo,
|
2015-01-14 14:07:42 +03:00
|
|
|
ScoreComponentCollection* accumulator) const {
|
|
|
|
}
|
|
|
|
|
2015-01-06 15:56:13 +03:00
|
|
|
void EvaluateTranslationOptionListWithSourceContext(const InputType &input
|
2015-01-14 14:07:42 +03:00
|
|
|
, const TranslationOptionList &translationOptionList) const {
|
|
|
|
}
|
2015-01-06 12:46:31 +03:00
|
|
|
|
2014-10-13 13:42:25 +04:00
|
|
|
|
2011-08-13 06:40:54 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|