Giter Site home page Giter Site logo

abdnh / anki-incontext Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 1.0 208 KB

An Anki add-on that shows random example sentences each time you review a vocabulary card

Home Page: https://ankiweb.net/shared/info/385420176

License: GNU General Public License v3.0

Makefile 0.84% Python 87.48% Shell 1.10% HTML 9.35% CSS 0.43% JavaScript 0.79%
anki anki-addon vocabulary-learning

anki-incontext's Introduction

InContext

An Anki add-on that fetches and displays random example sentences in different languages from various sources.

Template filter

The add-on mainly works as a template filter to show random example sentences for vocabulary each time a card is viewed.

You just have to put a filter like this in your card template:

{{incontext:Front}}

Here, the add-on will show a random English example sentence containing the word in the Front field.

You can specify the language using the lang option:

{{incontext lang=en:Front}}

Currently supported values are:

  • en English
  • tr Turkish
  • ja Japanese
  • ko: Korean
  • zh: Chinese

Sentences are fetched from multiple sources such as https://www.lexico.com/ (for English) and https://sozluk.gov.tr (for Turkish). You can show sentences from only a certain source by using the provider option, like this:

{{incontext lang=en provider=lexico:Front}}

For a list of supported sources, see the providers folder. The identifier of each provider is defined by a name variable inside each provider class. A list of available providers is also shown in the interface.

If a provider is given but no language, the first supported language of the provider will be assumed. If both language and provider are not given, the default is English with all providers.

More sites and languages will be added in the future. Contributions are welcome!

Fill-in option

You can also add sentences to a chosen field in multiple notes using the browser's Notes > InContext: Add sentences menu item. This is useful if you review on mobile.

Fill-in dialog

Importing Tatoeba databases

To make Tatoeba databases available for use with the add-on, please see this doc.

Interface

The add-on has an experimental graphical interface to manage sentences that can be accessed from Tools > InContext.

The add-on's interface

Demo

Download this deck for a demo of the add-on: https://drive.google.com/file/d/1Era5ksSa59xjB3ZbVQsdoTbQEigzh6Bi/view?usp=sharing

Download

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

Storage

In the first review of a card that has the InContext filter, sentences will be fetched from the language providers and saved in the user_files/sentences.db file. Subsequent reviews will use those saved sentences (if any) and avoid making more requests to the providers. You can anyway update saved sentences manually from the GUI.

Known Issues

  • IMPORTANT: In versions before 0.3.1, the add-on suffered from an issue preventing updates from being properly installed, which resulted in Anki prompting to update the add-on every time. To fix this, please follow the steps carefully:
    1. Download version 0.3.1 from this page. You should download the incontext_ankiweb.ankiaddon file or this won't work.
    2. Close Anki then double click on the .ankiaddon file to install it and run Anki. Closing Anki is important for the update to work.
    3. Go to Tools > Add-ons and click Check for Updates. You should be prompted to update the add-on. The issue should be fixed after updating this time.

Changelog

See CHANGELOG.md for a list of changes.

Credit

Some icons are adapted from Bootstrap Icons; licensed under the MIT.

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

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

anki-incontext's People

Contributors

abdnh avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

fudigg

anki-incontext's Issues

'Ui_Dialog' object has no attribute 'gridLayout'

Error
An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed.
If the issue only occurs when add-ons are enabled, please use the Tools > Add-ons menu item to disable some add-ons and restart Anki, repeating until you discover the add-on that is causing the problem.
When you've discovered the add-on that is causing the problem, please report the issue to the add-on author.
Debug info:
Anki 2.1.55 (e3c3405f) Python 3.10.8 Qt 6.4.0 PyQt 6.4.0
Platform: Linux-5.15.79-1-lts-x86_64-with-glibc2.36
Flags: frz=False ao=True sv=3
Add-ons, last update check: 2022-11-17 22:04:20
Add-ons possibly involved: ⁨incontext⁩

