文章目录

  • shell_命令行查单词/shell英文词典工具包(dict/trans/wd)
    • references
    • 离线方案:
      • sdcv
      • dict
        • 官方网站
          • 词典数据来源
        • 查看已安装的可用数据库
        • 短语匹配
        • 词典性能
          • 自动化服务检查脚本+阅读器
        • 搜索可用词典
        • 安装某个词典
        • dictd服务启动
        • dictd 获取帮助
          • dictd 配置文件
        • 检查本地安装的词库
    • translate-shell(在线翻译)
      • 基本特性
      • 使用示例
        • 翻译单词
        • 翻译句子
      • 文档提纲
    • 排版优化版本(在线翻译/双语例句)
      • 安装使用(python3 based)

shell_命令行查单词/shell英文词典工具包(dict/trans/wd)

  • 由于平时阅读英文文献/文档的时候经常需要查词

  • 而自己的工作环境又恰好是命令行,因此希望能够有一种命令行词典共学习使用

references

  • software recommendation - Is there an offline command-line dictionary? - Ask Ubuntu
  • command line - Is it possible to translate words via terminal? - Ask Ubuntu
  • Shell/Terminal: 命令行词典, 命令行字典, 命令行英汉字典, translate shell, 命令行查词工具, 终端字典 (ikeepstudying.com)
  • Linux终端下查单词(极简)

离线方案:

sdcv

  • 性能好,支持牛津/朗文等词典
  • 国内可能下载不下来词典
# cxxu @ CxxuWin11 in /usr/share/stardict/dic [16:42:51]
譬如搜索单词"contribute"
$ sdcv contribute
Found 2 items, similar to contribute.
###朗文结果
-->Longman Dictionary of Contemporary English
-->contributev   [Date: 1500-1600; Language: Latin; Origin: , past participle of  contribuere, from  com- (  COM-) +  tribuere (  TRIBUTE)]//1 [I and T] to give money, help, ideas etc to something that a lot of other people are also involved in:  contribute to/towards//  --City employees cannot contribute to political campaigns.//  contribute sth to/towards sth//  --The volunteers contribute their own time to the project.//2 [I] to help to make something happen:  --Stress is a contributing factor in many illnesses.//  contribute to//  --Alcohol contributes to 100,000 deaths a year in the US.//  contribute substantially/significantly/greatly etc to sth //  --Enya's success has contributed substantially to the current interest in Celtic music.//3 [I and T] to write articles, stories, poems etc for a newspaper or magazine:    contributor//  contribute to//  --one of several authors contributing to the book//
###牛津结果
-->Oxford Advanced Learner's Dictionary
-->contributeverb1  ~ (sth) (to / towards sth) to give sth, especially money or goods, to help sb/sth:
[VN] The writer personally contributed 」5 000 to the earthquake fund. * [V] Would you like to contribute to our collection? * Do you wish to contribute?2  [V] ~ (to sth) to be one of the causes of sth:
Medical negligence was said to have contributed to her death. * Human error may have been a contributing factor.3  ~ (sth) to sth to increase, improve or add to sth:
[V] Immigrants have contributed to British culture in many ways. * [VN] This book contributes little to our understanding of the subject.4  ~ (sth) (to sth) to write things for a newspaper, magazine, or a radio or television programme; to speak during a meeting or conversation, especially to give your opinion:
[VN] She contributed a number of articles to the magazine. * [V] He contributes regularly to the magazine 'New Scientist'. * We hope everyone will contribute to the discussion.

dict

官方网站

  • dict.org官方网站,在线版本
词典数据来源

