I always thought that a lazy programmer is a good programmer. Why? Because ask the hardworking to do something, he will go and do it. A lazy programmer will spend 2-3 times more time, but he will write a script that will - do it for him. Perhaps, for the first time, an unreasonable amount of time will be spent on this, but subject to repeated tasks, this approach very quickly pays off. I consider myself a lazy programmer. It was a preamble, and now let's get to the point.
A few years ago, I wondered how I could improve my English. Nothing better than reading literature came to mind. An electronic reader was purchased, books were uploaded, and I began to read. In the process of reading, unfamiliar words constantly came across. I immediately translated them through the built-in dictionaries in 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, then with a 90% chance I again needed to be translated, and so every time. The conclusion was that it was 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 hardly possible. Then I remembered that I once read about Interval repetitions .
What is it and what does it eat? In short, there is such a forgetting curve , further quoted from Wikipedia:
Already during the first hour, up to 60% of all received information is forgotten, 10 hours after memorizing, 35% of the studied one remains in memory. Then the process of forgetting goes slowly, and after 6 days about 20% of the total number of originally learned syllables remain in memory, the same amount remains in memory after a month.
And the output is here.
Conclusions that can be made on the basis of this curve is that in order to effectively memorize it is necessary to repeat the memorized material.
Here we come to the idea of interval repetition .
ANKI is an absolute free, open source program that implements the idea of ​​interval repetition. Simply put, computerized flash cards, on one side a question, on the other an answer. Since you can do questions / answers using normal html / css / javascript , you can say that it has truly unlimited possibilities. In addition, it is extensible with special plug-ins , and one of them will be very useful in the future.
Manually creating cards is long, tedious, and with a high probability after a while you are on - you will score this business and therefore I asked myself at some point whether it was possible to automate this business. The answer is yes, you can. And I did it. I will say right away that this is more POC (Proof of concept) , but which can be used. If there is interest from users and other developers will catch up, then it can be brought to the finished product, which even technically illiterate users can use. Now the use of my utility implies some programming knowledge.
I read books using the AIReader program. It has the ability to connect external dictionaries, as well as when translating a word, it saves the word to which you called the translation into a text file. It remains to be easy, translate these words and create ANKI cards.
At first I tried to translate Google Translate , Lingvo API , etc. But with free services it did not go. I exhausted the free limit even during the development process, besides, under the license terms, I had no right to cache words. At some point, I realized that I need to translate the words myself. As a result, the dsl2html module was written to which DSL dictionaries can be connected and which can convert them to HTML format.
This is what a dictionary entry in * .html looks like, my version in comparison with GoldenDict
Before looking for a word in the connected dictionaries, I bring it to the dictionary form (lemma) using the Stanford CoreNLP library. 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 the node-java library with which you can relatively simply execute Java code from nodejs and part of the code is written in JavaScript. If I had found this library before, then Java would not have written a single line. Another side project that was born in the process is the creation of a repository with DSL documentation which was found on the network in the * .chm format, converted and brought into a divine form. If the author of the original file is a user by the nickname yozhic, he sees this article then thank him very much for the work done, without his documentation, I probably would have failed.
So, I have a word in English, its dictionary entry in the * .html format, it remains to put everything together, create ANKI entries from the list of words and enter them into the ANKI database. For this purpose, the following data2anki project was created. He knows how to input a list of words, translate, create ANKI * .html articles and write them to the ANKI database. At the end of the article there is an instruction how to use it. In the meantime, the second story where interval repetitions can be useful.
All people in search of a more / less qualified specialty, including programmers, are faced with the need to prepare for an interview. Many concepts that ask for an interview are not used in everyday practice and are forgotten. During the next preparation for the interview, scrolling through the notes, the book, the reference book, I was faced with the fact that it takes a lot of time and attention to weed out the information that you already know because it is not always obvious and you have to read it to understand that this irrelevant. When you approach a topic that you really need to repeat, it often happens that you are already tired and the quality of training suffers. At some point, I thought, why not use ANKI cards for this? For example, when taking notes of a topic, immediately create a summary in the form of a question - an answer, and then when you repeat it, you will immediately know if you know or not the answer to this question.
The problem arose only in that filling the questions is very long and tedious. To facilitate the process, in the data2anki project I added the functionality to convert the markdown text to ANKI cards. All you need is to write one large file in which questions and answers will be marked with a predetermined sequence of characters, according to 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 appropriate card (s) and run the program again, and a new version will be created.
Install ANKI + AnkiConnect
Install data2anki
git clone https://github.com/anatoly314/data2anki
cd data2anki && npm install
Use to translate words:
In the data2anki / config.json file :
in the mode key you write the value dsl2anki
in the key modules.dsl.anki.deckName and modules.dsl.anki.modelName you register, respectively, the Deck Name and Model Name (must already be created before creating the cards). Now only the Basic type model is supported:
Has one and all fields. The text can be entered in the text.
where the source word is Front field , and the translation will be in the Back field .
There is no problem to add support for Basic (and reversed card) , where a reverse card will be created for the word and translation, where the translation will need to recall the original word. You just need time and desire.
In the key modules.dsl.dictionariesPath you write an array with connected * .dsl dictionaries. Each connected dictionary is a directory in which the dictionary files are located according to the format: DSL dictionary structure
In the key modules.dsl.wordToTranslatePath you specify the path to the list of words you want to translate.
node data2anki\index.js
Uses for making cards from markdown
In the data2anki / config.json file :
In the key modules.markdown.selectors.startQuestionSelectors and modules.markdown.selectors.startAnswerSelectors you register selectors with which you mark the beginning of the question and answer, respectively. The line with the selector itself will not be sent and will not get into the card, the parser will start working from the next line.
# QUESTION # ## Question 5. Write a mul function which will work when invoked with following syntax. `` javascript console.log (mul (2) (3) (4)); // output: 24 console.log (mul (4) (3) (4)); // output: 48 `` ` # ANSWER # The following is how it works: `` javascript function mul (x) { return function (y) {// anonymous function return function (z) {// anonymous function return x * y * z; }; }; } `` ` It is a function of a multifunctional function. In the junction of the junction, it is a function. - A function is an instance of the Object type - A function can - 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
An example is taken from here: 123-JavaScript-Interview-Questions
There is also an example file in the examples/markdown2anki-example.md
project folder.
node data2anki\index.js
Received on the desktop version of ANKI cards without any problems are synchronized with the ANKI cloud (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 to spend, instead of aimlessly flipping through Facebook or seals on instagram, you can learn something new.
As I already mentioned, this is rather a working POC that can be used than a finished product. Somewhere 30% of the standard of the DSL parser is not implemented, and therefore, for example, not all dictionary entries that are in the dictionaries can be found , there is also an idea to rewrite it in JavaScript , because you want "consistency", and besides, it is now written not very optimal. Now the parser builds a tree, and this is superfluous and it does not need to complicate the code. In the markdown2anki mode, the pictures are not parted. I will try to slowly cut, but, as long as I am writing for myself, I will first of all decide those rakes that I will attack myself, but if someone wants to help, then you are welcome. If there are questions about the program, I will be happy to help through open issues in 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 will correct everything.
Source: https://habr.com/ru/post/454236/