This commit is contained in:
Twan van Laarhoven
2020-05-14 23:48:06 +02:00
parent a13337c262
commit 1f3a2c2519
5 changed files with 32 additions and 88 deletions
-7
View File
@@ -110,13 +110,6 @@ bool SpellChecker::spell(const String& word) {
return Hunspell::spell(str);
}
bool SpellChecker::spell_with_punctuation(const String& word) {
size_t start = 0, end = String::npos;
trim_punctuation(word, start, end);
if (start >= end) return true; // just punctuation is wrong
return spell(word.substr(start,end-start));
}
void SpellChecker::suggest(const String& word, vector<String>& suggestions_out) {
CharBuffer str;
if (!convert_encoding(word,str)) return;
-2
View File
@@ -39,8 +39,6 @@ public:
/// Check the spelling of a single word
bool spell(const String& word);
/// Check the spelling of a single word, ignore punctuation
bool spell_with_punctuation(const String& word);
/// Give spelling suggestions
void suggest(const String& word, vector<String>& suggestions_out);
-6
View File
@@ -115,12 +115,6 @@ String strip_last_word(const String& s) {
const String word_start_chars = String(_("[({\"\'")) + LEFT_SINGLE_QUOTE + LEFT_DOUBLE_QUOTE;
const String word_end_chars = String(_("])}.,;:?!\"\'")) + RIGHT_SINGLE_QUOTE + RIGHT_DOUBLE_QUOTE;
void trim_punctuation(const String& str, size_t& start, size_t& end) {
start = str.find_first_not_of(word_start_chars, start);
end = str.find_last_not_of(word_end_chars, min(end,str.size()-1)) + 1;
if (start >= end) start = end;
}
bool is_word_start_punctuation(Char c) {
return word_start_chars.find_first_of(c) != String::npos;
}
-3
View File
@@ -140,9 +140,6 @@ String last_word(const String&);
/// Remove the last word from a string, leaves whitespace before that word
String strip_last_word(const String&);
/// Trim punctuation at the start/end of a word in the range [start..end)
void trim_punctuation(const String&, size_t& start, size_t& end);
bool is_word_start_punctuation(Char c);
bool is_word_end_punctuation(Char c);