Code Monkey home page Code Monkey logo

sentence-adder-anki-addon's Introduction

Sentence Adder Anki Addon - For any languages

Add sentences to Anki editor window in one click

Select a word in edit field and click add button to add sentences to that fields matching the words. Also create/add sentences for any languages. The sentences database created using tatoeba language tsv files. Download language tsv file from tatoeba.

Install

Make backup before installing addons.

Download addon from AnkiWeb
Sentence Adder Anki Addon

Download from release page
Sentence Adder Anki Addon

Features

  • Create new language database
  • Add random sentence in one click
  • View list of all sentences matching the selected word
  • Change language (Require restart of Anki to apply changes)
  • Change color of sentences
  • Add sentence pair (sentence and its translation)
  • Wrap word and sentence in html tag

Usage

Tutorials

Install

  1. Install Addon from AnkiWeb
Anki -> Tools -> Add-ons -> Get Add-ons...

Paste the code 1682655437 and install.

  1. Restart Anki and open the Addon to add new languages.
  2. Download language of choice from tatoeba
    View Demo Download Sentences data tsv files
  3. Open the installed Addon in Anki
Anki -> Tools -> Sentence Adder...
  1. Click Add new language
  2. Enter language name
  3. Select downloaded language tsv file
  4. Click create to create/add new language to the Addon
    View demo Create/Add Language database
  5. Restart Anki to apply changes

Adding sentences to field in Anki

  1. First change preferences for the Anddon
    There are two preferences
    a. Auto add sentences: Automatically add random sentences matching the words
    b. Open all sentences window: View list of all sentences and select as per choice from the list

  2. Select any text in editor window

  3. Click add button to add sentences

Demo

demo

Sentences Database

tatoeba

My other Anki addons and decks

Shared Decks and Addons

License

Mani
GPL 3.0 View Licence

sentence-adder-anki-addon's People

Contributors

kleemaj avatar krmanik avatar

Stargazers

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

Watchers

 avatar  avatar

sentence-adder-anki-addon's Issues

Chinese - Not finding sentences

Something strange is happening when I try to bulk add sentences for a list of words.
The words have sentences in my tsv file, but the program won't find them and parse them.
This isn't only with Chinese, it also happened with Russian.
It just won't find any sentences at all, and then it will suddenly find others. Don't understand the pattern.

Not finding a sentence in the database during batch adding crashes Anki

EDIT: On further review, it looks the add-on freezes Anki whenever it doesn't find the word or expression in the database (but only for batch adding, manual adding gives an error instead: "Create database or change language options"). Batch adding for simple words that have sentences in my tatoeba database works. However, when looking up something without a sentence in the database it freezes and I have to force close Anki.

________ (original post)
I can add sentences by highlighting and clicking the addon button. But whenever I try to batch add Anki becomes non-responsive.

~~If I select just one or a few cards it just freezes until I have to force close Anki. If I select all my notes from the deck (~1500), it says "Processing" and there is a progress bar. At some point it disappears, but when I try to close the Sentence Adder window, Anki hangs and I have to force close. No sentences are added.~~

I am using:
Anki 2.1.65 (aa9a734f) Python 3.9.15 Qt 6.4.3 PyQt 6.4.0
Platform: Windows-10-10.0.22621
Flags: frz=True ao=True sv=3

It gives me an error.

This is the error that I get:

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, repeat 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 on the add-ons section of our support site.
Debug info:
Anki 2.1.52 (ab1c2395) Python 3.9.7 Qt 6.3.0 PyQt 6.3.0
Platform: Windows 10
Flags: frz=True ao=True sv=2
Add-ons, last update check: 2022-11-12 19:35:54

Caught exception:
Traceback (most recent call last):
File "C:\Users\tibor\AppData\Roaming\Anki2\addons21\1682655437_init_.py", line 120, in createDB
to_db = [row[2]]
IndexError: list index out of range

Ability of providing own tsv file?

Is it possible to implement my own tsv file so it can fetch sentences from a file I provide myself?
If possible, could you explain how I would need to design the file?

Adding a minimum and maximum sentence length

Would it be possible to customize the minimum and maximum number of characters of example sentences?

In fact, it would be great if this was configurable for different sentences. So if I want to add 2 sentences, one might be between 30 and 50 characters and the other one between 50 and 80, for example.

Thanks for this great addon in any case! So useful!

Bug: DB doesn't work

Hi,

just installed the add-on, created the db and all cool. The problem begins after restarting Anki to get the changes done. It all looks normal in the add-on configuration window, but this appears when used:
imagen

