all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Testing validity of a word
@ 2023-07-26  0:21 uzibalqa
  2023-07-26  1:33 ` [External] : " Drew Adams
  2023-07-26 12:06 ` Emanuel Berg
  0 siblings, 2 replies; 10+ messages in thread
From: uzibalqa @ 2023-07-26  0:21 UTC (permalink / raw)
  To: uzibalqa via Users list for the GNU Emacs text editor


I want to test whether a word is valid. Is there a package in Emacs for dictionary word lookup ?

Have constructed something like this, but of course the function lookup-word does not exist.

(defun is-valid-word (word)
  "Check if the WORD is valid using the Emacs dictionary."
  (let ((dict-info (lookup-word word)))
    (if (plist-get dict-info :found)
        t ; The word is valid.
      nil))) ; The word is not valid.

Is there a package in Emacs for dictionary word lookup ?




^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [External] : Testing validity of a word
  2023-07-26  0:21 Testing validity of a word uzibalqa
@ 2023-07-26  1:33 ` Drew Adams
  2023-07-26  1:40   ` uzibalqa
  2023-07-26  2:32   ` uzibalqa
  2023-07-26 12:06 ` Emanuel Berg
  1 sibling, 2 replies; 10+ messages in thread
From: Drew Adams @ 2023-07-26  1:33 UTC (permalink / raw)
  To: uzibalqa, uzibalqa via Users list for the GNU Emacs text editor

> Is there a package in Emacs for dictionary word lookup ?
 
Maybe have a look at the links here, under "Dictionaries".  There seem to be a dozen or so.

https://www.emacswiki.org/emacs/CategoryInterface


^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [External] : Testing validity of a word
  2023-07-26  1:33 ` [External] : " Drew Adams
@ 2023-07-26  1:40   ` uzibalqa
  2023-07-26  2:27     ` uzibalqa
  2023-07-26  4:21     ` Drew Adams
  2023-07-26  2:32   ` uzibalqa
  1 sibling, 2 replies; 10+ messages in thread
From: uzibalqa @ 2023-07-26  1:40 UTC (permalink / raw)
  To: Drew Adams; +Cc: uzibalqa via Users list for the GNU Emacs text editor


------- Original Message -------
On Wednesday, July 26th, 2023 at 1:33 PM, Drew Adams <drew.adams@oracle.com> wrote:


> > Is there a package in Emacs for dictionary word lookup ?
> 
> 
> Maybe have a look at the links here, under "Dictionaries". There seem to be a dozen or so.
> 
> https://www.emacswiki.org/emacs/CategoryInterface

Any recommendations ?



^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [External] : Testing validity of a word
  2023-07-26  1:40   ` uzibalqa
@ 2023-07-26  2:27     ` uzibalqa
  2023-07-26  4:21     ` Drew Adams
  1 sibling, 0 replies; 10+ messages in thread
From: uzibalqa @ 2023-07-26  2:27 UTC (permalink / raw)
  To: uzibalqa
  Cc: Drew Adams, uzibalqa via Users list for the GNU Emacs text editor

------- Original Message -------
On Wednesday, July 26th, 2023 at 1:40 PM, uzibalqa <uzibalqa@proton.me> wrote:


> ------- Original Message -------
> On Wednesday, July 26th, 2023 at 1:33 PM, Drew Adams drew.adams@oracle.com wrote:
> 
> 
> 
> > > Is there a package in Emacs for dictionary word lookup ?
> > 
> > Maybe have a look at the links here, under "Dictionaries". There seem to be a dozen or so.
> > 
> > https://www.emacswiki.org/emacs/CategoryInterface
> 
> 
> Any recommendations ?

Have been looking at using ispell.  Would that be a good strategy ?




^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [External] : Testing validity of a word
  2023-07-26  1:33 ` [External] : " Drew Adams
  2023-07-26  1:40   ` uzibalqa
