Code Monkey home page Code Monkey logo

zhudi's Introduction

What is Zhudi?

Zhudi is a GTK4 graphical interface to the EDICT dictionaries. The following ones are included by default:

Features

What platforms are supported?

Since this project is written in Python 3.10+ & GTK4, it should be able to run on any given platform. However, I only have tested it under GNU/Linux (Gnome).

What are the dependencies of Zhudi?

In order to run Zhudi, you need the following packages:

  • python 3.10+
  • python-gobject
  • pygobject-devel
  • gobject-introspection

You also need to have GTK 4 installed.

Installation

Pip

Zhudi can be installed using python's package manager pip as follows:

pip install git+https://github.com/Jiehong/Zhudi

Launching

Run it by running the zhudi python module in the directory you installed it from:

cd /path/to/zhudi
python -m zhudi

You should see the GUI up and running:

GUI screenshot

Development

Locally, you can use poetry.

First time:

poetry install

Then:

poetry run python -m zhudi

Command line usage

You also have access to a limited command line search as follows:

$ zhu 我
我    ㄨㄛˇ    I
           ⇾ me

Unlike the GUI, this only provides the first and best match so far.

Unit tests

dict_test.u8 is used to test the splitting of the dictionary, and then for the rest of the unittests.

First, test that splitting the dictionary is working well:

poetry run python test_cli.py

Then, test the rest of the units:

poetry run python -m unittest

Formatting

Source files are formatted with black:

poetry run python -m black zhudi && poetry run python -m black tests

New Dictionaries

Download any EDICT dictionary with the *.u8 format, and modify db_fill.py to read it.

Then run:

poetry run python db_fill.py

zhudi's People

Contributors

jiehong avatar lindenr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

zhudi's Issues

zhudi manual install then setup fails somehow

setup does prepare some files but crashes.

$ zhudi -s cfdict.u8
Splitting dictionary in progress…
Traceback (most recent call last):
File "/usr/bin/zhudi_gui.py", line 5, in
pkg_resources.run_script('zhudi==1.4', 'zhudi_gui.py')
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 483, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 1348, in run_script
exec(script_code, namespace, namespace)
File "/usr/lib/python2.7/site-packages/zhudi-1.4-py2.7.egg/EGG-INFO/scripts/zhudi_gui.py", line 43, in

File "/usr/lib/python2.7/site-packages/zhudi-1.4-py2.7.egg/EGG-INFO/scripts/zhudi_gui.py", line 30, in main

File "build/bdist.linux-x86_64/egg/zhudi/init.py", line 74, in prepare_data
TypeError: init() takes at least 11 arguments (8 given)

below is only there if helpful.

or does it only leave incorrectly? if I run from the same directory (yes i did the awful way, everything in the same place ;)
$ ls
build cfdict.u8 COPYING.tex dist doc NEWS pinyin PKGBUILD README.md scripts setup.py simplified tests.py traditional translation zhudi zhudi-data zhudi.egg-info zhudi.install

running zhudi will then fail
$ python /usr/bin/zhudi_gui.py -p pinyin -tr translation -sd simplified
No config file found. Use defaults
Traceback (most recent call last):
File "/usr/bin/zhudi_gui.py", line 5, in
pkg_resources.run_script('zhudi==1.4', 'zhudi_gui.py')
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 483, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 1348, in run_script
exec(script_code, namespace, namespace)
File "/usr/lib/python2.7/site-packages/zhudi-1.4-py2.7.egg/EGG-INFO/scripts/zhudi_gui.py", line 43, in

File "/usr/lib/python2.7/site-packages/zhudi-1.4-py2.7.egg/EGG-INFO/scripts/zhudi_gui.py", line 30, in main

File "build/bdist.linux-x86_64/egg/zhudi/init.py", line 143, in prepare_data
File "build/bdist.linux-x86_64/egg/zhudi/chinese_table.py", line 56, in load
IOError: [Errno 2] 没有那个文件或目录: '/usr/share/zhudi-data/cangjie5'

ok so let's go installing zhudi-data.

$ sudo cp -R zhudi-data /usr/share/

$ zhudi -p pinyin -tr translation -sd simplified
No config file found. Use defaults
Traceback (most recent call last):
File "/usr/bin/zhudi_gui.py", line 5, in
pkg_resources.run_script('zhudi==1.4', 'zhudi_gui.py')
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 483, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 1348, in run_script
exec(script_code, namespace, namespace)
File "/usr/lib/python2.7/site-packages/zhudi-1.4-py2.7.egg/EGG-INFO/scripts/zhudi_gui.py", line 43, in

File "/usr/lib/python2.7/site-packages/zhudi-1.4-py2.7.egg/EGG-INFO/scripts/zhudi_gui.py", line 30, in main

