krmanik / Sentence-Adder-Anki-Addon

Add sentences to Anki editor window in one click
GNU Affero General Public License v3.0
14 stars 6 forks source link

Ability of providing own tsv file? #7

Open ghost opened 3 years ago

ghost commented 3 years ago

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?

krmanik commented 3 years ago

It is possible, you have to download init .py and editor.py and copy in add-ons folder. Along with edit config.json. More info in this issues https://github.com/infinyte7/Sentence-Adder-Anki-Addon/issues/5

If need more information comment it, I will try to add the required details.

danijelkvc commented 3 years ago

Hey, I would really like to add my own file with sentences but I don't understand the terminology used here and I don't know how to do it. The way you explain everything on the anki add on page and on youtube is very very good so if you have time to do something similar with how to import our own files that would be great. We noobs would be thankful !

ghost commented 3 years ago

Hey, I would really like to add my own file with sentences but I don't understand the terminology used here and I don't know how to do it. The way you explain everything on the anki add on page and on youtube is very very good so if you have time to do something similar with how to import our own files that would be great. We noobs would be thankful !

I managed to do this by formatting my desired text file with regex in Sublime Text. Just replacing every . (dot) with: .\t\n so you get a dot, tab and new line. Did this with all Harry Potter books and it worked flawlessly! Just remember to save it as .tsv

danijelkvc commented 3 years ago

Hey,

Thank a lot. I managed to create a tsv file from a book (so cool) but I don't understand how to upload it into add on in Anki. I see that you already wrote how to use another tsv file for the add on but I am a noob so I don't understand. It would mean soo much if you would explain in more detail.

ghost commented 3 years ago

To upload the book into anki you need to go to Tools -> Sentence adder: image Where it says language, just put the name of the database you want to make, for example I put ITHP for Italian Harry Potter. If your langugae contains spaces between the words, check that box, if not then disable it. image After this go to browse and select a few words and go to the menu and look for Sentence Batch Adder: image Here you now select from which field the sentences fetch the desired word. So the sentence gets matched to a field which contains the word you want to see in context. For example: If the field Expression contains the word Like and you want a sentence with Like, you would select Expression and tell it where to put the sentence, for example into the Sentence field. image

This is all if you want the sentences related to a specific field or word. If you just want to import the book in sentence format without anything related to it, just go to File-> Import and you'll be done! Hope it's clear :)

danijelkvc commented 3 years ago

To upload the book into anki you need to go to Tools -> Sentence adder: image Where it says language, just put the name of the database you want to make, for example I put ITHP for Italian Harry Potter. If your langugae contains spaces between the words, check that box, if not then disable it. image After this go to browse and select a few words and go to the menu and look for Sentence Batch Adder: image Here you now select from which field the sentences fetch the desired word. So the sentence gets matched to a field which contains the word you want to see in context. For example: If the field Expression contains the word Like and you want a sentence with Like, you would select Expression and tell it where to put the sentence, for example into the Sentence field. image

This is all if you want the sentences related to a specific field or word. If you just want to import the book in sentence format without anything related to it, just go to File-> Import and you'll be done! Hope it's clear :)

Thank you for your effort! I am using this add on for learning 8000 difficult words in a foreign language for my exam. Front and back of the cards has a word. The front is the ''difficult'' word and the back has a synonym word which is ''easy'' but I usually don't understand it. That's why I use example sentences that contain the word to learn and better understand them, which works fine but it takes a lot of time. I was looking for an add on that will import example sentences to the difficult words automatically thus saving me time and effort. This add on works perfectly but the .tsv file from tatoeba contains only a few sentences so I was planning to upload my own .tsv file with a lot more. I managed to convert a book to .tsv file (I used the book just to try it out, if it works I will use a bigger database with more sentences) with your help through Sublime Text, but when I try to upload it to -add new language database- in the add on, I get this message-

Anki 2.1.40 (cf446733) Python 3.8.6 Qt 5.14.2 PyQt 5.14.2 Platform: Mac 10.15.7 Flags: frz=True ao=True sv=1 Add-ons, last update check: 2021-07-01 20:31:34 Add-ons possibly involved: ⁨Sentence adder for any language with batch add option⁩

Caught exception: Traceback (most recent call last): File "/Users/danielkovacs/Library/Application Support/Anki2/addons21/1682655437/init.py", line 96, in createDB to_db = [row[2]] IndexError: list index out of range

Sorry for the long post :) Daniel

ghost commented 3 years ago

Happened to me too. Check any line which could contain special characters as a first character. For example: ! Hello, how are you? or » was what she said Sometimes the line-breaks when transforming a book to text do strange things. I've had some problems with this so usually before creating the tsv file I do these checks and it always works :)

danijelkvc commented 3 years ago

Hey, I tried that and I tried to do it with only a few sentences and I always get this Caught exception: Traceback (most recent call last): File "/Users/danielkovacs/Library/Application Support/Anki2/addons21/1682655437/init.py", line 96, in createDB to_db = [row[2]] IndexError: list index out of range

Idnk why it says list index out of range and what does it mean ?

ghost commented 3 years ago

Seems to be a problem of where the \ŧ (tab) is cutting the sentence. Each sentence should end at a . (dot) and then you should have a \t\n meaning tab and new line. Try removing the created .db file in the addon folder and create a new one. That solved it for me :)

danijelkvc commented 3 years ago

Hey, I took screenshots of what I am doing because I think that I am doing something wrong. I think the problem I have is with making a .tsv file that looks like the one provided by the guy who made the add-on. It looks very broken as you can see in the screenshot below. I tried a million different things but It always looks very bad for some reason.

Thank you for your help by the way.

On Tue, Jul 6, 2021 at 4:26 PM Yannick Oberhauser @.***> wrote:

Seems to be a problem of where the \ŧ (tab) is cutting the sentence. Each sentence should end at a . (dot) and then you should have a \t\n meaning tab and new line.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/infinyte7/Sentence-Adder-Anki-Addon/issues/7#issuecomment-874808561, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASMYFA4OC6FVSHNVBDCHO2TTWMHBJANCNFSM42KMGMDA .

krmanik commented 3 years ago

Hi, Can you share the tsv file? Because the formatting of file is important.

Every row should contains equal number of columns. If row have empty column then row should contains equal numbers tab.

Incredibus commented 3 years ago

Hey infinyte7! I really like the idea of your add-on! I just have the bug, which was already reported earlier:

Debuginformationen: 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: 2021-07-31 20:55:53

Caught exception: Traceback (most recent call last): File "C:\Users\peter\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 0xb6 in position 15: invalid start byte

I would like to use your add-on for an italian database full of sentences. It is attached to this message. Would appreciate it, if you could look for the issue!

Thanks in advance!!! :)

EDIT: Unfortunately I can't add the italian database.