Caught exception:
Traceback (most recent call last):
  File "/home/yaoberh/.local/share/Anki2/addons21/incontext/__init__.py", line 55, in open_dialog
    dialog = InContextDialog(mw, sentences_db)
  File "/home/yaoberh/.local/share/Anki2/addons21/incontext/incontext_dialog.py", line 221, in __init__
    self.setup_ui()
  File "/home/yaoberh/.local/share/Anki2/addons21/incontext/incontext_dialog.py", line 225, in setup_ui
    self.form.gridLayout.addWidget(self.wordlist_view, 4, 0)  # type: ignore[call-overload]
AttributeError: 'Ui_Dialog' object has no attribute 'gridLayout'

Skell downloader not found

Hey! So my installation doesn't find Skell downloader.
Found your other repository with this name, put it into the incontext folder but this doesn't fix the issue.
What should I do?


When loading '⁨InContext - Learn vocabulary in context⁩':
⁨Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/aqt/addons.py", line 244, in loadAddons
    __import__(addon.dir_name)
  File "/home/yaoberh/.local/share/Anki2/addons21/incontext/__init__.py", line 14, in <module>
    from .incontext_dialog import InContextDialog
  File "/home/yaoberh/.local/share/Anki2/addons21/incontext/incontext_dialog.py", line 9, in <module>
    from .providers import get_languages, get_providers_for_language, get_sentence
  File "/home/yaoberh/.local/share/Anki2/addons21/incontext/providers/__init__.py", line 14, in <module>
    from .skell import SkellProvider
  File "/home/yaoberh/.local/share/Anki2/addons21/incontext/providers/skell.py", line 3, in <module>
    from .vendor.skell_downloader import SkellDownloader
ModuleNotFoundError: No module named 'incontext.providers.vendor.skell_downloader'

Have a great day :)

Add support for more languages and providers

  • We can cheaply add basic support for numerous languages by implementing generic fetchers for sites like Tatoeba.
  • We should utilize existing libraries and vendorize them - the existing Make-based build system will probably become unwieldy after we add more than a couple of dependencies.

Contributions to add more languages and providers are welcome! See #1 (comment) as a starting point.

A few suggestions

Hi. I just wanted to leave here a few suggestions in case you were interested.

  • Support generic text files with sentences in csv or similar format
  • Support adding html to the beginning and end of the retrieved sentence and/or word (so the user can format them differently with CSS for example)
  • Add min/max character limit for the example sentence (potentially even for each of them)

There is also this add-on which hasn't been updated in a while and is partly broken. Not sure if you might be interested in joining efforts or reusing some code.

In any case, thanks a lot! I am currently using it with the Tatoeba Spanish sentence file and it is working (it is a bit slow though, it's like a second per card, with two sentences each card, so it'll take about 2 hours to go through my deck).

Let me know if I can be of any help or if you want me to post the suggestions as different issues.

Possibility of adding other languages?

Hey! Hope you're doing fine :)
Wondering if I could manually add other languages, and if you could possibly explain to me how to do this?
I got as far as downloading other languages from tatoeba, but they're not working when using the addon in anki.
Maybe I'm doing something wrong?
Thanks!

Improve support for multiple languages

  • Currently, multi-language support is done by separate files for each language under the providers directory.
  • Some sentence sources that support multiple languages like Tatoeba should be implemented through a common sub-library that can be imported and used by different providers.
  • We have to define a way to specify metadata about each fetcher, so that we can store this info on the DB and do filtering/querying operations accordingly.
  • Maybe each language's providers should reside in a dedicated subfolder, where each fetcher can be separated to its own file?

Fetching sentences from a deck or list of sentences?

Hey!
Such a cool idea :D
Maybe it would be useful if one could do this locally, by selecting a sentence list from a file or having it look at your deck and fetch from there?
In this case one could support many more languages, I think. Right?
Anyway, looking forward to more languages in this!

Rework the sentence storage format

Currently, sentences are saved as a simple list in JSON files. It would be nice to be able to see from where each sentence comes from, so we have to store the provider of each sentence. Support for searching and deleting certain sentences would be great, too. Therefore, we're probably better off using a format more suited to running queries, like SQLite.

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.