3/21/2008


Traducción de palabras con dict en Gnu/Linux!

Dict, es un cliente para el servidor de diccionarios(DICTD). Quién realiza una transacción TCP basada en petición/respuesta que permite a un cliente acceder a definiciones de diccionario, por medio de bases de datos de lenguajes naturales.
La mayoría de las distribuciones lo incluyen en su paquete base, pero si no lo tiene pueden instalarlo como dictd o dict.
Para la traducción de palabrás es necesario contar con una conexión a internet.

En Arch:

pacman -S dictd

Comandos básicos de Dict:

[braianet@ArchLinux ~]$ dict --help
dict 1.9.15/rf on Linux 2.6.24-ARCH
Copyright 1997-2002 Rickard E. Faith (faith@dict.org)

Usage: dict [options] [word]
Query a dictd server for the definition of a word

-h --host (server) specify server
-p --port specify port
-d --database select a database to search
-m --match match instead of define
-s --strategy strategy for matching or defining
-c --config specify configuration file
-C --nocorrect disable attempted spelling correction
-D --dbs show available databases
-S --strats show available search strategies
-H --serverhelp show server help
-i --info show information about a database
-I --serverinfo show information about the server
-a --noauth disable authentication
-u --user username for authentication
-k --key shared secret for authentication
-V --version display version information
-L --license display copyright and license information
--help display this help
-v --verbose be verbose
-r --raw trace raw transaction
-P --pager program specify program to use as pager (- for none)
--debug set debugging flag
--pipesize specify buffer size for pipelining (256)
--client additional text for client command
[braianet@ArchLinux ~]$


Si por ejemplo ejecuto dict y paso como parámetro "speak", me aparecería lo siguiente:

braianet ~ $ dict speak
4 definitions found

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

Speak \Speak\, v. i. [imp. {Spoke}({Spake}Archaic); p. p.
{Spoken}({Spoke}, Obs. or Colloq.); p. pr. & vb. n.
{Speaking}.] [OE. speken, AS. specan, sprecan; akin to
OF.ries. spreka, D. spreken, OS. spreken, G. sprechen, OHG.
sprehhan, and perhaps to Skr. sph[=u]rj to crackle, to
thunder. Cf. {Spark} of fire, {Speech}.]
1. To utter words or articulate sounds, as human beings; to
express thoughts by words; as, the organs may be so
obstructed that a man may not be able to speak.
[1913 Webster]

Till at the last spake in this manner. --Chaucer.
[1913 Webster]

Speak, Lord; for thy servant heareth. --1 Sam. iii.
9.
[1913 Webster]

2. To express opinions; to say; to talk; to converse.
[1913 Webster]

That fluid substance in a few minutes begins to set,
as the tradesmen speak. --Boyle.
[1913 Webster]

An honest man, is able to speak for himself, when a
knave is not. --Shak.
[1913 Webster]

During the century and a half which followed the
Conquest, there is, to speak strictly, no English
history. --Macaulay.
[1913 Webster]
...

Como podemos observar es un diccionario, pero lamentablemente solamente da definiciones en inglés, pero podemos utilizar dict como un traductor español-inglés o inglés-español. Utilizamos el parámetro -D para listar todas las bases de datos disponibles.

