all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Additional dict server for dictionary.el
@ 2008-10-29 21:17 Sven Bretfeld
  0 siblings, 0 replies; 5+ messages in thread
From: Sven Bretfeld @ 2008-10-29 21:17 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 568 bytes --]

Hello to all

I'm just discovering dictionary.el. 

I cannot find instructions on how to add a dict server additionally to
the default dict.org. There is a server providing a dictionary I would
really like to use, but I don't want to lose access to dict.org. To
complicate things, that server uses port 2629 instead of the usual
2628. This is, of course, not working:

(setq dictionary-server "indica-et-buddhica.org")
(setq dictionary-port 2629)

because, then, only the dictionaries on that server are available.

What can I do?

Greetings

Sven

[-- Attachment #2: Type: application/pgp-signature, Size: 188 bytes --]

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

* Re: Additional dict server for dictionary.el
       [not found] <mailman.2428.1225315094.25473.help-gnu-emacs@gnu.org>
@ 2008-10-30 22:27 ` Xah
  2008-10-30 23:45   ` Xah
  0 siblings, 1 reply; 5+ messages in thread
From: Xah @ 2008-10-30 22:27 UTC (permalink / raw)
  To: help-gnu-emacs

On Oct 29, 2:17 pm, Sven Bretfeld <sven.bretf...@gmx.ch> wrote:
> Hello to all
>
> I'm just discovering dictionary.el.
>
> I cannot find instructions on how to add a dict server additionally to
> the default dict.org. There is a server providing a dictionary I would
> really like to use, but I don't want to lose access to dict.org. To
> complicate things, that server uses port 2629 instead of the usual
> 2628. This is, of course, not working:
>
> (setq dictionary-server "indica-et-buddhica.org")
> (setq dictionary-port 2629)
>
> because, then, only the dictionaries on that server are available.
>
> What can I do?

i also use “dictionary.el”, but i haven't several others. In
particular, i note there's a http://sourceforge.net/projects/dictem .
There are several others last discussed here, you might try emacswiki.

If you run customize-group, then “dictionary”, you'll find there's a
field to change the server and port. Not sure it can add servers as
you asked.

i'd like to set the default dict to just WordNet, 1913 Websters, and
Moby Thesaurus. However, its documention doesn't mention how.

if you run customize-group, there's default dict you can set. But it's
not clear what's the available dicts, what's the proper keyword for
them, and what's the proper syntax to use.

When doing the “[Select Dictionary]” in dictionary-mode, among the
lists are:

wn: WordNet (r) 2.0
moby-thes: Moby Thesaurus II by Grady Ward, 1.0

so, apparently, “wn” and “moby-thes” are the keywords, however, it
seems to be mising the 1913 Webster. (i want the unmodified 1913
Webster, not the “The Collaborative International Dictionary of
English” (gcide) that's derived from it. (The “1913 Webster” are often
available from other open source dict clients, such as Omni dict on
the Mac.))

also, i find it annoying that when you lookup a word, it switches the
cursor to the newly created dict panel. This is contrary to
conventional behavior.

Note: i have:

(global-set-key (kbd "<kp-0>") 'dictionary-lookup-definition)
(global-set-key (kbd "<S-kp-0>") 'lookup-word-definition-in-w3m)
(global-set-key (kbd "<C-kp-0>") 'lookup-wikipedia)

--------------

there are few problems with open source dictionaries...

• for example, it requires to use the singular form to find the right
word. (e.g. try search for “chairs”) This is a major pain.

• problem with phonetic system. e.g. it often uses some idiosyncratic
made-up pronunciation system (typical of American dicts) as opposed to
IPA. (For a comparison of major US dicts on pron system, see: English
Phonetics at http://xahlee.org/Periodic_dosage_dir/bangu/voksa_sinxa_ciste.html
) Worse is that ascii is used to emulate pronunciation symbols, makes
it hard to understand.

• Problem with accented letters. e.g. you can't lookup words with a
accented letter such as touché, précis, élan, lycée, passé, ... etc.

• also, often there are 2 results from “The Collaborative
International Dictionary of English”, apparently of the same version
but they differ slightly in content. e.g. lookup “precis”, then it
gives:

«From The Collaborative International Dictionary of English v.0.48
[gcide]:

Pr'ecis \Pr['e]`cis"\ (pr[asl]`s[=e]"), n. [F. See Precise.]
   A concise or abridged statement or view; an abstract; a
   summary.
   [1913 Webster]

From The Collaborative International Dictionary of English v.0.48
[gcide]:

precis \precis\ v. t.
   To make a precis of.
   [WordNet 1.5]
»

• Of course, the definition quality and vocabulary size is often not
comparable to commercial dicts.

-----------------

occationally i use wiktionary
( http://en.wiktionary.org/wiki/Wiktionary:Main_Page )
particularly good if you are looking up chinese chars for its
traditional/simpified version, english translation, code points, uses
in Japanese and Korean, classification of input under several input
systems.

e.g. http://en.wiktionary.org/wiki/反

does wiktionary support server request?

-----------------------

i have some code for looking up references that might be of interest.

(defun lookup-wikipedia ()
"Look up the word's in Wikipedia.\n
This command generates a url for Wikipedia.com and switches
you to browser.
If a region is active (a phrase), lookup that phrase."
 (interactive)
 (let (myword myurl)
   (setq myword
         (if (and transient-mark-mode mark-active)
             (buffer-substring-no-properties (region-beginning)
(region-end))
           (thing-at-point 'symbol)))

  (setq myword (replace-regexp-in-string " " "_" myword))
  (setq myurl (concat "http://en.wikipedia.org/wiki/" myword))
  (shell-command (concat "open -a opera " myurl))
   ;; (browse-url myurl)
   ))


the following lookup word def in a commercial dict based on the web,
using w3m interface. You can modify it so it fires up a browser
instead. (advantage using real browser that you get voice recoded
pronunciation, easier to read, and faster load etc.)

(defun lookup-word-definition-in-w3m ()
"Look up the word's definition in a emacs-w3m.\n
If a region is active (a phrase), lookup that phrase."
 (interactive)
 (let (myword myurl)
   (setq myword
         (if (and transient-mark-mode mark-active)
             (buffer-substring-no-properties (region-beginning)
(region-end))
           (thing-at-point 'symbol)))

  (setq myword (replace-regexp-in-string " " "%20" myword))
  (setq myurl (concat "http://www.answers.com/main/ntquery?s="
myword))
  (w3m-browse-url myurl)
   ))

See also:
• A Review of 3 Dictionaries
http://xahlee.org/Periodic_dosage_dir/bangu/dict_review.html

• English vocabulary compendium
http://xahlee.org/PageTwo_dir/Vocabulary_dir/vocabulary.html

  Xah
∑ http://xahlee.org/^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Additional dict server for dictionary.el
  2008-10-30 22:27 ` Additional dict server for dictionary.el Xah
@ 2008-10-30 23:45   ` Xah
  2008-11-01 10:36     ` Xah
  0 siblings, 1 reply; 5+ messages in thread
From: Xah @ 2008-10-30 23:45 UTC (permalink / raw)
  To: help-gnu-emacs

PS just played with customize-group and “dictionary”. You can set the
default dict to one of “wn”, “web1913” or “moby-thes”. That will
lookup using that one particular dict.

is there a way to set a list of dicts to use?

  Xah
∑ http://xahlee.org/^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Additional dict server for dictionary.el
  2008-10-30 23:45   ` Xah
@ 2008-11-01 10:36     ` Xah
  2008-11-03 22:43       ` Xah
  0 siblings, 1 reply; 5+ messages in thread
From: Xah @ 2008-11-01 10:36 UTC (permalink / raw)
  To: help-gnu-emacs

Some more info ...

i took a look at the alternative emacs dict client
http://sourceforge.net/projects/dictem
it turns out that this is merely a wrapper to a real command line
client, and is actually orginially based on “dictionary.el”.

this is kinda disappointing. I guess it tries to improve
“dictionary.el” but throws real meat, the actual real dict client,
out.

--------------

i wrote to the author of dictionary.el Torsten Hilbrich. Here's what
he says:

«
There is currently no way to use more than one dictionary server.

You could however locally modify dictionary-server in a self-written
lisp function like:

(defun search-in-1913 (word)
  (interactive (list (read-string "Search word: " (current-word))))
  (let ((dictionary-server "dict.org"))
    (dictionary-search word "web1913")))

Replace dict.org with the server you use for this dictionary.
»

«Regarding the window change you mentioned in the thread. Here is a
function you could use in replacement of dictionary-search to get the
behaviour you prefer:

(defun dictionary-search-other-window (word &optional dictionary)
  (interactive
   (list (read-string "Search word: " (current-word))
	 (if current-prefix-arg
	     (read-string "Dictionary: " dictionary-default-dictionary)
	   dictionary-default-dictionary)))
  (let ((dictionary-use-single-buffer t))
      (dictionary-search word dictionary)
      (other-window 1)))

It switches back to the original window and also let dictionary use a
single window to avoid recreating a new dictionary buffer for each
request.
»

----------------------------

i did some digging of the source code. So, effectively you can just do
this:

(dictionary-new-search (cons "fancy" "wn")) ; look up word in WordNet
(dictionary-new-search (cons "fancy" "web1913"))  ; look up word in
webster 1913

or

(dictionary-do-search "fancy" "web1913" 'dictionary-display-search-
result)

the dictionary-display-search-result function will take the result and
format it and display in buffer. But i haven't spent enough time to
figure out what's the format passed to dictionary-display-search-
result.

in anycase, here's a code that does lookup on current word. It
different than dictionary-lookup-definition in that if you have a text
selection, it'll use that phrase to lookup. This is convenient because
quite often emacs's (current-word) does not really pickup the word you
want. Including phrases or idioms that has a dict entry but has a
space in them. The other change is that the cursor remains where it
is.

(defun lookup-word-def ()
"Look up the word's definition in Webster 1913
If a region is active (a phrase), lookup that phrase."
 (interactive)
 (let (myword myurl)
   (setq myword
         (if (and transient-mark-mode mark-active)
             (buffer-substring-no-properties (region-beginning)
(region-end))
           (thing-at-point 'symbol)))
   (require 'dictionary)
   (dictionary-new-search (cons myword "web1913"))
; (dictionary-new-search (cons "fancy" "moby-thes"))
; (dictionary-new-search (cons "fancy" "wn"))
; (dictionary-do-search "fancy" "web1913" 'dictionary-display-search-
result)
   (other-window 1)
   ))

you could define several of these and assign them each to a shortcut.
e.g. the 0 on keypad, shift-0, ctrl+0, for looking up diff dicts...

ideally, i would like one press of a key and have the 3 dicts i want
(webster 1913, wordnet, moby thes) all combined in one output. This
means i'll have to figure out the format used in dictionary-display-
search-result... but currently not priority.

PS it odd that the dict protocol does not seem to allow client to
specify a _list_ of dicts to use, but it has a “*” to mean what i
presume ALL dict that's available on the server.

  Xah
∑ http://xahlee.org/^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Additional dict server for dictionary.el
  2008-11-01 10:36     ` Xah
@ 2008-11-03 22:43       ` Xah
  0 siblings, 0 replies; 5+ messages in thread
From: Xah @ 2008-11-03 22:43 UTC (permalink / raw)
  To: help-gnu-emacs


i took some time to solve problem about “dictionary.el”.

Now, with the following customized command, one can now effectively
select a set of dictionaries as the default dicts to lookup, with
their results in one pane. The cursor stays in the original pane. And
if the word under cursor is plural, e.g. chairs, or a phrase (e.g.
“Union Jack”), you can select parts of the word or phrase, and the
lookup will use that text selection.

Here's the code:

(defun lookup-word-def ()
  "Look up current word's definition in WordNet, Webster 1913, Moby
Thesaurus.
If there is a text selection (a phrase), lookup that phrase.
This command needs “dictionary.el” installed."
 (interactive)
 (let (myword myurl meat navigText pos)
   (setq myword
         (if (and transient-mark-mode mark-active)
             (buffer-substring-no-properties (region-beginning)
(region-end))
           (thing-at-point 'symbol)))
   (require 'dictionary)
   ;; (dictionary-do-search "fancy" "web1913" 'dictionary-display-
search-result)
   (dictionary-new-search (cons myword "wn"))
   (setq meat (buffer-substring (point-min) (point-max)))

   (dictionary-new-search (cons myword "web1913"))
   (setq meat (concat meat (buffer-substring (point-min) (point-
max))))

   (dictionary-new-search (cons myword "moby-thes"))
   (setq meat (concat meat (buffer-substring (point-min) (point-
max))))

   (switch-to-buffer "*my dict results*")
   (erase-buffer)
   (dictionary-mode)
   (insert meat)
   (goto-char 1) (next-line 2)
   (setq pos (point))

   (setq navigText (buffer-substring 1 pos))

   (goto-char 1)
   ;; remove navigation text
   (while
       (search-forward
        "[Back] [Search Definition]         [Matching words]
[Quit]
       [Select Dictionary]         [Select Match Strategy]
" nil t
        )
     (replace-match
"-----------------------------------------------------------------" t
t))

   ;; remove message about how many def found. e.g. “1 definition
found”.
   (goto-char 1)
   (while
       (search-forward-regexp "[0-9]+ definitions* found\n\n" nil t)
     (replace-match "" t t))

   (goto-char (point-max))
   (insert navigText)
   (goto-char 1)
   (other-window 1)
   ))


The major content of this thread is now cleaned up and summarized as a
tutorial and a essay at:

• Dictionary and Reference Lookup with Emacs
http://xahlee.org/emacs/emacs_lookup_ref.html

• Problems of Open Source Dictionaries
http://xahlee.org/Periodic_dosage_dir/bangu/dict_open_source_probs.html

  Xah
∑ http://xahlee.org/^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-11-03 22:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.2428.1225315094.25473.help-gnu-emacs@gnu.org>
2008-10-30 22:27 ` Additional dict server for dictionary.el Xah
2008-10-30 23:45   ` Xah
2008-11-01 10:36     ` Xah
2008-11-03 22:43       ` Xah
2008-10-29 21:17 Sven Bretfeld

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.