File "build/bdist.linux-x86_64/egg/zhudi/init.py", line 152, in prepare_data
UnboundLocalError: local variable 'simplified' referenced before assignment

I can't search with pinyin

As far as I can tell, pinyin searching doesn't work. Searching "ni" obviously crashes everything, but nihao, ni3, and nǐ don't work.

Chinese and English search order is different

When searching in Chinese, results are ordered by length (and for the same length, ordered somehow I guess?) which makes sense.

I think it would be helpful if the results were also sorted by length for English searches too.

Even better would be if they were ordered by commonness somehow, but that would probably be quite difficult.

Zhudi renders slowly

Showing definitions can take a very long time, depending on the word. I did a bit of profiling and it turns out the _format_codes function is to blame, probably because it searches the whole db for every character. I think it would be better to do one db search on startup, and keep a dictionary of (character) -> (code) in memory. What do you think?

For now I've just made _format_codes return an empty string in my local build and it runs much faster! :)

Zhudi doesn't respect pinyin default choice on first use

The first time you start zhudi, it will render pinyin with numbers instead of tones, even though in the options tab "pinyin" is the selected method. Once you click on the pinyin option again it seems to notice and start rendering pinyin properly.

Possibly this has something to do with the ~/.zhudi/config file that gets created.

Struggling to install zhudi

Hi - this is probably a silly issue on my end, apologies if so. I uninstalled previous zhudi files and ran

pip install git+https://github.com/Jiehong/Zhudi

which looked successful but there doesn't seem to be a zhudi command that I can run now. Running python -m zhudi hangs. Is this expected?

Changing the options is weirdly difficult

This one might just be my computer being weird. If I change to the options tab and click either of the options, the lists flash instead of coming up normally. On the second click within the tab they work as they should.

This happens 50% of the time, not all the time. No idea why.

Pinyin/zhuyin not rendered in definitions

E.g. in 年 we have 2. CL:個|个[ge4]

I think it should be "gè" instead of "ge4" (if pinyin selected) or ㄍㄜˇ if zhuyin selected.

Hopefully this could be accomplished by just pointing the pinyin/zhuyin converter at parts of the definitions contained within square brackets.

Zhudi is difficult to get started with

I know there are good instructions in the README but I feel it could be still more user-friendly.

Coming bundled with cedict/cfdict would be better than nothing imo, but you might disagree. One plus is that updating zhudi would then be an easy way for me to update the dictionaries :P

Even having to first split the dictionary into bits would be better if it was seamless on first run. Something like running zhudi -s mydict could do the splitting, put the files in ~/.zhudi instead of current directory, and then startup zhudi normally.

Maybe then it would be difficult to support multiple different dictionaries (e.g. both cfdict and cedict)? I think it could be made to work nicely. Let me know if you're interested and I'll make an attempt.

Landing tab should be the dictionary one

Currently, the landing tab when launching the application is the one that should be called "About".

It was historically a first greeting pane, but it's adding 1 click every time the app is launched, which is not satisfactory.

The search bar doesn't have focus when zhudi starts up

This is a bit subjective, but I think it would be better if the search bar had cursor focus when zhudi starts.

This would be better because you wouldn't have to click inside the search bar before you start typing.

Even better would be if the search bar never lost focus (in the "Dictionary" tab), even if you click on an entry. Then you could always type and the search bar would pick it up.

Core for some inputs

Zhudi sometimes cores, when latin input is too short.

Ex: (cfdict.u8), word entered: "si":

(zhudi_gui.py:7479): Gtk-CRITICAL **: gtk_text_buffer_get_iter_at_mark: assertion 'GTK_IS_TEXT_MARK (mark)' failed

(zhudi_gui.py:7479): Gtk-CRITICAL **: gtk_text_layout_get_line_yrange: assertion '_gtk_text_iter_get_btree (iter) == _gtk_text_buffer_get_btree (layout->buffer)' failed

(zhudi_gui.py:7479): Gdk-ERROR **: The program 'zhudi_gui.py' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadAlloc (insufficient resources for operation)'.
  (Details: serial 10020 error_code 11 request_code 130 (MIT-SHM) minor_code 5)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the GDK_SYNCHRONIZE environment
   variable to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() function.)
/usr/bin/zhudi: line 3:  7479 Trace/breakpoint trap   (core dumped) $(dirname $0)/zhudi_gui.py $@

Using arrow keys doesn't cause scrolling to keep up

When I press down in the dictionary, the selection can go off the bottom of the screen and the scrolling window doesn't follow. So I can't see what I'm about to select.

Sorry for submitting lots of issues. These are the sort of things I would like to make pull requests for, please let me know if you will accept them. :)

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.