Giter Club home page Giter Club logo

anki-zim-reader's Introduction

Anki add-on that allows you to import ZIM files and access their data inside Anki. The main focus of the add-on is to support extracting information such word definitions, example sentences, pronunciation, etc. from the Wiktionary ZIM files and add them to notes.

This is a fork of the Wiktionary add-on. The plan was to add ZIM support to the Wiktionary add-on in addition to the original support for Kaikki files, but I got some ideas to extend the add-on with ZIM-specific additions like a pop-up dictionary and a local server that can be accessed from other add-ons, so I decided to split it into a new add-on to keep the Wiktionary add-on simple.

Supported dictionaries

Currently supported Wiktionary versions are the following:

  • Greek
  • Spanish
  • German
  • Turkish

We try to support the ZIM files provided by the Kiwix team at https://wiki.kiwix.org/wiki/Content_in_all_languages

If you want to see support for your language, you can open a feature request in the issue tracker. If you're a developer and want to contribute, please see development.md.

Usage

Importing a ZIM file

The dialog under Tools > ZIM Reader > Import a file allows you to import a new ZIM file and make it available for use in the add-on. The Kiwix library has a lot of ZIM files available for download.

Filling in notes

The add-on provides an interface to fill existing notes with defintions, example sentences, etc. from imported files. The interface can either be accessed from a button in the editor, or via the Edit > Bulk-define from ZIM file menu item in the browser for bulk operations on selected notes. You can also configure shortcuts from Tools > Add-ons.

Explanation of some options:

  • File: The imported ZIM file you want to extract info from.
  • Parser: For the add-on to understand how to extract data from the chosen file, you need to tell it what "parser" it should use to do that. Only a limited number of ZIM files for a couple of languages currently have parsers.
  • Word: The field where the word you want to query exists.
  • The other options decide to which field each kind of supported info goes.

Pop-up dictionary

There is also a feature to look up words in the reviewing screen in imported ZIM files. Unlike the "fill-in" feature, this should work on any imported ZIM file without the need for a special parser. If you select any word and press "Alt+Shift+S", a pop-up should be shown with the page of the selected word if found. You can configure the ZIM file used for the pop-up feature and some other settings from the Settings dialog.

Browser

You can browse the contents of imported ZIM files from the window under Tools > ZIM Reader > Browser.

Settings

You can configure some settings of the add-on from Tools > ZIM Reader > Settings. Currently only the pop-up dictionary's settings are configurable here. For the parser option, if your chosen dictionary file doesn't have a dedicated parser, you can simply choose the "Default" parser. Parsers here are currently only useful to convert a word to its base form and search for that instead using language-specific rules if the exact word doesn't have a page in the dictionary.

Download

You can download the add-on from AnkiWeb: https://ankiweb.net/shared/info/951350249

Development

See development.md for docs that only interest developers and contributors.

Changelog

See CHANGELOG.md for a list of changes.

License

GPLv3 or later. See LICENSE.

Credit

Support & feature requests

Please post any questions, bug reports, or feature requests in the support page or the issue tracker.

If you want priority support for your feature/help request, I'm available for hire. You can get in touch from the aforementioned pages, via email or on Fiverr.

Support me

Consider supporting me if you like my work:

Buy Me a Coffee at ko-fi.com

I'm also available for freelance add-on development on Fiverr:

anki-zim-reader's People

Contributors

abdnh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

exponent4806

anki-zim-reader's Issues

Extract non-native entries from Wiktionary files too

Each language's Wiktionary version can contain entries for any word in any language. We currently only extract the native ones, but making it possible to extract all entries is very useful. We have to understand a setting to allow choosing which entry should be pasted to the note.

One related issue that we should think of is how to handle the case where there are multiple entries of a single word belonging to the same language (e.g. different entries for nouns and verbs). Should we dump all of them together to the same note?

Add tests

We should add some tests for dictionary parsing to ensure regressions are caught. Running the tests on GitHub actions would be nice too.

[Feature] Automatically resize images added from Wiktionary

The images from the Wiktionary in .zim format are very small.

When one tries to see the images on Anki the size is not adequate and then one needs to manually resize.

Would it be possible an option to automatically resize the images to a "default value" with the add-on ?

For example > 800 x 800 or something similar conserving the original size ratio.


Here is the "original size":
grafik

grafik

Add Russian Support

Would it be possible to add support for the "Russian Wiktionary" in .zim format ?

That Wiktionary is one of the most complete and the HTML structure seems to be very well standardized.

Some time ago, I contacted you via "Fiverr" to add "German Support" to this add-on when you were in the initial phase of development. I am glad to have supported your work since this add-on has improved my German skills drastically. Thank you.

I will be glad to support you again via "Fiverr" if you could add the "Russian Language". Please let me know if it would be possible... :D

Pop-up dictionary

A feature that allows users to look up words/terms in cards then pops up a dictionary view in a tooltip (Like Pop-up Dictionary) will be great to have.

Some notes about how this should be implemented:

  • Imported dictionaries should be served over a local server that makes available the requested HTML and other resources of a queried word. I've already written a working implementation in Flask, with the help of mediasrv.py from Anki. More work needs to be done though if we want to support serving multiple dictionaries at the same time with an option to switch the active one.
  • We can use Tippy.js for the tooltips.

Test files created with Zimit

Zimit is a service that lets you create a ZIM file from any website: https://youzim.it/

I've not had much success viewing a ZIM file created with it with this add-on or ZIMply. Specifically the .search() function returns correct results, but no URL returned by it gives results with .get_article().

The files work fine with Kiwix-serve though, so this looks like a ZIMply-specific issue.

I should write a working python-libzim prototype and test things on it.

Add French support

Hello, and first thank you for this plugin!
I would like it to have support for French, and I tried looking into the code of the parsers for other languages, but I’m not really sure how it works, nor how I can look into ZIM files to understand their structure and write a parser for them… How much effort do you think it would be to add support for the French language? :)

Add-on does not work on Anki 23.12.1

The add-on cannot be used on the latest version of Anki!

Would it be possible to find a solution ? I helped to fund the add-on adding German support via a freelancer platform but now this critical errors makes it impossible to use ! :(

Best regards from Germany....


Anki 23.12.1 (1a1d4d54) (src) (ao)
Python 3.11.6 Qt 6.6.1 PyQt 6.6.1
Platform: Linux-6.6.10-arch1-1-x86_64-with-glibc2.38

When loading ZIM Reader - Look up words in Wiktionary:
Traceback (most recent call last):
File "/usr/lib/python3.11/site-packages/aqt/addons.py", line 245, in loadAddons
import(addon.dir_name)
File "/home/m/.local/share/Anki2/addons21/951350249/init.py", line 4, in
from . import main
File "/home/m/.local/share/Anki2/addons21/951350249/main.py", line 23, in
from . import popup
File "/home/m/.local/share/Anki2/addons21/951350249/popup.py", line 14, in
from . import server
File "/home/m/.local/share/Anki2/addons21/951350249/server.py", line 13, in
from .dictionaries import DefaultParser, Parser, ZIMDict
File "/home/m/.local/share/Anki2/addons21/951350249/dictionaries/init.py", line 7, in
from .dictionary import DictEntry, ZIMDict
File "/home/m/.local/share/Anki2/addons21/951350249/dictionaries/dictionary.py", line 13, in
from ..client import ZIMItem, init_client
File "/home/m/.local/share/Anki2/addons21/951350249/client.py", line 142, in
assert _client_class
AssertionError

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.