Download tools/mosesdecoder/moses/server/PackScores.cpp from Quagmire1/wiki-cased: direct link, hf CLI and curl.
- Browser
- Download file 1.51 kB
-
https://huggingface.co/Quagmire1/wiki-cased/resolve/main/tools/mosesdecoder/moses/server/PackScores.cpp
- Command line
-
hf download hf://Quagmire1/wiki-cased/tools/mosesdecoder/moses/server/PackScores.cpp
-
curl -L -o PackScores.cpp https://huggingface.co/Quagmire1/wiki-cased/resolve/main/tools/mosesdecoder/moses/server/PackScores.cpp
1.51 kB
| // -*- mode: c++; indent-tabs-mode: nil; tab-width:2 -*- | |
| namespace Moses { | |
| void | |
| PackScores(FeatureFunction const& ff, FVector const& S, | |
| std::map<std::string, xmlrpc_c::value>& M) | |
| { | |
| std::vector<xmlrpc_c::value> v; | |
| size_t N = ff.GetNumScoreComponents(); | |
| std::vector<xmlrpc_c::value> dense; | |
| dense.reserve(N); | |
| size_t o = ff.GetIndex(); | |
| for (size_t i = 0; i < N; ++i) | |
| if (ff.IsTuneableComponent(i)) | |
| dense.push_back(xmlrpc_c::value_double(S[o+i])); | |
| v.push_back(xmlrpc_c::value_array(dense)); | |
| std::map<std::string,xmlrpc_c::value> sparse; | |
| typedef FVector::FNVmap::const_iterator iter; | |
| for(iter m = S.cbegin(); m != S.cend(); ++m) | |
| sparse[m->first.name()] = xmlrpc_c::value_double(m->second); | |
| v.push_back(xmlrpc_c::value_struct(sparse)); | |
| M[ff.GetScoreProducerDescription()] = xmlrpc_c::value_array(v); | |
| } | |
| xmlrpc_c::value | |
| PackScores(ScoreComponentCollection const& S) | |
| { | |
| std::map<std::string, xmlrpc_c::value> M; | |
| typedef StatefulFeatureFunction SFFF; | |
| typedef StatelessFeatureFunction SLFF; | |
| BOOST_FOREACH(SFFF const* ff, SFFF::GetStatefulFeatureFunctions()) | |
| if (ff->IsTuneable()) | |
| PackScores(*ff, S.GetScoresVector(), M); | |
| BOOST_FOREACH(SLFF const* ff, SLFF::GetStatelessFeatureFunctions()) | |
| if (ff->IsTuneable()) | |
| PackScores(*ff, S.GetScoresVector(), M); | |
| return xmlrpc_c::value_struct(M); | |
| } | |
| } | |