braianet ~ $ dict -D
Databases available:
gcide The Collaborative International Dictionary of English v.0.48
wn WordNet (r) 2.0
moby-thes Moby Thesaurus II by Grady Ward, 1.0
elements Elements database 20001107
vera Virtual Entity of Relevant Acronyms (Version 1.9, June 2002)
jargon Jargon File (4.3.1, 29 Jun 2001)
foldoc The Free On-line Dictionary of Computing (27 SEP 03)
easton Easton's 1897 Bible Dictionary
hitchcock Hitchcock's Bible Names Dictionary (late 1800's)
bouvier Bouvier's Law Dictionary, Revised 6th Ed (1856)
devils THE DEVIL'S DICTIONARY ((C)1911 Released April 15 1993)
world02 CIA World Factbook 2002
gazetteer U.S. Gazetteer (1990)
gaz-county U.S. Gazetteer Counties (2000)
gaz-place U.S. Gazetteer Places (2000)
gaz-zip U.S. Gazetteer Zip Code Tabulation Areas (2000)
--exit-- Stop default search here.
afr-deu Africaan-German Freedict dictionary
afr-eng Africaan-English Freedict Dictionary
ara-eng English-Arabic Freedict Dictionary
cro-eng Croatian-English Freedict Dictionary
cze-eng Czech-English Freedict dictionary
dan-eng Danish-English Freedict dictionary
deu-eng German-English Freedict dictionary
deu-fra German-French Freedict dictionary
deu-ita German-Italian Freedict dictionary
deu-nld German-Nederland Freedict dictionary
deu-por German-Portugese Freedict dictionary
eng-afr English-Africaan Freedict Dictionary
eng-ara English-Arabic FreeDict Dictionary
eng-cro English-Croatian Freedict Dictionary
eng-cze English-Czech fdicts/FreeDict Dictionary
eng-deu English-German Freedict dictionary
eng-fra English-French Freedict Dictionary
eng-hin English-Hindi Freedict Dictionary
eng-hun English-Hungarian Freedict Dictionary
eng-iri English-Irish Freedict dictionary
eng-ita English-Italian Freedict dictionary
eng-lat English-Latin Freedict dictionary
eng-nld English-Netherlands Freedict dictionary
eng-por English-Portugese Freedict dictionary
eng-rom English-Romanian FreeDict dictionary
eng-rus English-Russian Freedict dictionary
eng-spa English-Spanish Freedict dictionary
eng-swa English-Swahili xFried/FreeDict Dictionary
eng-swe English-Swedish Freedict dictionary
eng-tur English-Turkish FreeDict Dictionary
eng-wel English-Welsh Freedict dictionary
fra-deu French-German Freedict dictionary
fra-eng French-English Freedict dictionary
fra-nld French-Nederlands Freedict dictionary
hin-eng English-Hindi Freedict Dictionary [reverse index]
hun-eng Hungarian-English FreeDict Dictionary
iri-eng Irish-English Freedict dictionary
ita-deu Italian-German Freedict dictionary
jpn-deu Japanese-German Freedict dictionary
kha-deu Khasi-German FreeDict Dictionary
lat-deu Latin-German Freedict dictionary
lat-eng Latin-English Freedict dictionary
nld-deu Nederlands-German Freedict dictionary
nld-eng Nederlands-English Freedict dictionary
nld-fra Nederlands-French Freedict dictionary
por-deu Portugese-German Freedict dictionary
por-eng Portugese-English Freedict dictionary
sco-deu Scottish-German Freedict dictionary
scr-eng Serbo-Croat-English Freedict dictionary
slo-eng Slovenian-English Freedict dictionary
spa-eng Spanish-English Freedict dictionary
swa-eng Swahili-English xFried/FreeDict Dictionary
swe-eng Swedish-English Freedict dictionary
tur-deu Turkish-German Freedict dictionary
tur-eng Turkish-English Freedict dictionary
english English Monolingual Dictionaries
trans Translating Dictionaries
all All Dictionaries (English-Only and Translating)
web1913 Webster's Revised Unabridged Dictionary (1913)
world95 The CIA World Factbook (1995)
braianet ~ $

Listo ahora solo debemos seleccionar la base de datos que nos interese, como podrán ver tenemos varios base de datos de idiomas para seleccionar.
El parámetro -d selecciona.

Traductor español-inglés:

braianet ~ $ dict -d spa-eng hablar
1 definition found

From Spanish-English Freedict dictionary [spa-eng]:

hablar
speak, talk(paroli)
braianet ~ $

Traductor inglés-español:

braianet ~ $ dict -d eng-spa speak
1 definition found

From English-Spanish Freedict dictionary [eng-spa]:

speak [spiːk]
hablar
braianet ~ $

Simplificando los comandos anteriores, crearemos alias para llamarlos sencillamente desde la consola, agregamos las siguientes líneas a ~/.bashrc.

alias ing-esp='dict -d eng-spa'
alias esp-ing='dict -d spa-eng'

Luego reiniciamos la terminal y probamos:

Ing-Esp

braianet ~ $ ing-esp speak
1 definition found

From English-Spanish Freedict dictionary [eng-spa]:

speak [spiːk]
hablar

Esp-Ing

braianet ~ $ esp-ing hablar

1 definition found

From Spanish-English Freedict dictionary [spa-eng]:

hablar
speak, talk(paroli)
braianet ~ $

Si el diccionario que necesitan no está en la base de datos de dict.org, pueden buscar en otros servidores dict.
dict://vocabulary.aioe.org
posee una gran cantidad de diccionarios
Deberán utilizar el parámetro -h para usarlo, -D lista las base de datos.

braianet ~ $ dict -h vocabulary.aioe.org -D


Por úlitmo, para no utilizar el parámetro -h, pueden agregar los servidores al archivo /etc/dict/dict.conf (en mi caso).

#server localhost
#server dict.org
server vocabulary.aioe.org

Espero que les resulte útil el uso, ya que a mí me simplificó bastante con la traducción de palabras, aunque no contengan mucha cantidad. Saludos!

0 comentarios: