summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2024-01-27 09:53:59 +0200
committerThanos Apollo <[email protected]>2024-01-27 11:31:27 +0200
commit38aa8af4168219089f07e3824cea9e9193d13d03 (patch)
tree546cdf1d4df86699f03e5f3fbd3f8501e0e7bdba
parentce66d456b1cfdec5b12c11c1f951aee30a90db0e (diff)
gnosis-compare-strings: Refactor using string-difference
Use Lavenshtein distance to ignore typos
-rw-r--r--gnosis.el5
1 files changed, 3 insertions, 2 deletions
diff --git a/gnosis.el b/gnosis.el
index 18d917c..ef02b46 100644
--- a/gnosis.el
+++ b/gnosis.el
@@ -721,8 +721,9 @@ Valid cloze formats include:
"Compare STR1 and STR2.
Compare 2 strings, ignoring case and whitespace."
- (string= (downcase (replace-regexp-in-string "\\s-" "" str1))
- (downcase (replace-regexp-in-string "\\s-" "" str2))))
+ (<= (string-distance (downcase (replace-regexp-in-string "\\s-" "" str1))
+ (downcase (replace-regexp-in-string "\\s-" "" str2)))
+ gnosis-string-difference))
(defun gnosis-directory-files (&optional dir regex)
"Return a list of file paths, relative to DIR directory.