Two stories about how ANKI can help you learn a foreign language and prepare for an interview

I have always believed that a lazy programmer is a good programmer. Why? Because ask a hardworking person to do something, he will go and do it. And a lazy programmer will spend 2-3 times more time, but write a script that will do it for him. It may be unreasonably time consuming the first time, but given repetitive tasks, this approach pays off very quickly. I consider myself a lazy programmer. That was the preamble, now let's get down to business.

History first

A few years ago I thought about how I could improve my English. Nothing better than reading literature came to mind. An electronic reader was purchased, books were downloaded and I began to read. In the process of reading, unfamiliar words constantly came across. I immediately translated them using the dictionaries built into the reader, but I noticed one feature: the words did not want to be remembered. When I met this word again after a few pages, with a 90% probability I again needed a translation, and so every time. The conclusion was that it is not enough just to translate unfamiliar words in the process of reading, you need to do something else. The ideal option would be to introduce it into use and start using it, but I do not live in an English-speaking country and this is not possible. Then I remembered that I once read about Spaced repetitions.

What is it and what is it eaten with? In short, there is forgetting curveHere is a quote from Wikipedia:

Already during the first hour, up to 60% of all the information received is forgotten, 10 hours after memorization, 35% of what has been learned remains in memory. Further, the process of forgetting goes slowly, and after 6 days about 20% of the total number of originally learned syllables remains in memory, the same amount remains in memory after a month.

And the conclusion

The conclusions that can be drawn on the basis of this curve are that for effective memorization it is necessary to repeat the learned material.

So we came up with the idea spaced repetition.

ANKI is a completely free and open source program that implements the idea of ​​spaced repetition. Simply put, computerized flash cards, on one side is a question, on the other is an answer. Since you can do questions/answers with a normal html / css / javascript, then we can say that it has truly limitless possibilities. In addition, it is expandable with special plugins, and one of them will be very useful to us in the future.

Manually creating cards is long, tedious, and with a high probability after a while you will score this business, and therefore at some point I asked myself the question, is it possible to automate this business. The answer is yes, you can. And I did it. Let me tell you, it's more POC (Proof of concept), but which can be used. If there is interest from users and other developers catch up, then it can be brought to a finished product that even technically illiterate users can use. Now, using my utility implies some programming knowledge.

I read books using the program AI Reader. She has the ability to connect external dictionaries, and when translating a word, she saves the word for which you called the translation into a text file. The only thing left is to translate these words and create ANKI cards.

At first I tried to use to translate Google Translate, Lingvo API etc. But with free services, things did not work out. I exhausted the free limit during the development process, in addition, according to the terms of the license, I did not have the right to cache words. At some point, I realized that I needed to translate the words myself. As a result, the module was written dsl2html to which you can connect DSL dictionaries and who knows how to convert them into HTML format.

This is what a dictionary entry looks like in *.html, my variant in comparison with the variant GoldenDict

Two stories about how ANKI can help you learn a foreign language and prepare for an interview

Before looking up a word in the connected dictionaries, I bring it to dictionary form (lemma) using the library Stanford Core NLP. In fact, because of this library, I started writing in Java and the original plan was to write everything in Java, but in the process I found a library node java with which you can relatively easily execute Java code from nodejs and part of the code is written in JavaScript. If I had found this library earlier, not a single line would have been written in Java. Another side project that was born in the process is the creation repository with DSL documentation which was found on the net in the format *.chm, converted and brought to the divine form. If the author of the original file is a user by nickname yozhic sees this article, then a big thank you to him for the work done, without his documentation, I most likely would not have succeeded.

So, I have a word in English, its dictionary entry in the format *.html, it remains to bring everything together, create ANKI articles from a list of words and enter them into the ANKI database. For this purpose, the following project was created data2anki. He can take a list of words as input, translate, create ANKI *.html articles and record them in the ANKI database. At the end of the article there is an instruction on how to use it. In the meantime, the second story is where spaced repetitions can be useful.

The second story.

All people in search of a more / less qualified specialty, including programmers, are faced with the need to prepare for an interview. Many of the concepts that are asked in an interview you do not use in everyday practice and they are forgotten. In the next preparation for an interview, leafing through a summary, a book, a reference book, I was faced with the fact that it takes a lot of time and attention to weed out information that you already know because it is not always obvious and you have to read it carefully to understand what it is. irrelevant. When you come to a topic that really needs to be repeated, it often happens that you are already tired and the quality of preparation suffers. At some point, I thought, why not use ANKI cards for this as well? For example, when taking notes on a topic, immediately create a summary in the form of a question - answer, and then when you repeat, you will immediately know whether you know the answer to this question or not.

The problem arose only in the fact that filling questions is very long and tedious. To make the process easier, data2anki project I added functionality to convert markdown text in ANKI cards. All you need is to write one big file, in which questions and answers will be marked with a predetermined sequence of characters, by which the parser will understand where the question is and where the answer is.

