Download mosesdecoder/moses2/legacy/Util2.cpp from sleepyhead111/vllm_fairseq: direct link, hf CLI and curl.
- Browser
- Download file 721 Bytes
-
https://huggingface.co/sleepyhead111/vllm_fairseq/resolve/main/mosesdecoder/moses2/legacy/Util2.cpp
- Command line
-
hf download hf://sleepyhead111/vllm_fairseq/mosesdecoder/moses2/legacy/Util2.cpp
-
curl -L -o Util2.cpp https://huggingface.co/sleepyhead111/vllm_fairseq/resolve/main/mosesdecoder/moses2/legacy/Util2.cpp
721 Bytes
| namespace Moses2 | |
| { | |
| class BoolValueException: public util::Exception | |
| { | |
| }; | |
| template<> | |
| bool Scan<bool>(const std::string &input) | |
| { | |
| std::string lc = ToLower(input); | |
| if (lc == "yes" || lc == "y" || lc == "true" || lc == "1") return true; | |
| if (lc == "no" || lc == "n" || lc == "false" || lc == "0") return false; | |
| UTIL_THROW(BoolValueException, | |
| "Could not interpret " << input << " as a boolean. After lowercasing, valid values are yes, y, true, 1, no, n, false, and 0."); | |
| } | |
| const std::string ToLower(const std::string& str) | |
| { | |
| std::string lc(str); | |
| std::transform(lc.begin(), lc.end(), lc.begin(), (int (*)(int))std::tolower); | |
| return | |
| lc ; | |
| } | |
| } | |