Hide keyboard on tap, more robust search algorithm, option to search by dictionary word or definition
This commit is contained in:
@@ -52,11 +52,21 @@ class TokiDictionaryViewModel: ObservableObject {
|
||||
entryMatch = true
|
||||
}
|
||||
|
||||
// Check if any part of the word definitions match in English, even partially
|
||||
// Check if any part of the word definitions match in English, even partially, but
|
||||
// only by prefix (if one of the definition words matches the beginning of the word with
|
||||
// the search term)
|
||||
for definition in value.definitions {
|
||||
if definition.definition.contains(input) {
|
||||
entryMatch = true
|
||||
let capturePattern = #"(\w+)"#
|
||||
let captures = self.searchStringForRegex(string: definition.definition, regex: capturePattern)
|
||||
for capture in captures {
|
||||
if capture.hasPrefix(input) {
|
||||
entryMatch = true
|
||||
}
|
||||
}
|
||||
// Commented out, less strict matching that will match on any substring match
|
||||
// if definition.definition.contains(input) {
|
||||
// entryMatch = true
|
||||
// }
|
||||
}
|
||||
|
||||
// Add to dictionary
|
||||
|
Reference in New Issue
Block a user