After this file is created, you run data2anki and it creates ANKI cards. The original file is easy to edit and share, you just need to erase the corresponding card(s) and run the program again, and a new version will be created.

Installation and use

  1. Installing ANKI + AnkiConnect

    1. Download ANKI from here: https://apps.ankiweb.net/
    2. Install AnkiConnect plugin: https://ankiweb.net/shared/info/2055492159

  2. Installation data2anki

    1. Downloading data2anki from github repository
      git clone https://github.com/anatoly314/data2anki
    2. Install dependencies
      cd data2anki && npm install
    3. Download java dependencies https://github.com/anatoly314/data2anki/releases/download/0.1.0/jar-dependencies.zip
    4. Unpack jar-dependencies.zip and put its content in data2anki/java/jars

  3. Usage for translating words:

    1. In file data2anki/config.json:

      • in the key Fashion prescribe the value dsl2anki

      • in the key modules.dsl.anki.deckName ΠΈ modules.dsl.anki.modelName write, respectively, deck name ΠΈ Model Name (should already be created before creating cards). Currently only model type is supported Basic:

        Has Front and Back fields, and will create one card. Text you enter in Front will appear on the front of the card, and text you enter in Back will appear on the back of the card.

        where is the original word front field, and the translation will be in back field.

        There is no problem to add support Basic (and reverse card), where a reverse card will be created for the word and translation, where, according to the translation, you will need to remember the original word. All you need is the time and desire.

      • in the key modules.dsl.dictionariesPath prescribe an array with connected *.dsl dictionaries. Each connected dictionary is a directory in which the dictionary files are located in accordance with the format: Building a DSL Dictionary

      • in the key modules.dsl.wordToTranslatePath write the path to the list of words you want to translate.

    2. Launch with a working ANKI application
      node data2ankiindex.js
    3. PROFIT!!!

  4. Uses to create cards from markdown

    1. In file data2anki/config.json:

      • in the key Fashion prescribe the value markdown2anki
      • in the key modules.markdown.anki.deckName ΠΈ modules.dsl.anki.modelName write, respectively, deck name ΠΈ Model Name (should already be created before creating cards). For markdown2anki mode is only supported on model type Basic.
      • in the key modules.markdown.selectors.startQuestionSelectors ΠΈ modules.markdown.selectors.startAnswerSelectors prescribe selectors with which you mark the beginning of the question and answer, respectively. The line with the selector itself will not be parsed and will not get into the card, the parser will start working from the next line.

        For example, this question/answer card:

        Two stories about how ANKI can help you learn a foreign language and prepare for an interview

        It will look like this in markdown:
        #QUESTION# ## Question 5. Write a mul function which will work properly when invoked with following syntax. ```javascript console.log(mul(2)(3)(4)); // output : 24 console.log(mul(4)(3)(4)); // output : 48 ``` #ANSWER# Below is the code followed by the explanation of how it works: ```javascript function mul (x) { return function (y) { // anonymous function return function (z) { // anonymous function return x * y * z; }; }; } ``` Here the `mul` function accepts the first argument and returns the anonymous function which takes the second parameter and returns the anonymous function which takes the third parameter and returns the multiplication of arguments which is being passed in successive In Javascript function defined inside has access to outer function variable and function is the first class object so it can be returned by the function as well and passed as an argument in another function. - A function is an instance of the Object type - A function can have properties and has a link back to its constructor method - A function can be stored as variable - A function can be pass as a parameter to another function - A function can be returned from another function
        

        Example taken from here: 123-JavaScript-Interview-Questions

        There is also an example file in the project folder examples/markdown2anki-example.md

      • in the key modules.markdown.pathToFile
        prescribe, the path to the file where it lies *.md question/answer file

    2. Launch with a working ANKI application
      node data2ankiindex.js
    3. PROFIT!!!

This is how it looks on mobile:

Experience the Power of Effective Results

The cards received on the desktop version of ANKI are synchronized with the ANKI cloud without any problems (free up to 100mb), and then you can use them everywhere. There are clients for Android and iPhone, you can also use it in the browser. As a result, if you have time that you have nothing to spend on, then instead of aimlessly scrolling through Facebook or cats on Instagram, you can learn something new.

Finale

As I mentioned, this is more of a working POC that you can use than a finished product. Somewhere around 30% of the DSL parser standard is not implemented, and therefore, for example, not all dictionary entries that are in dictionaries can be found, there is also an idea to rewrite it to JavaScript, because I want "consistency", and besides, now it is not written very optimally. Now the parser is building a tree, which in my opinion is superfluous and does not need to complicate the code. IN markdown2anki mode pictures are not parsed. I will try to slowly cut, but since I am writing for myself, I will first of all solve the rake that I will step on myself, but if someone wants to help, then you are welcome. If you have any questions about the program, I will be happy to help through open issues in the relevant projects. The rest of the criticism and suggestions write here. I hope this project will be useful to someone.

PS If you notice errors (and they, unfortunately, are), write in a personal, I'll fix everything.

Source: habr.com

Add a comment