So, went deep into the folder path until reached the Anki2 folder… For my surprise, these two "ang_db and config.json" files don't exist there but in the user_files folder. No clue what's going on.

Bulk option?

Is it possible to make sentences in bulk? Only 1 per card, but not having to do each one manually?

Problem: Selecting from a list of all sentences

I have come across an issue, where this happens: When I choose a sentence from a list of all available sentences in tsv file containing the word, the sentence is pasted into the field, but each character is in its own separate line.
sentence_adder_tatoeba

Suggestion: Ability to add Tatoeba ID to a field / audio

Hi, krmanik! Thanks again for your work, this is really useful.

I am trying to add some sentences to my cards, but I want to use the ones that have audio. I have downloaded a list with sentences with audio I am interested in. This is a tsv file that includes Sentence ID [tab] Sentence [tab] Sentence translation (if available).

What I'd like to do is to add the audio or the audio link to the note. To do that I need to know the Sentence ID and then create a link to or download the mp3 from https://audio.tatoeba.org/sentences/[languagecode]/[SentenceID].mp3. For example for Chinese sentence 332421, the audio link would be https://audio.tatoeba.org/sentences/cmn/332421.mp3.

Adding the link to a given field or even just the Sentence ID would be immensely helpful. I could then look for the audio myself or create the link with Find and replace or whatever.

Unfortunately I am unable to create a PR since I can't code, so I hope you consider it. Thanks again in any case!

ModuleNotFoundError: No module named 'PyQt5' on MacOs

Other addons don't need it so I guess that it's not ok?

Anki 23.10.1 (fac9e0ee) Python 3.9.15 Qt 6.5.3 PyQt 6.5.3
Platform: macOS-13.5.2-arm64-arm-64bit
Flags: frz=True ao=True sv=3
Add-ons, last update check: 2023-12-23 21:25:04

When loading Sentence adder for any language with batch add option:
Traceback (most recent call last):
File "aqt.addons", line 245, in loadAddons
File "/Users/lenanetka/Library/Application Support/Anki2/addons21/1682655437/init.py", line 22, in
from PyQt5 import QtWidgets, QtCore
ModuleNotFoundError: No module named 'PyQt5'

Sentences between specific lengths?

Hey! Hope you're doing fine :)
Is it possible to make it so one can choose a minimum and maximum length for fetching sentences?
Say for example sentences between 1 and 5 in length, and not specifically 4,5 or 10 in length only.
Would be cool!

Stuck and unresponsive when unable to find a word in the database - Batch Adder

When unable to locate a word in the database while using Batch Adder mode, it gets stuck and unresponsive. If I wait, it does nothing, but in single mode, it shows "create database or change language options...".
I'm using Anki Version ⁨2.1.65 (aa9a734f)⁩
I downloaded the tsv (English sentences) from tatoeba. added language to db.

BTW thanks for the useful add-on.

Error with tsv file

Hi, I was the one that rate bad a few hours ago because of an error. Here is my preview message and below I add the files you requested me:

deutsch_sentences TSV file.zip
english_sentences TSV file.zip
frances_sentences TSV file.zip
japanesse_sentences TSV file.zip

Hi, I've tried many times to launch the addon but it keeps sending me an error when I try to load the language data with the tsv document. Could you please assist me with this one? I´m a little bit stuck right now. I will update de rating when everything runs ok! ok?

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 on the add-on support site.
Debug info:
Anki 2.1.42 (8eebfe18) Python 3.8.6 Qt 5.14.2 PyQt 5.14.2
Platform: Windows 10
Flags: frz=True ao=True sv=2
Add-ons, last update check: 2021-03-30 00:34:31

Caught exception:
Traceback (most recent call last):
File "C:\Users\Valde\AppData\Roaming\Anki2\addons21\1682655437_init_.py", line 95, in createDB
for row in reader:
File "C:\python\lib\codecs.py", line 322, in decode
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbc in position 10: invalid start byte

### Update: Here I attach images of what appears today 30/03/2021

image
image
image
image

If I try once again it sends me this:
image

But actually, there's no language loaded:
image

And, to be clear, it happens with all of the tsv files, with all the 4 languages that I tried to upload

Something to consider is that in the files directory of the addon it does appear the language:
image
image

Error Message on Anki

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 on the add-on support site.
Debug info:
Anki 2.1.42 (8eebfe18) Python 3.8.6 Qt 5.14.2 PyQt 5.14.2
Platform: Mac 10.16
Flags: frz=True ao=True sv=2
Add-ons, last update check: 2021-03-21 11:48:36
Add-ons possibly involved: ⁨Sentence adder for any language⁩

