From 54843bbb2ca4f19acb16509e0f13b7b317ed5da3 Mon Sep 17 00:00:00 2001 From: Szymon Studniarz Date: Fri, 14 Jan 2022 21:44:52 +0100 Subject: [PATCH 1/4] modify card layout for better clarity --- createAPKG.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/createAPKG.js b/createAPKG.js index 042ebf2..900f47a 100644 --- a/createAPKG.js +++ b/createAPKG.js @@ -51,11 +51,16 @@ const createAPKG = ({ vocab, dict }) => { card: { fields: ['word', 'meaning', 'usage'], template: { - question: '{{word}}', + question: '

{{word}}

{{usage}}

', answer: ` -
{{word}}
+

{{word}}

{{meaning}}
{{usage}}
+ ` } } From 959589a6852c79e90ddda6fbc3e475e9f38d5797 Mon Sep 17 00:00:00 2001 From: Szymon Studniarz Date: Fri, 14 Jan 2022 21:46:00 +0100 Subject: [PATCH 2/4] change how script looks for words, different separator Finding words didn't work for me, result was always empty, so no records were added to database, and apkg were created without definition. To overcome it I've changed faulty jquery (I suppose) to separating words with substring, which searches for closing tag of h2 (opening tag was the most suitable for separator for my dictionary, as it was before every word, after the word comes the closing tag), and then assigning substring before closing tag to word, and the rest after the closing tag to the definition. This way query now works like a charm, but it might not work for every dictionary, as layout might differ, so further research is required. --- createDictDatabase.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/createDictDatabase.js b/createDictDatabase.js index 132cbad..2cdacc4 100644 --- a/createDictDatabase.js +++ b/createDictDatabase.js @@ -13,23 +13,29 @@ function createDictDatabase({ input: rawml, output: database }) { const src = createReadStream(rawml) src - .pipe(new Separator({ separator: '
' })) + .pipe(new Separator({ separator: '

' })) .on('data', chunk => { let html = chunk.toString().trim() let $ = cheerio.load(html) - let $word = $('word') + + //let $word = $('word') + + let $word = html.substring(0, html.indexOf("

") - 1) + html = html.substring(html.indexOf("")+6) if (!$word.length) { return } - let words = $word - .map((_, word) => { - word = $(word) - word.find('sup').remove() - return word.text().replace(/,?\s*$/, '') - }) - .get() + //let words = $word + // .map((_, word) => { + // word = $(word) + // word.find('sup').remove() + // return word.text().replace(/,?\s*$/, '') + // }) + // .get() + let words = new Array(); + words.push($word); const sql = `INSERT INTO dictionary (word, meaning) VALUES ( '${doubleQuote(words.join('|'))}', '${doubleQuote(html)}')` From 1539df9095f2635beb2610e202f48a020141553a Mon Sep 17 00:00:00 2001 From: Szymon Studniarz Date: Fri, 14 Jan 2022 22:05:07 +0100 Subject: [PATCH 3/4] update readme --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 851017c..1297fda 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # Export Kindle Vocabulary Builder to Anki APKG +ATTENTION!!! +If you encounter trouble running the script, try using nodejs v10.0 version, then remove node_modules folder and try again. It worked for me, hope it will work for you as well. +Also if dict.db file is empty (weights around 8KB), or despite taking some more space Anki flashcards are deprived of definitions from the dictionary of your choice, then open the .rawml file and createDictDatabase.js, find what separates definitions (for me it was opening h2 tag), and also look what is after the word, for me it was (no surprise) closing h2 tag. Then change the values in createDictDatabase.js file for those which suits your needs. + ![](./kindle_anki.png) [Vocabulary Builder](https://www.amazon.com/gp/help/customer/display.html?nodeId=201733850) is one of my favorite features on Kindle. With a tap on the word, it pops up a window displaying definitions and at the same time creates a flashcard in the background. What's more, it saves the sentences where the word appreares, which makes it easier to remember words. However, E-Ink is not ideal for frequent paging, and it seems that Vocabulary Builder doesn't have an algorithm on tracking forgeting curve. From 8131d7bd434b0cfb7c6d801d7e89dca28ba9aad2 Mon Sep 17 00:00:00 2001 From: Szymon Studniarz Date: Sat, 15 Apr 2023 15:12:47 +0200 Subject: [PATCH 4/4] [info] add comment about plans for the future --- createDictDatabase.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/createDictDatabase.js b/createDictDatabase.js index 2cdacc4..97a6e68 100644 --- a/createDictDatabase.js +++ b/createDictDatabase.js @@ -11,6 +11,8 @@ function createDictDatabase({ input: rawml, output: database }) { const db = new Database(database) db.exec('CREATE TABLE dictionary(word text, meaning text)') + //I will introduce some changes there + const src = createReadStream(rawml) src .pipe(new Separator({ separator: '

' }))