Giter VIP home page Giter VIP logo

wudao-dict's Introduction

Andy's github stats

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, ...

logo

wudao-dict's People

Contributors

chestnutheng avatar diyer22 avatar idiomaticrefactoring avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wudao-dict's Issues

Very, very small problems

First,Thank you!

安装环境: 需要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

BrokenPipeError: [Errno 32] Broken pipe

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

建议: 用 sqlite3 来储存 dict/en.z, dict/zh.z 里的数据. Migrate the data in "dict/en.z", "dict/zh.z" to a sqlite3 database

由于无道词典的操作方式是开启一个本地服务器 (WudaoServer.py) 随时聆听请求并以 json 格式返回查询单词的语意, 而服务器包含一个 JsonReader (src/JsonReader.py) 物体, 该物体储存了所有中英文单词的索引, 难免有些占用内存 (如图 约 116MB).

image

如果能够讲运用 Python 自带的 sqlite3 建立一个简单的数据库, 必能优化以上问题, 且能有效的加快查询速度.

无法在线查询

系统: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
也没有问题。

Input/output error

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.

建议默认只看释义

基本上是查查看某个单词什么意思,例句什么的可以加参数查看,否则像我改成了默认【wd】是【wd -s】的效果,再想看例句就不知道加什么参数了

Functioning Abnormally and Canot Be Used Any More

Here below is the screen output after I "wd ####" a word

^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

有没有web based版本?

比如通过浏览器访问下面的URL

http://URL/querydict?example

然后在浏览器上显示英文单词example的解释。

安全问题!

里面太多的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下无法使用, 错误信息如下, 请问如何解决?

系统: kali-2018.2
终端: gnome-terminal
指令:
root@kali:/wudao-dict/wudao-dict# ./setup.sh
Setup Finished!
use wd [OPTION]... [WORD] to query the word.
自动补全会在下次打开命令行时启用
或者手动运行 source /.bashrc
root@kali:
/wudao-dict/wudao-dict# wd hello
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:
/wudao-dict/wudao-dict# python3
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

thanks

感谢!哈哈,终于找到这么可爱的翻译了。

wd 运算符 和 wd 算符 报错

执行命令: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)

在线查询网络释义

有些词在线查询查不到,但是在网易的网页版是能查到网络释义的。不知能否考虑在在线查询中加入此释义?

在线查询时出现错误

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 )

关于安装脚本的/usr/bin/wd脚本生成

  1. 应该可以在wd脚本中保存一下安装路径,然后按照安装路径调用,要修改wdd文件应该可以避免在wd命令中跳转目录了。
  2. 可以最后传给管道(more,less) 分屏,如:wdd $* | more,这个确实很需要,我是本地再写了一个脚本调用命令调用wdd的

git clone 总是到42%以后,就安装失败了

大家看看有没有这种情况的发生

✘ 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也发挥不出来功用啊啊。
建议起码包括以下几项:

  • 单复数能够正常查询
  • 只输入前半部,后边可以使用Tab补全或者列出候选项之类的

查询词汇出错,uninstall 后再安装也无法解决问题

安装好后,任意查询词汇:
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版本的问题?

增加zsh补全

可以在原本在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

无道词典连不上网

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,你自己弄吧。

macOS support

It's really a fantastic tool. Would be great if it can add macOS support. Thanks.

交互模式 wd -i

wd -i命令进入交互模式,直接输入单词然后回车就能查词,查完后程序不退出,可以接着查下一个词。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.