help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Testing validity of a word


From: Emanuel Berg
Subject: Re: Testing validity of a word
Date: Wed, 26 Jul 2023 21:07:03 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

uzibalqa wrote:

> The following could be less intensive
>
> (defun is-valid-word (word)
>   "Check if the WORD is valid using `ispell`."
>   (ispell-lookup-words word))

Okay, so I tried with these

(defun spell-word-2 (word)
  (and (ispell-lookup-words word) t) )
;; (spell-word-2 "length") ; t
;; (spell-word-2 "lenght") ; nil

(defun spell-word (word)
  (with-temp-buffer
    (save-excursion
      (insert word) )
    (condition-case nil
        (not (ispell-word))
      (error nil) )))
;; (spell-word "length") ; t
;; (spell-word "lenght") ; nil

Maybe spell-word-2, using `ispell-lookup-words', is faster as
you say, but something is different because with the
permutation use case and code previously discussed [1] this

  (string-perms-filter "pigelsen")

only returns "sleeping". With my old spell-word both are
returned, i.e. ("peelings" "sleeping") - no idea why actually,
I'll leave it to my subconscious to figure out God willing ...

[1] https://dataswamp.org/~incal/emacs-init/perm.el

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

[Prev in Thread] Current Thread [Next in Thread]