Download tools/mosesdecoder/defer/ExternalFeature.h from Quagmire1/wiki-cased: direct link, hf CLI and curl.
- Browser
- Download file 1.75 kB
-
https://huggingface.co/Quagmire1/wiki-cased/resolve/main/tools/mosesdecoder/defer/ExternalFeature.h
- Command line
-
hf download hf://Quagmire1/wiki-cased/tools/mosesdecoder/defer/ExternalFeature.h
-
curl -L -o ExternalFeature.h https://huggingface.co/Quagmire1/wiki-cased/resolve/main/tools/mosesdecoder/defer/ExternalFeature.h
1.75 kB
| namespace Moses | |
| { | |
| class CdecFF; | |
| class ExternalFeatureState : public FFState | |
| { | |
| protected: | |
| int m_stateSize; | |
| void *m_data; | |
| public: | |
| ExternalFeatureState(int stateSize) | |
| :m_stateSize(stateSize) | |
| ,m_data(NULL) { | |
| } | |
| ExternalFeatureState(int stateSize, void *data); | |
| ~ExternalFeatureState() { | |
| free(m_data); | |
| } | |
| int Compare(const FFState& other) const { | |
| const ExternalFeatureState &otherFF = static_cast<const ExternalFeatureState&>(other); | |
| int ret = memcmp(m_data, otherFF.m_data, m_stateSize); | |
| return ret; | |
| } | |
| }; | |
| // copied from cdec | |
| class ExternalFeature : public StatefulFeatureFunction | |
| { | |
| public: | |
| ExternalFeature(const std::string &line) | |
| :StatefulFeatureFunction(line) { | |
| ReadParameters(); | |
| } | |
| ~ExternalFeature(); | |
| void Load(AllOptions const& opts); | |
| bool IsUseable(const FactorMask &mask) const { | |
| return true; | |
| } | |
| void SetParameter(const std::string& key, const std::string& value); | |
| 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; | |
| virtual const FFState* EmptyHypothesisState(const InputType &input) const { | |
| return new ExternalFeatureState(m_stateSize); | |
| } | |
| protected: | |
| std::string m_path; | |
| void* lib_handle; | |
| CdecFF *ff_ext; | |
| int m_stateSize; | |
| }; | |
| class CdecFF | |
| { | |
| public: | |
| virtual ~CdecFF() {} | |
| virtual int StateSize() const = 0; | |
| }; | |
| } | |