Download mosesdecoder/moses/FF/CoveredReferenceFeature.h from suricodes/hindi-sindhi-docker: direct link, hf CLI and curl.
- Browser
- Download file 2.15 kB
-
https://huggingface.co/spaces/suricodes/hindi-sindhi-docker/resolve/main/mosesdecoder/moses/FF/CoveredReferenceFeature.h
- Command line
-
hf download hf://spaces/suricodes/hindi-sindhi-docker/mosesdecoder/moses/FF/CoveredReferenceFeature.h
-
curl -L -o CoveredReferenceFeature.h https://huggingface.co/spaces/suricodes/hindi-sindhi-docker/resolve/main/mosesdecoder/moses/FF/CoveredReferenceFeature.h
2.15 kB
| namespace Moses | |
| { | |
| // Given a file with reference translation, reward phrases for matching words from the reference. | |
| class CoveredReferenceState : public FFState | |
| { | |
| public: | |
| std::multiset<std::string> m_coveredRef; | |
| virtual size_t hash() const; | |
| virtual bool operator==(const FFState& other) const; | |
| }; | |
| class CoveredReferenceFeature : public StatefulFeatureFunction | |
| { | |
| static std::multiset<std::string> GetWordsInPhrase(const Phrase &phr) { | |
| std::multiset<std::string> out; | |
| for (size_t i = 0; i < phr.GetSize(); i++) { | |
| out.insert(phr.GetFactor(i, 0)->GetString().as_string()); | |
| } | |
| return out; | |
| } | |
| std::string m_path; | |
| boost::unordered_map<long, std::multiset<std::string> > m_refs; | |
| public: | |
| CoveredReferenceFeature(const std::string &line) | |
| :StatefulFeatureFunction(1, line) { | |
| m_tuneable = true; | |
| ReadParameters(); | |
| } | |
| void Load(AllOptions::ptr const& opts); | |
| bool IsUseable(const FactorMask &mask) const { | |
| return true; | |
| } | |
| virtual const FFState* EmptyHypothesisState(const InputType &input) const { | |
| return new CoveredReferenceState(); | |
| } | |
| void EvaluateWithSourceContext(const InputType &input | |
| , const InputPath &inputPath | |
| , const TargetPhrase &targetPhrase | |
| , const StackVec *stackVec | |
| , ScoreComponentCollection &scoreBreakdown | |
| , ScoreComponentCollection *estimatedScores = NULL) const; | |
| FFState* EvaluateWhenApplied( | |
| const Hypothesis& cur_hypo, | |
| const FFState* prev_state, | |
| ScoreComponentCollection* accumulator) const; | |
| FFState* EvaluateWhenApplied( | |
| const ChartHypothesis& /* cur_hypo */, | |
| int /* featureID - used to index the state in the previous hypotheses */, | |
| ScoreComponentCollection* accumulator) const; | |
| void SetParameter(const std::string& key, const std::string& value); | |
| }; | |
| } | |