支持多语言,但是不支持中文

  • 默认英英词典
  • How to look up dictionary via command line on Linux - Xmodulo (archive.org)

  • sudo apt install dict dictd dict-gcide

    • 较新版本中,仅安装dict似乎也可以用(但是内置词典较多,性能不佳)

    • ┌─[cxxu@CxxuWin11] - [/mnt/c/Users/cxxu] - [2022-04-13 03:54:35]
      └─[0] <> dpkg -l dict*|grep ii
      ii  dict             1.13.0+dfsg-1 amd64        dictionary client
      ii  dict-devil       1.0-13.1      all          "The Devil's Dictionary" by Ambrose Bierce
      ii  dict-gcide       0.48.5+nmu2   all          Comprehensive English Dictionary
      ii  dict-wn          1:3.0-37      all          electronic lexical database of English language for dict
      ii  dictd            1.13.0+dfsg-1 amd64        dictionary server
      ii  dictzip          1.13.0+dfsg-1 amd64        compression utility for dictionary databases
      
    • 可见上述安装将安装词典客户端dict词典服务dictd(daemon)

    • 词典数据库dict-gcide

      • 不同数据库可以对应有不同的语言(英->法)

      • 有些词典可能默认安装dict-wn(wordNet)

      • 查看可安装的词典(数据库)apt-cache policy dict*|less

查看已安装的可用数据库

