Hi there, I'm Ziheng Lv 🎉
- 🇨🇳 Chinese
- 🔭 Finding The meaning of useless technology
- 😄 🎮Video Games, ❤️☠️🤖 Movies, 🏊Swimming, 🎸Guitar, 🎼 Classic Music
- ☁️ Web Server, Distributed system, Middleware, Cache, ...
- 📙 Go, C/C++, Python, ...
有道词典的命令行版本,支持英汉互查和在线查询。
安装环境: 需要python3和bs4 (在线搜索用)
sudo apt-get install python3
sudo apt-get install python3-pip
pip3 install bs4
need change to:
sudo apt-get install python3
sudo apt-get install python3-pip
sudo pip3 install bs4
Error: Connection out of time
Traceback (most recent call last):
File "WudaoCommand.py", line 135, in
main()
File "WudaoCommand.py", line 131, in main
app.query()
File "WudaoCommand.py", line 77, in query
server_context = self.client.get_word_info(self.word).strip()
File "/home/micheallin/Workspace/github/Wudao-dict-master/wudao-dict/src/WudaoClient.py", line 29, in get_word_info
self.client.sendall(word.encode('utf-8'))
BrokenPipeError: [Errno 32] Broken pipe
现在计划是开源项目.
系统:Archlinux
桌面:kde
终端:Konsole
错误信息:
File "WudaoCommand.py", line 135, in
main()
File "WudaoCommand.py", line 131, in main
app.query()
File "WudaoCommand.py", line 103, in query
word_info = get_text(self.word)
File "/home/lkf/gitrepo/wudao_dict/wudao-dict/src/WudaoOnline.py", line 87, in get_text
d = root.select(".wordGroup.def")
TypeError: 'NoneType' object is not callable
注:已安装bs4,lxml。
控制台python
>>>import bs4
>>>import lvml
也没有问题。
mashiro@DESKTOP-AB378GP:~$ cd ./wudao-dict/wudao-dict
mashiro@DESKTOP-AB378GP:~/wudao-dict/wudao-dict$ sudo sh setup.sh
[sudo] mashiro 的密码:
mkdir: 无法创建目录"usr": 文件已存在
Unziping...
Archive: ./dict/dict.zip
error: cannot create ./dict/dict.index
Input/output error
error: cannot create ./dict/dict.json
Input/output error
error: cannot create ./dict/zh_dict.index
Input/output error
error: cannot create ./dict/zh_dict.json
Input/output error
Setup Finished!
use wd [OPTION]... [WORD] to query the word.
mashiro@DESKTOP-AB378GP:~/wudao-dict/wudao-dict$ su root
密码:
root@DESKTOP-AB378GP:/home/mashiro/wudao-dict/wudao-dict# sudo sh setup.sh
mkdir: 无法创建目录"usr": 文件已存在
Unziping...
Archive: ./dict/dict.zip
error: cannot create ./dict/dict.index
Input/output error
error: cannot create ./dict/dict.json
Input/output error
error: cannot create ./dict/zh_dict.index
Input/output error
error: cannot create ./dict/zh_dict.json
Input/output error
Setup Finished!
use wd [OPTION]... [WORD] to query the
```word.
写了个调用wudao-dict的vimscript,暂时可以用来调用wd查询单个单词
https://github.com/qiebzps/vim_wudao-dict
基本上是查查看某个单词什么意思,例句什么的可以加参数查看,否则像我改成了默认【wd】是【wd -s】的效果,再想看例句就不知道加什么参数了
^CTraceback (most recent call last):
File "WudaoCommand.py", line 118, in
main()
File "WudaoCommand.py", line 114, in main
app.query()
File "WudaoCommand.py", line 68, in query
server_context = self.client.get_word_info(self.word).strip()
File "/home/HOST/wudao-dict/wudao-dict/src/WudaoClient.py", line 27, in get_word_info
self.connect()
File "/home/HOST/wudao-dict/wudao-dict/src/WudaoClient.py", line 17, in connect
self.client.connect(("0.0.0.0", 2376))
KeyboardInterrupt
比如通过浏览器访问下面的URL
http://URL/querydict?example
然后在浏览器上显示英文单词example的解释。
RT,退出代理的话还需要exit退出一下,才能正常使用在线查询
里面太多的http了,很多都可以用https的。我在互联网安全公司工作,安全分析师刚刚给我看我查的每一个词在公司网络上都看得到。现在全公司都知道我英语不好了!泪...
而且代码里有把在线查到的词上传到你的服务器数据库是吗?这至少应该提前说一声啊。这也是隐私保护的一部分。最好应该可以选择愿不愿意上传,而不是只要用了这个工具就上传给你。
我一直在使用您的wd作为日常翻译工具使用,感觉非常好用和方便:+1:。但我最近在使用的时候发现一个翻译场景可能会比较常见但是wd无法支持:hushed:。就是使用wd翻译txt文本,或者说是使用wd翻译linux命令的帮助,因为大多数命令都是英文的,需要去网络上进行查找,效率非常低。如果使用管道结合wd进行翻译例如下面的命令“docker run --help | wd”。这样对命令的使用和学习应该帮助很大,现在的同类软件中都没有这样的支持,如果wd能支持的话相信star应该不会少的:smile:。
目前中文解释是深蓝色,我的终端也是深色,所以颜色有点冲突,想问一下如何更改颜色,谢谢
有个epeak的工具可以实现发音,我更熟悉shell,所以编写了如下代码实现查词时自动发音功能。
#!/bin/bash
filename="/home/zjq/Wudao-dict/`date '+%x'`_words"
case $1 in
-b)
touch $filename.txt
echo "`date '+%x'`_words" > $filename.txt
#创建一个.txt文件用来存查过的单词,文件名是时间戳
;;
-s)
sed '/^\s*$/d' $filename.txt | s-nail -s "new words" [email protected]
#去掉空格,并以 new words 为主题发送邮件至指定你的邮箱
;;
*)
word=" "
for x
do
word="$word $x"
done
#连接单词和短语
;;
esac
wd -o $word
espeak "$word"
echo $word >> $filename.txt
系统: kali-2018.2
终端: gnome-terminal
指令:
root@kali:/wudao-dict/wudao-dict# ./setup.sh/wudao-dict/wudao-dict# python3
Setup Finished!
use wd [OPTION]... [WORD] to query the word.
自动补全会在下次打开命令行时启用
或者手动运行 source /.bashrc/wudao-dict/wudao-dict# wd hello
root@kali:
Traceback (most recent call last):
File "WudaoCommand.py", line 10, in
from src.WudaoClient import WudaoClient
File "/root/wudao-dict/wudao-dict/src/WudaoClient.py", line 3, in
import socket
File "/usr/lib/python3.6/socket.py", line 49, in
import _socket
ModuleNotFoundError: No module named '_socket'
Python版本:
root@kali:
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 18:10:19)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
[1]+ Stopped python3
查询出来汉字是深蓝色,黑色背景看不清
rm掉旧版本,clone新版本安装后不能使用
$ wd fuck
Error: Connection out of time
Traceback (most recent call last):
File "WudaoCommand.py", line 135, in <module>
main()
File "WudaoCommand.py", line 131, in main
app.query()
File "WudaoCommand.py", line 77, in query
server_context = self.client.get_word_info(self.word).strip()
File "/home/linmei/tools/wudao-dict/wudao-dict/src/WudaoClient.py", line 29, in get_word_info
self.client.sendall(word.encode('utf-8'))
BrokenPipeError: [Errno 32] Broken pipe
感谢!哈哈,终于找到这么可爱的翻译了。
总文件夹压缩前263M,为什么这么大。
执行命令:wd 运算符 报以下错误,wd 算符也是,其余的没发现
Traceback (most recent call last): File "WudaoCommand.py", line 135, in <module> main() File "WudaoCommand.py", line 131, in main app.query() File "WudaoCommand.py", line 81, in query word_info = json.loads(server_context) File "/usr/lib/python3.6/json/__init__.py", line 354, in loads return _default_decoder.decode(s) File "/usr/lib/python3.6/json/decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.6/json/decoder.py", line 357, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
解释没有被查的词语
RT
有些词在线查询查不到,但是在网易的网页版是能查到网络释义的。不知能否考虑在在线查询中加入此释义?
现在如果一个单词查询多次,将会在单词本中重复出现,希望在加入到生词本之前,检测重复性。
能不能做成pip包的形式,在windows下使用,那就太好了!
wd -o ####
Traceback (most recent call last):
File "WudaoCommand.py", line 118, in
main()
File "WudaoCommand.py", line 114, in main
app.query()
File "WudaoCommand.py", line 85, in query
word_info = get_text(self.word)
File "/home/dolabmoon/Wudao-dict-master/wudao-dict/src/WudaoOnline.py", line 36, in get_text
root = bs4.BeautifulSoup(content, "lxml")
File "/usr/local/lib/python3.5/dist-packages/bs4/init.py", line 165, in init
% ",".join(features))
bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?
系统: Ubuntu 17.10
Wudao-dict git:(master) ✗ sudo ./wudao-dict/setup.sh cp: 无法获取'wd_com' 的文件状态(stat): 没有那个文件或目录 ./wudao-dict/setup.sh: 行 23: /etc/bash_completion.d/wd: 没有那个文件或目录 Setup Finished! use wd [OPTION]... [WORD] to query the word. 自动补全会在下次打开命令行时启用 或者手动运行 source ~/.bashrc
➜ ~ wd /usr/bin/wd: 行 4: ./wdd: 没有那个文件或目录
单文件可以运行
➜ ~ ./Downloads/Wudao-dict/wd_monofile task task 英 [tɑːsk] 美 [tæsk] vt. 分派任务 n. 工作,作业;任务 CET4 TEM4 ( tasking, tasked, tasks )
大家看看有没有这种情况的发生
✘ soar@sir ~/Applications git clone https://github.com/chestnutheng/wudao-dict Cloning into 'wudao-dict'... remote: Enumerating objects: 11, done. remote: Counting objects: 100% (11/11), done. remote: Compressing objects: 100% (8/8), done. error: RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54 fatal: The remote end hung up unexpectedly fatal: early EOF fatal: index-pack failed
模糊查询对于查单词来说太重要了,往往记不住的话wd也发挥不出来功用啊啊。
建议起码包括以下几项:
安装好后,任意查询词汇:
xiankun@xiankun-PC:~/Softwares/Wudao-dict/wudao-dict$ wd university
出现如下错误:
Traceback (most recent call last):
File "WudaoCommand.py", line 118, in
main()
File "WudaoCommand.py", line 114, in main
app.query()
File "WudaoCommand.py", line 74, in query
self.history_manager.add_item(self.word)
File "/home/xiankun/Softwares/Wudao-dict/wudao-dict/src/UserHistory.py", line 30, in add_item
self.content = json.load(f)
File "/usr/lib/python3.4/json/init.py", line 268, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
File "/usr/lib/python3.4/json/init.py", line 318, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.4/json/decoder.py", line 343, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.4/json/decoder.py", line 361, in raw_decode
raise ValueError(errmsg("Expecting value", s, err.value)) from None
ValueError: Expecting value: line 1 column 1 (char 0)
运行uninstall.sh后再安装也无法解决问题,是否是我的python版本的问题?
能在生词本加入音标吗
wd it
可以在原本在bash的补全文件的基础上修改,然后通过.zshrc source加载,不知道可不可以在setup.sh中安装时进行自动设置。
# ~/.oh-my-zsh/completions/_wd
_wudao()
{
optl=(
the
of
...
admitting
)
compadd ${optl[@]}
}
compdef _wudao wd
# ~/.zshrc
source /home/yourname/.oh-my-zsh/completions/_wd
理论上~/.oh-my-zsh/completions/是在$fpath中,每次启动zsh时会该目录下的文件自动加载,但不知道为什么我的始终不行,最后在.zshrc中加了source
会报错UnicodeDecodeError
能不能加一个英文单词缩写查询,以及缩写查询原英文单词的特性QAQ
使得无sudo权限时可将配置文件和binary安装到家目录下。
RT,请问,谢谢
Word not found, auto Online search...
No Internet : Please check your connection or try again.
Ubuntu18.04,电脑已经联网,在终端ping百度这些网站也能ping通,但是无道词典查询报错,连不上网
我用你的代码做了一个:https://github.com/xuiv/WuYoudao-dict
你的代码有一些问题,服务器上因为json调用会生成太多异常导致崩溃,服务器上的生僻词提交导致效率低下,你应该把查不出来生僻词提交放到客户端里。
我用BytesIO把词典文件放到内存里了,生僻词提交的代码我也删除了,希望你能把这个功能合并进来。我没学过python,你自己弄吧。
想把蓝色的翻译结果换成黄色
It's really a fantastic tool. Would be great if it can add macOS support. Thanks.
用wd -i
命令进入交互模式,直接输入单词然后回车就能查词,查完后程序不退出,可以接着查下一个词。
通过brew
安装包,一直失败
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.