21 unsigned int EditDistance(
const TString &s1,
const TString &s2)
const;
22 unsigned int EditDistance(
const std::string &s1,
const std::string &s2)
const;
25 typename std::map<TString, T>::iterator
FindMostSimilar(std::map<TString, T> &mymap,
const TString &key);
28 typename std::map<std::string, T>::iterator
FindMostSimilar(std::map<std::string, T> &mymap,
const std::string &key);
30 template <
typename T1,
typename T2>
31 std::vector<T1>
GetListOfKeys(
const std::map<T1, T2> &inputmap)
const;
33 template <
typename T1,
typename T2>
34 std::vector<T2>
GetListOfValues(
const std::map<T1, T2> &inputmap)
const;
45 if (mymap.size() == 0)
47 MSGUser()->StartTitle(
"MapTool::FindMostSimilar");
48 MSGUser()->MSG_WARNING(
"The given map is empty, returning its end");
50 return std::end(mymap);
53 auto findresult = mymap.find(key);
54 if (findresult != mymap.end())
58 MSGUser()->StartTitle(
"MapTool::FindMostSimilar");
60 typename std::map<TString, T>::iterator keypos;
62 for (
typename std::map<TString, T>::iterator it = mymap.begin(); it != mymap.end(); ++it)
79 MSGUser()->MSG(
MSGLevel::WARNING,
"No exact match of input string, turn to fuzzy search(the best match in the key). Key ", keypos->first,
" is find (key ", key,
" is the input)");
91 inline typename std::map<std::string, T>::iterator
MapTool::FindMostSimilar(std::map<std::string, T> &mymap,
const std::string &key)
93 if (mymap.size() == 0)
95 MSGUser()->StartTitle(
"MapTool::FindMostSimilar");
96 MSGUser()->MSG_WARNING(
"The given map is empty, returning its end");
98 return std::end(mymap);
101 auto findresult = mymap.find(key);
102 if (findresult != mymap.end())
106 MSGUser()->StartTitle(
"MapTool::FindMostSimilar");
108 typename std::map<std::string, T>::iterator keypos;
110 for (
typename std::map<std::string, T>::iterator it = mymap.begin(); it != mymap.end(); ++it)
127 MSGUser()->MSG(
MSGLevel::WARNING,
"No exact match of input string, turn to fuzzy search(the best match in the key). Key ", keypos->first,
" is find (key ", key,
" is the input)");
134 template <
typename T1,
typename T2>
137 std::vector<T1> tempv;
138 for (
auto &t : inputmap)
139 tempv.push_back(t.first);
144 template <
typename T1,
typename T2>
147 std::vector<T2> tempv;
148 for (
auto &t : inputmap)
149 tempv.push_back(t.second);