有没有离线的命令行词典?

有没有命令行的离线词典?我知道有一些像StarDictArtha这样的,但是有没有一个在命令行中使用的呢?
另外,我尝试了dict,但它是一个在线词典。
7个回答

sdcvStardict 的控制台版本。

1. 安装字典

在终端中运行以下命令:

sudo apt-get install sdcv

2. 下载词典文件
根据您的需求,从以下来源下载词典文件。

3. 安装下载的词典

创建一个目录,让 sdcv 在其中寻找词典:

sudo mkdir -p /usr/share/stardict/dic/

下一个命令取决于下载的文件是一个 .gz 文件还是一个 .bz2 文件。
如果它是一个 .bz2 文件:
sudo tar -xvjf downloaded.tar.bz2 -C /usr/share/stardict/dic

如果是一个.gz文件:
sudo tar -xvzf downlaoded.tar.gz -C /usr/share/stardict/dic

4. 完成!

要搜索一个单词,请使用:

sdcv word

enter image description here


3标记并且+1给安装指南 - PALEN
太棒了!谢谢你提供的信息性回答! - SirCharlo
很高兴能帮到你 :) - green
你可以从软件包中安装词典,例如类似于 stardict-dic-en 的东西。如果你安装了 Stardict 的图形界面版本(例如 stardict),你可能会自动获得英语词典。 - alfC
还有其他一些下载链接,bigdictgoogle-stardict - Cloverr
如何解决这个问题:“mkdir: /usr/share/stardict/dic/: 操作不允许”? - Inquisitive

简单的离线dictd安装

原因

使用离线词典时,dict命令非常方便。只需将dictd守护进程及其依赖项与本地的离线词典一起安装即可。这比在本页面其他地方建议的安装sdcv要简单得多。

安装

下面展示了如何安装dictd以及全面的英语词典dict-gcide。标准软件源中还有许多其他词典可供选择。

$ sudo apt-get install dict dictd dict-gcide

用法

$ dict word

 3 definitions found

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

      Word \Word\, n. [AS. word; akin to OFries. & OS. word, D. woord,
         G. wort, Icel. or[eth], Sw. & Dan. ord, Goth. wa['u]rd,
         OPruss. wirds, Lith. vardas a name, L. verbum a word; or
         perhaps to Gr. "rh`twr an orator. Cf. {Verb}.]
         [1913 Webster]
         1. The spoken sign of a conception or an idea; an articulate
            or vocal sound, or a combination of articulate and vocal
            sounds, uttered by the human voice, and by custom
            expressing an idea or ideas; a single component part of
            human speech or language; a constituent part of a
            sentence; a term; a vocable. "A glutton of words." --Piers
            Plowman.
            [1913 Webster]

                  You cram these words into mine ears, against
                  The stomach of my sense.              --Shak.
            [1913 Webster]

                  Amongst men who confound their ideas with words,
                  there must be endless disputes.       --Locke.
            [1913 Webster]

         2. Hence, the written or printed character, or combination of
            characters, expressing such a term; as, the words on a
            page.
            [1913 Webster]

         3. pl. Talk; discourse; speech; language.
            [1913 Webster]

1这里链接的网页指向更多词典似乎已经损坏。这是一个存档副本:https://web.archive.org/web/20180816203245/http://xmodulo.com/how-to-look-up-dictionary-via-command-line-on-linux.html - Julian

你可能也安装了aspell,它有一个优点,可以为拼写错误的单词提供建议。你可以直接在文本文件上调用aspell:
aspell check text.txt

或者只在一个单词上使用它:
echo wrd | aspell -a

2如果尚未安装,请执行以下命令:sudo apt-get install aspell aspell-es(用于安装程序和西班牙语词典)。 - hoijui

如果你只是想查看一个单词是否拼写正确或者存在,你可以使用 grep 来搜索 /usr/share/dict/ 目录下的单词列表文件,这些文件是由相应的 wordlist 软件包提供的。以下是一个例子,用来判断 "emu" 是否是一个有效的单词:

grep -i "^emu$" /usr/share/dict/american-english

那没有任何定义。

其实,我在寻找定义... - PALEN
你不需要单引号或者\$吗? - John P

你可以使用免费的字典通过dict命令:

  • 首先通过sudo apt-get install dictd安装。
  • 找出你想要使用的语言字典,可以通过sudo apt-cache search "dict-freedict"查找。
  • 找到这些名称后,安装它们(例如:sudo apt-get install dict-freedict-eng-tur)。
  • 检查已安装的语言:dict -D
  • 使用方法:dict "word"
  • 特定用法:dict -d fd-eng-tur "word"

要不要从网站上下载字典文本文件,例如this link警告:4.5 MB),然后使用类似于grep "word" dictionary.txt的命令来查找文本。

或者也可以使用VIM编辑器通过其命令/Word搜索单词。按下nN键可以找到单词的下一个或上一个出现位置,这样更有趣并且可以找到单词的含义。


我使用了普林斯顿大学的WordNet应用程序。我不想处理Tcl/Tk,所以准备了一个make文件,可以让你将WN作为命令行应用程序运行。你需要编译它,但我提供了一些帮助说明。对于我来说,在我的Linux计算机上弹出一个终端并键入"wn unknown-word -over"以获取unknown-word的定义非常方便。WordNet的好处是,如果你需要,你可以获得同义词,反义词和其他语言细微差别。这是我的github下载链接: Dalton Bentley WordNet命令版本的github链接 顺便说一下,我还编辑了所有普林斯顿语言帮助文件,制作成一份合理的PDF文档,对于那些对更高级功能感兴趣的人来说,会很有帮助。