Split sentence into segments (using punctuation).
| 31 | |
| 32 | // Split sentence into segments (using punctuation). |
| 33 | std::vector<std::string> SplitSentence(const std::string& input) { |
| 34 | string result(input); |
| 35 | |
| 36 | RE2::GlobalReplace(&result, "([?.!,])+", " \\1"); |
| 37 | RE2::GlobalReplace(&result, "([?.!,])+\\s+", "\\1\t"); |
| 38 | RE2::GlobalReplace(&result, "[ ]+", " "); |
| 39 | RE2::GlobalReplace(&result, "\t+$", ""); |
| 40 | |
| 41 | return absl::StrSplit(result, '\t'); |
| 42 | } |
| 43 | |
| 44 | // Predict with TfLite model. |
| 45 | void ExecuteTfLite(const std::string& sentence, |
no outgoing calls
no test coverage detected