Caught exception:
Traceback (most recent call last):
File "/Users/user/Library/Application Support/Anki2/addons21/1682655437/init.py", line 87, in createDB
curs.execute(
sqlite3.OperationalError: table examples already exists

Option for prefering shorter sentences

When learning monolingually or wanting shorter sentences this would be excellent.
Could be a tickbox so one could choose to have only long or short sentences!

some ideas to improve your brainchild!!

on 3/25/2021
Wow, amazing!!
<3 I has tried to use your add-on which is a significant idea.
@@@@@@ A number of functions may be useful and attracting to users:

  • allow users create their own databases with simple file types, such as TXT, excel, tsv,.. => It's is better to have more tools assist creating database easily; small, simple but powerful.
  • A simple tool (may be integral) for splitting text into sentences to create databases automatically
  • use separate databases for each fields
  • bulking creating function: should have a warning window which inform us when it finishes tasks
  • highlight words which is substituted, for instance:
    love -> I <u>love</u> you in result.
    I love you.
    => options
  • can choose source field and destination field in editor or browser
  • base on keyword/a specific field => can select a export field in editor (1)
  • base on keyword/a specific field => can select export fields from different databases in editor (2)
  • add shortcut to perform typical tasks+
  • compatible with Edit Field During Review (Cloze) https://ankiweb.net/shared/info/385888438 + shortcut
  • some functions are similar to https://github.com/sth2018/FastWordQuery <3
  • reduce (options) spaces of extracted sentences
  • can select the number of exporting sentence: 1/2/3/..
    +...

Many thanks!

--- solved

  • bulking creating function doesn't work on the newest Anki. => it works properly (25-03-2021)

--- 2021-03-25 <3 Congratulations!

Option for download audio

Nice addon! It would be really nice if you have an option do batch download audio as well. Every sentence on tatoeba has an ID and the audio ID is the same of the sentence. On the download page of tatoeba you can donwload a tsv file that shows only sentences with audio. You can cross references there!

putting any HTML to set the target word apart in a sentence (not just colors)

Would it be possible to implement the option adding custom HTML to wrap around the target word (say, if I wanted bold; target word; now there are some tatoeba sentences which already include this so it would probably require to strip formatting from tsv file and then wrap custom formatting around a target word...) and not just the color when in the config? If it has already been added and I did not notice, my bad. Also, I noticed, that even if adding just one sentence, it adds a line break, which has a tendency to multiply and annoy :D ...

I am no programmer and I have not the slightest idea how much work it includes but I was just wondering, I tend to just emphasize the target words with bold.

Anyway, thanks for your work!

Problem with word matching

If a word is contained within another word, for example
et is contained within toilette
Then the sentence generator considers toilette as a valid sentence for et, which it isn't obviously and et is a different word in french.

Error in Batch Adder

Hello, I've been using this add-on for a while and I love it. You've saved me hours of work. Thank you.

After the last update, I am able to add sentences to a single card but I'm getting an error when I'm trying to batch add them to multiple cards. I've tried reinstalling but nothing changed.


Debug info:
Anki 2.1.44 (b2b3275f) Python 3.8.6 Qt 5.14.2 PyQt 5.14.2
Platform: Windows 10
Flags: frz=True ao=True sv=2
Add-ons, last update check: 2022-06-20 22:58:12

Caught exception:
Traceback (most recent call last):
  File "C:\Users\.....\AppData\Roaming\Anki2\addons21\1682655437\batch_edit.py", line 111, in <lambda>
    action.triggered.connect(lambda x, b=browser: onSentenceBatchEdit(b))
  File "C:\Users\......\AppData\Roaming\Anki2\addons21\1682655437\batch_edit.py", line 103, in onSentenceBatchEdit
    dlg = SentenceBatchEdit(browser, nids)
  File "C:\Users\.....\AppData\Roaming\Anki2\addons21\1682655437\batch_edit.py", line 39, in __init__
    note_type = self.mw.col.get_note(nid).note_type()
AttributeError: 'Collection' object has no attribute 'get_note'

Btw I'm really glad that you've added a limiter to sentences lengths, if I could give one suggestion it would be the ability to blacklist words. Tatoeba's English depository have a lot of sentences with Albania for some reason.

When Will Sentence Pairs Be Available?

I downloaded sentence pairs for two langauges and imported into my Anki deck. I freeze all the cards and then browse for sentences when I need them. Unfortunately this has maxed out my sync account. Do you have any idea when the Sentence pairs will be available through your add-on?

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.