@ 2023-07-26  2:32   ` uzibalqa
  1 sibling, 0 replies; 10+ messages in thread
From: uzibalqa @ 2023-07-26  2:32 UTC (permalink / raw)
  To: Drew Adams; +Cc: uzibalqa via Users list for the GNU Emacs text editor






Sent with Proton Mail secure email.

------- Original Message -------
On Wednesday, July 26th, 2023 at 1:33 PM, Drew Adams <drew.adams@oracle.com> wrote:


> > Is there a package in Emacs for dictionary word lookup ?
> 
> 
> Maybe have a look at the links here, under "Dictionaries". There seem to be a dozen or so.
> 
> https://www.emacswiki.org/emacs/CategoryInterface

Have taken the ispell route.  But I got into the difficulty of 

(error "Marker points into wrong buffer" #<marker at 1 in  *temp*>)

Furthermore I am not sure whether the method is efficient.

(defun is-valid-word (word)
  "Check if the WORD is valid using `ispell`."
  (let ((original-buffer (current-buffer)))
    (with-temp-buffer
      (insert word)
      (ispell-word)
      (not (eq (current-buffer) original-buffer)))))




^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [External] : Testing validity of a word
  2023-07-26  1:40   ` uzibalqa
  2023-07-26  2:27     ` uzibalqa
@ 2023-07-26  4:21     ` Drew Adams
  1 sibling, 0 replies; 10+ messages in thread
From: Drew Adams @ 2023-07-26  4:21 UTC (permalink / raw)
  To: uzibalqa; +Cc: uzibalqa via Users list for the GNU Emacs text editor

> > Maybe have a look at the links here, under "Dictionaries". There seem to
> be a dozen or so.
> >
> >
> https://www.emacswiki.org/emacs/CategoryInterface
> 
> Any recommendations ?

Not from me.  I don't use any of them.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Testing validity of a word
  2023-07-26  0:21 Testing validity of a word uzibalqa
  2023-07-26  1:33 ` [External] : " Drew Adams
@ 2023-07-26 12:06 ` Emanuel Berg
  2023-07-26 17:08   ` uzibalqa
  1 sibling, 1 reply; 10+ messages in thread
From: Emanuel Berg @ 2023-07-26 12:06 UTC (permalink / raw)
  To: help-gnu-emacs

uzibalqa wrote:

> I want to test whether a word is valid. Is there a package
> in Emacs for dictionary word lookup ?

(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

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




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Testing validity of a word
  2023-07-26 12:06 ` Emanuel Berg
@ 2023-07-26 17:08   ` uzibalqa
  2023-07-26 17:45     ` Emanuel Berg
  2023-07-26 19:07     ` Emanuel Berg
  0 siblings, 2 replies; 10+ messages in thread
From: uzibalqa @ 2023-07-26 17:08 UTC (permalink / raw)
  To: Emanuel Berg; +Cc: help-gnu-emacs

------- Original Message -------
On Thursday, July 27th, 2023 at 12:06 AM, Emanuel Berg <incal@dataswamp.org> wrote:


> uzibalqa wrote:
> 
> > I want to test whether a word is valid. Is there a package
> > in Emacs for dictionary word lookup ?
> 
> 
> (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
> 
> --
> underground experts united
> https://dataswamp.org/~incal

The following could be less intensive

(defun is-valid-word (word)
  "Check if the WORD is valid using `ispell`."
  (ispell-lookup-words word))




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Testing validity of a word
  2023-07-26 17:08   ` uzibalqa
@ 2023-07-26 17:45     ` Emanuel Berg
  2023-07-26 19:07     ` Emanuel Berg
  1 sibling, 0 replies; 10+ messages in thread
From: Emanuel Berg @ 2023-07-26 17:45 UTC (permalink / raw)
  To: help-gnu-emacs

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))

You are right, maybe `ispell-lookup-words' didn't exist when
I wrote that ... should replace that, thanks.

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




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Testing validity of a word
  2023-07-26 17:08   ` uzibalqa
  2023-07-26 17:45     ` Emanuel Berg
@ 2023-07-26 19:07     ` Emanuel Berg
  1 sibling, 0 replies; 10+ messages in thread
From: Emanuel Berg @ 2023-07-26 19:07 UTC (permalink / raw)
  To: help-gnu-emacs

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




^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-07-26 19:07 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-26  0:21 Testing validity of a word uzibalqa
2023-07-26  1:33 ` [External] : " Drew Adams
2023-07-26  1:40   ` uzibalqa
2023-07-26  2:27     ` uzibalqa
2023-07-26  4:21     ` Drew Adams
2023-07-26  2:32   ` uzibalqa
2023-07-26 12:06 ` Emanuel Berg
2023-07-26 17:08   ` uzibalqa
2023-07-26 17:45     ` Emanuel Berg
2023-07-26 19:07     ` Emanuel Berg

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.