wiki-cased / tools /mosesdecoder /moses /TranslationModel /RuleTable /PhraseDictionaryALSuffixArray.cpp
Download tools/mosesdecoder/moses/TranslationModel/RuleTable/PhraseDictionaryALSuffixArray.cpp from Quagmire1/wiki-cased: direct link, hf CLI and curl.
- Browser
- Download file 1.71 kB
-
https://huggingface.co/Quagmire1/wiki-cased/resolve/main/tools/mosesdecoder/moses/TranslationModel/RuleTable/PhraseDictionaryALSuffixArray.cpp
- Command line
-
hf download hf://Quagmire1/wiki-cased/tools/mosesdecoder/moses/TranslationModel/RuleTable/PhraseDictionaryALSuffixArray.cpp
-
curl -L -o PhraseDictionaryALSuffixArray.cpp https://huggingface.co/Quagmire1/wiki-cased/resolve/main/tools/mosesdecoder/moses/TranslationModel/RuleTable/PhraseDictionaryALSuffixArray.cpp
1.71 kB
| // | |
| // PhraseDictionaryALSuffixArray.cpp | |
| // moses | |
| // | |
| // Created by Hieu Hoang on 06/11/2011. | |
| // Copyright 2011 __MyCompanyName__. All rights reserved. | |
| // | |
| using namespace std; | |
| namespace Moses | |
| { | |
| PhraseDictionaryALSuffixArray::PhraseDictionaryALSuffixArray(const std::string &line) | |
| : PhraseDictionaryMemory(1, line) | |
| { | |
| const StaticData &staticData = StaticData::Instance(); | |
| if (staticData.ThreadCount() > 1) { | |
| throw runtime_error("Suffix array implementation is not threadsafe"); | |
| } | |
| ReadParameters(); | |
| } | |
| void PhraseDictionaryALSuffixArray::Load(AllOptions::ptr const& opts) | |
| { | |
| m_options = opts; | |
| SetFeaturesToApply(); | |
| } | |
| void PhraseDictionaryALSuffixArray::InitializeForInput(ttasksptr const& ttask) | |
| { | |
| InputType const& source = *ttask->GetSource(); | |
| // populate with rules for this sentence | |
| long translationId = source.GetTranslationId(); | |
| string grammarFile = GetFilePath() + "/grammar." + SPrint(translationId) + ".gz"; | |
| std::auto_ptr<RuleTableLoader> loader = | |
| RuleTableLoaderFactory::Create(grammarFile); | |
| AllOptions::ptr const& opts = ttask->options(); | |
| bool ret = loader->Load(*opts, m_input, m_output, grammarFile, m_tableLimit, *this); | |
| UTIL_THROW_IF2(!ret, "Rules not successfully loaded for sentence id " | |
| << translationId); | |
| } | |
| void PhraseDictionaryALSuffixArray::CleanUpAfterSentenceProcessing(const InputType &source) | |
| { | |
| m_collection.Remove(); | |
| } | |
| } | |