float thold_pt,
float thold_ptsum);
-// trim from start (in place)
-static inline void ltrim(std::string &s) {
- s.erase(s.begin(), std::find_if_not(s.begin(), s.end(), [](unsigned char ch) {
- return std::isspace(ch);
- }));
-}
-
-// trim from end (in place)
-static inline void rtrim(std::string &s) {
- s.erase(std::find_if_not(s.rbegin(), s.rend(), [](unsigned char ch) {
- return std::isspace(ch);
- }).base(), s.end());
-}
-
-// trim from both ends (in place)
-static inline void trim(std::string &s) {
- rtrim(s);
- ltrim(s);
-}
-
static inline bool should_split_on_word(const char * txt, bool split_on_word) {
if (!split_on_word) return true;
const int cur = strlen(txt);
if (acc + cur > max_len && i > 0 && should_split_on_word(txt, split_on_word)) {
- // split here
- if (split_on_word) {
- trim(text);
- }
-
state.result_all.back().text = std::move(text);
state.result_all.back().t1 = token.t0;
state.result_all.back().tokens.resize(i);
}
}
- if (split_on_word) {
- trim(text);
- }
state.result_all.back().text = std::move(text);
return res;