如果dictd服务没有启动,且尚未显示安装某个词典,那么会列出所有词典名称(联网查询)

  • dict -D|less

  • ┌─[cxxu@CxxuWin11] - [/mnt/c/Users/cxxu] - [2022-04-13 03:58:51]
    └─[130] <> dict -D|less
    Databases available:gcide          The Collaborative International Dictionary of English v.0.48wn             WordNet (r) 3.0 (2006)moby-thesaurus Moby Thesaurus II by Grady Ward, 1.0elements       The Elements (07Nov00)vera           V.E.R.A. -- Virtual Entity of Relevant Acronyms (February 2016)jargon         The Jargon File (version 4.4.7, 29 Dec 2003)foldoc         The Free On-line Dictionary of Computing (30 December 2018)easton         Easton's 1897 Bible Dictionaryhitchcock      Hitchcock's Bible Names Dictionary (late 1800's)bouvier        Bouvier's Law Dictionary, Revised 6th Ed (1856)devil          The Devil's Dictionary (1881-1906)world02        CIA World Factbook 2002gaz2k-counties U.S. Gazetteer Counties (2000)gaz2k-places   U.S. Gazetteer Places (2000)gaz2k-zips     U.S. Gazetteer Zip Code Tabulation Areas (2000)fd-hrv-eng     Croatian-English FreeDict Dictionary ver. 0.1.2fd-fin-por     suomi-português FreeDict+WikDict dictionary ver. 2018.09.13fd-fin-bul     suomi-български език FreeDict+WikDict dictionary ver. 2018.09.13fd-fra-bul     français-български език FreeDict+WikDict dictionary ver. 2018.09.13fd-deu-swe     Deutsch-Svenska FreeDict+WikDict dictionary ver. 2018.09.13fd-fin-swe     suomi-Svenska FreeDict+WikDict dictionary ver. 2018.09.13.....
    
  • 或者

    • dict -I|less

    • ┌─[cxxu@cxxuAli] - [~] - [2022-04-13 04:06:07]
      └─[0] <> dict -Idictd 1.12.1/rf on Linux 4.15.0-175-genericOn cxxuAli: up 133.000, 3 forks (81.2/hour)Database      Headwords         Index          Data  Uncompressedgcide              203645       3859 kB         12 MB         38 MBmoby-thesaurus      30263        528 kB         10 MB         28 MB#另一台主机 ┌─[cxxu@CxxuWin11] - [/mnt/c/Users/cxxu] - [2022-04-13 04:02:07]
      └─[20] <> dict -Idictd 1.12.1/rf on Linux 4.19.0-10-amd64On dict.dict.org: up 485+15:43:20, 109918515 forks (9430.4/hour)Database      Headwords         Index          Data  Uncompressedgcide              203645       3859 kB         12 MB         38 MBwn                 147311       3002 kB       9247 kB         29 MBmoby-thesaurus      30263        528 kB         10 MB         28 MBelements              142          2 kB         17 kB         53 kBvera                12016        136 kB        213 kB        709 kBjargon               2314         40 kB        565 kB       1346 kBfoldoc              15170        301 kB       2215 kB       5423 kBeaston               3968         64 kB       1077 kB       2648 kBhitchcock            2619         34 kB         33 kB         85 kBbouvier              6797        128 kB       2338 kB       6185 kBdevil                1008         15 kB        161 kB        374 kBworld02               280          5 kB       1543 kB       7172 kBgaz2k-counties      12875        269 kB        280 kB       1502 kBgaz2k-places        51361       1006 kB       1711 kB         13 MBgaz2k-zips          33249        454 kB       2123 kB         15 MB--exit--                0          0 kB          0 kB          0 kBfd-hrv-eng          79814       1816 kB       1633 kB       4819 kBfd-fin-por          10755        190 kB        512 kB       1306 kBfd-fin-bul          10789        185 kB        525 kB       1348 kBfd-fra-bul          11009        182 kB        290 kB        793 kBfd-deu-swe          38957        730 kB       2348 kB       6102 kBfd-fin-swe          12309        221 kB        599 kB       1525 kB
      

短语匹配

tab 补全单词

┌─[cxxu@ubuntu] - [~] - [2022-04-13 03:44:53]
└─[0] <> dict make
make               make-believe       Make-peace         make-up
Make               Make-believe       Maker              makeup
Make\ and\ break   Maked              makeready          make\ water
Makebate           Make-game          make\ reparation   Makeweight
make-belief        make\ known        make\ reparations  make-work
make\ believe      Makeless           makeshift

词典性能

┌─[cxxu@cxxuAli] - [~] - [2022-04-13 04:00:00]
└─[0] <> dict -D
Databases available:gcide      The Collaborative International Dictionary of English v.0.48
  • 如果安装的词典很多,那么性能肯定是下降的
  • 建议仅安装需要的
自动化服务检查脚本+阅读器
  • 使用下方的bash 函数dl可以检查服务是否运行,如果没有运行,将尝试启动dictd服务
dl(){# 启动dictd服务来提供离线词典# sudo dictdpattern="dictd"if pgrep -x $pattern > /dev/nullthenecho "$pattern is Running"elseecho "$pattern Stopped,try to start $pattern"sudo dictdsleep 1ps u -C "dictd"fi# 使用less来阅读,避免一下子输出过多内容dict $1|less
}
┌─[cxxu@CxxuWin11] - [/mnt/d/repos/blogs] - [2022-04-18 01:22:27]
└─[0] <git:(main 7b33a7b✗✱✈) > dl contribute
dictd is Running

搜索可用词典

  • sudo apt-cache search "dict-"|grep ^dict-|less

    • 空格翻页

安装某个词典

  • 譬如,安装WordNet(包名:dict-*,对应wn则为dict-wn)
  • sudo apt install dict-wn

dictd服务启动

  • 确保dictd服务启动着,否则dict性能低下(貌似会联网请求)

    • ┌─[cxxu@ubuntu] - [~] - [2022-04-13 03:36:41]
      └─[0] <> ps aux|grep dictd
      dictd      12565  0.0  0.3  20604  6376 ?        Ss   03:34   0:00 dictd 1.12.1: 1/1
      cxxu       12596  0.0  0.0  17768   844 pts/0    S+   03:36   0:00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox dictd
      

      手动启动:sudo dictd

  • 如果使用dictd提供服务,那么,仅显式安装的词典数据库会被本地的快速检索

dictd 获取帮助

  • man dictd
dictd 配置文件
┌─[cxxu@ubuntu] - [~] - [2022-04-13 03:40:57]
└─[0] <> sudo vim /etc/dictd/                                                              colorit.conf        dictd.conf          dictd.order
dict.conf           dictdconfig.alias*

检查本地安装的词库

  • dict -I
    dict -D
    
  • ┌─[cxxu@ubuntu] - [~] - [2022-04-13 03:36:48]
    └─[0] <> dict -Idictd 1.12.1/rf on Linux 5.11.0-27-genericOn ubuntu: up 193.000, 2 forks (37.3/hour)Database      Headwords         Index          Data  Uncompressedgcide     203645       3859 kB         12 MB         38 MB┌─[cxxu@ubuntu] - [~] - [2022-04-13 03:37:42]
    └─[0] <> dict -D
    Databases available:gcide      The Collaborative International Dictionary of English v.0.48
    

translate-shell(在线翻译)

  • soimort/translate-shell: Command-line translator using Google Translate, Bing Translator, Yandex.Translate, etc. (github.com)

    • 由于是在线的,在支持的内容较为完善:

    • 可定制性强,支持各种模式

基本特性

  • 语种

  • 汉语拼音

  • 英文音标

  • 词性

  • 不加目标语言,则默认是英英词典

国内gitee 源优化安装

  • git clone https://gitee.com/mirrors/Translate-Shell.git
    cd Translate-Shell
    sudo apt install gawk
    make
    sudo make install

使用示例

翻译单词

  • trans :<target language code> <source:word to be translate>
# cxxu_kali @ CxxuWin11 in ~/Translate-Shell on git:develop o [16:14:31]
$  trans :zh apple
apple
/ˈapəl/苹果
(Píngguǒ)Definitions of apple
[ English -> 简体中文 ]noun苹果apple苹appleapple苹果, Apple

翻译句子

# cxxu_kali @ CxxuWin11 in ~/Translate-Shell on git:develop o [16:16:08]
$  trans :zh "I want to test the tool"
I want to test the tool我想测试这个工具
(Wǒ xiǎng cèshì zhège gōngjù)Translations of I want to test the tool
[ English -> 简体中文 ]I want to test the tool我想测试这个工具, 我想测试该工具

文档提纲

  1. Getting Started by Examples

    1. Translate a Word

      1. From any language to your language
      2. From any language to one or more specific languages
      3. From a specific language
    2. Translate Multiple Words or a Phrase
    3. Translate a Sentence
    4. Brief Mode
    5. Dictionary Mode
    6. Language Identification
    7. Text-to-Speech
    8. Terminal Paging
    9. Right-to-Left (RTL) Languages
    10. Pipeline, Input and Output
    11. Translate a File
    12. Translate a Web Page
    13. Language Details
    14. Interactive Translate Shell (REPL)
  2. Usage
  3. Code List

排版优化版本(在线翻译/双语例句)

  • 项目连接(gitee 加速)https://gitee.com/mirrors/wudao-dict.git

安装使用(python3 based)

  • for linux/mac wudao-dict

    • 分为两步

      • python依赖安装

        • 例如,对ubuntu

        • sudo apt-get install python3
          sudo apt-get install python3-pip
          sudo pip3 install bs4
          sudo pip3 install lxml
          
      • 项目clone

        • git clone https://gitee.com/mirrors/wudao-dict.git
          cd ./wudao-dict/wudao-dict
          sudo bash setup.sh #或者sudo ./setup.sh
          
  • 重新连接shell 以生效(zsh也生效)
  • 命令关键字/用法:wd <word to be translate>

linux_shell_命令行查单词/shell英文词典工具包(sdcv/dict/trans/wd)相关推荐

  1. Juniper防火墙命令行查错工具snoop的使用

    Juniper防火墙命令行查错工具snoop的使用 摘要:Snoop 是Juniper防火墙另外一个有效的查错工具,它和debug flow basic的区别是: snoop类似于在防火墙的接口上抓包 ...

  2. Linux(12)-命令行的使用,shell脚本

    命令行的使用,shell脚本 1.终端shell,man 2.shell 编程 2.1 shell脚本 2.2 注释 2.3 指明所用的shell 2.4 支持函数 2.5 使用变量 2.6 解析命令 ...

  3. linux初始:命令行解释器(shell)、权限

    目录 命令行解释器 什么是命令行解释器(shell) 命令行解释器的作用 权限 权限的种类 结合用户去理解权限 如何查看权限 用户和用户组 如何看懂权限 如何更改权限 权限对于文件或文件夹的影响 权限 ...

  4. dos命令行输入adb shell命令为什么报错

    在命令行(就是开始--运行--输入cmd)模式下输入adb shell命令一般会报两种错误,一是"adb不是内部命令或外部命令,也不是可运行的程序或批处理文件",二是"e ...

  5. linux的命令行操作和shell的区别

    这个问题也是突然想起来的,因为我身边的同事有时候会把这两个区别的表述,所以我就好奇了,到底是什么关系呢,他们都能操作Linux系统啊..后来百度一下才知道大致的区别. 一.什么是shell 答:    ...

  6. shell for循环命令行_24 道 shell 脚本面试题

    想要成为中高级phper, shell 脚本是需要掌握的,它有助于你在工作环境中自动完成很多任务. 如下是一些面试过程中,经常会遇到的 shell 脚本面试问题及解答: Q:1 Shell脚本是什么. ...

  7. Linux命令行–更多bash shell命令(转)

    4.1.1 探查程序 ps 命令 默认情况下,ps命令只会显示运行在当前控制台下的属于当前用户进程的进程 显示的当前进程的项目 进程号 运行在哪个终端(tty) 进程占用的CPU时间 Linux系统支 ...

  8. Vim命令行模式调用shell命令方式(笔记)

    本文为阅读vim实用技巧时的一部分笔记 在vim中操作时,我们能很方便德调用shell命令.下面选取了最有用的一些调用外部命令的方式: :shell:启动一个shell(输入exit返回vim) :! ...

  9. 终端命令行新手教程——shell脚本

    终端命令基础 摘自:菜鸟教程 本文精简自原文章,总结了常用部分,如需深入学习请点击上方链接 一.运行环境 打开文本编辑器(可以使用 vi/vim 命令来创建文件),新建一个文件 test.sh,扩展名 ...

  10. linux命令行 正则,Linux shell基础(四)正则表达式与grep命令 beta

    一.正则表达式 之前学习find命令时,就已经接触过一些简单的正则,那么我们现在来学习一些复杂的正则.首先,我们还是来复习什么是正则表达式,看这个教程先,一定要多看几遍,至少知道正则大概长什么样子.( ...

最新文章

  1. linux 单独取出本机IP地址
  2. 让你提前知道软件开发(44):如何解决软件故障?
  3. HDU-4777 Rabbit Kingdomom(树状数组、区间离线)
  4. Altiumnbsp;designernbsp;学习教程
  5. Mysql:This version of MySQL doesn’t yet support ‘LIMIT IN/ALL/ANY/SOME 错误解决
  6. MD文件图片base64自动编码
  7. npm使用taobao镜像
  8. Datalist嵌套以及属性生成器和页面样式
  9. 特征的标准化和归一化
  10. C# 如何调用打印机打印报表
  11. 时域技术在天线测量中的应用
  12. MeshBaker插件 使用套路
  13. 王见:手机创业很简单,去县城获取粉丝更简单!
  14. python实现微信发红包
  15. 用 PHP 来刷leetCode 之 电话号码的字母组合
  16. cookie前端写还是后端写
  17. 2016计算机考研330分,考研330分什么概念_中国研究生招生信息网官方
  18. win32asm导入表
  19. jvm什么时候会触发full gc
  20. ←机器人工程或机器人方向毕业设计汇总篇→↓2022↑

热门文章

  1. hprose-php教程,Swoole学习笔记(六):Hprose入门
  2. python二分法求函数零点_在SciPy/NumPy中求复函数的零点
  3. 关于彻底卸载手心输入法的终极操作
  4. 登录时候输入验证码,验证码图片从服务器获取方法
  5. 数据库管理系统的概念及数据库管理系统的基本功能
  6. java程序设计大赛acm_转载(ACM国际大学生程序设计大赛)
  7. 普通用户sudo echo权限依旧写入不了文件
  8. 4k hidpi 黑苹果_黑苹果如何通过开启HIDPI来增强显示效果?
  9. macOS 11 Big Sur 开启 2K 分辨率的 HiDPI 模式(五分钟完成)
  10. 测试开发工程师必知必会