Download tools/mosesdecoder/moses/Syntax/S2T/ParserCallback.h from Quagmire1/wiki-cased: direct link, hf CLI and curl.
- Browser
- Download file 2.24 kB
-
https://huggingface.co/Quagmire1/wiki-cased/resolve/main/tools/mosesdecoder/moses/Syntax/S2T/ParserCallback.h
- Command line
-
hf download hf://Quagmire1/wiki-cased/tools/mosesdecoder/moses/Syntax/S2T/ParserCallback.h
-
curl -L -o ParserCallback.h https://huggingface.co/Quagmire1/wiki-cased/resolve/main/tools/mosesdecoder/moses/Syntax/S2T/ParserCallback.h
2.24 kB
| namespace Moses | |
| { | |
| namespace Syntax | |
| { | |
| namespace S2T | |
| { | |
| class StandardParserCallback | |
| { | |
| private: | |
| typedef BoundedPriorityContainer<SHyperedgeBundle> Container; | |
| public: | |
| StandardParserCallback(const SChart &schart, std::size_t ruleLimit) | |
| : m_schart(schart) | |
| , m_container(ruleLimit) {} | |
| void operator()(const PHyperedge &hyperedge) { | |
| PHyperedgeToSHyperedgeBundle(hyperedge, m_schart, m_tmpBundle); | |
| float score = SHyperedgeBundleScorer::Score(m_tmpBundle); | |
| m_container.SwapIn(m_tmpBundle, score); | |
| } | |
| void InitForRange(const Range &range) { | |
| m_container.LazyClear(); | |
| } | |
| const Container &GetContainer() { | |
| return m_container; | |
| } | |
| private: | |
| const SChart &m_schart; | |
| SHyperedgeBundle m_tmpBundle; | |
| BoundedPriorityContainer<SHyperedgeBundle> m_container; | |
| }; | |
| class EagerParserCallback | |
| { | |
| private: | |
| typedef BoundedPriorityContainer<SHyperedgeBundle> Container; | |
| public: | |
| EagerParserCallback(const SChart &schart, std::size_t ruleLimit) | |
| : m_schart(schart) | |
| , m_containers(schart.GetWidth(), Container(ruleLimit)) | |
| , m_prevStart(std::numeric_limits<std::size_t>::max()) {} | |
| void operator()(const PHyperedge &hyperedge, std::size_t end) { | |
| PHyperedgeToSHyperedgeBundle(hyperedge, m_schart, m_tmpBundle); | |
| float score = SHyperedgeBundleScorer::Score(m_tmpBundle); | |
| m_containers[end].SwapIn(m_tmpBundle, score); | |
| } | |
| void InitForRange(const Range &range) { | |
| const std::size_t start = range.GetStartPos(); | |
| m_end = range.GetEndPos(); | |
| if (start != m_prevStart) { | |
| for (std::vector<Container>::iterator p = m_containers.begin(); | |
| p != m_containers.end(); ++p) { | |
| p->LazyClear(); | |
| } | |
| m_prevStart = start; | |
| } | |
| } | |
| const Container &GetContainer() { | |
| return m_containers[m_end]; | |
| } | |
| private: | |
| const SChart &m_schart; | |
| SHyperedgeBundle m_tmpBundle; | |
| std::vector<Container> m_containers; | |
| std::size_t m_end; | |
| std::size_t m_prevStart; | |
| }; | |
| } // S2T | |
| } // Syntax | |
| } // Moses | |