MCPcopy Create free account
hub / github.com/catboost/catboost / LanguageByName

Method LanguageByName

library/cpp/langs/langs.cpp:263–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

261
262 public:
263 inline ELanguage LanguageByName(const TStringBuf& name, ELanguage def) const {
264 if (!name)
265 return def;
266
267 TNamesHash::const_iterator i = Hash.find(name);
268 if (i == Hash.end()) {
269 // Try to extract the primary language code from constructions like "en-cockney" or "zh_Hant"
270 size_t dash_pos = name.find_first_of("_-");
271 if (dash_pos != TStringBuf::npos)
272 i = Hash.find(name.substr(0, dash_pos));
273 if (i == Hash.end())
274 return def;
275 }
276
277 return i->second;
278 }
279
280 inline const char* FullNameByLanguage(ELanguage language) const {
281 if (static_cast<size_t>(language) >= FullNames.size())

Callers 2

LanguageByNameStrictFunction · 0.80
LanguageByNameFunction · 0.80

Calls 4

findMethod · 0.45
endMethod · 0.45
find_first_ofMethod · 0.45
substrMethod · 0.45

Tested by

no test coverage detected