📜 ⬆️ ⬇️

Learn the language by watching serials: vlc + lua + stardict + wordnet + anki = l'amour

I really like to watch serials, and I also learn languages ​​with their help. And if earlier I diligently stopped the video on an incomprehensible place, rewound it back, turned on the subtitles and scored unfamiliar words in Anki, now I am doing the same. Is that too lazy to automate this process, which led to the creation of the Say It Again extension for the VLC player with the following features:



Say It Again screenshot

')

But why?


At some point, I realized that watching TV shows with the included subtitles stopped giving tangible results (except for speeding up reading). But, turning off the subtitles, I came across a flurry of incomprehensible words. I had to rewind the video back (of course, either not enough or too far from the right place ), include subtitles, stop playback, search for unfamiliar words in the dictionary, write them in a separate file, then score in Anki (sometimes with context, a phrase from the movie!) - in general, hemorrhoids. Hence the idea of ​​expansion, which I use today, and which I want to share with the public. It allows you to automate the process of saving words with context to a text file of this type:
Sample export file
desecrate [ˈdesɪkreɪt] , , You've desecrated my owls. Weeds S07E12



How to use it?


In fact, not the most user-friendly process, but there's nothing you can do. The script was tested on VLC 2.0.5 under Windows.
  1. Download the latest version of the say_it_again.lua script from GitHub ( direct link )
  2. Copy it, depending on the platform, into % ProgramFiles% \ VideoLAN \ VLC \ lua \ extensions or / usr / share / vlc / lua / extensions .
  3. We are looking for and download the dictionary in Stardict format ( copyright? No, not heard ). Personally, I like the Oxford American Dictionary.
  4. Unpack it. As a result, you should get three files to the dictionary: * .idx, * .dict, * .ifo. If instead of * .dict we have * .dz, then unpack it too - this is a regular zip.
  5. Download the WordNet database and also unpack them somewhere.
  6. Edit say_it_again.lua , changing dict_dir, wordnet_dir, chosen_dict .
    Settings example

  7. Run VLC, open the video file, next to which lies the subtitle file in srt format; turn on the View menu - Say It Again.
  8. Voilà - use the buttons y, u, i and backspace for appropriate actions (see above)

You can do without dictionaries ( dict_dir = nil, chosen_dict = nil ), but then the word will have to be hammered with hands, and there will be no transcription - the meaning of automation is lost.
You can also not connect wordnet ( wordnet_dir = nil ), but then the normalization of words will not work - the word was will not find the verb be in the dictionary.

Technical aspect - VLC and Lua


Starting with version 1.1, it seems, the VLC player allows you to extend its functionality with the help of Lua scripts. To do this, the extension must meet certain requirements (some are optional, but VLC will swear):
  1. Return your description as a table with the descriptor () function. The format of the table can be viewed in the finished scripts in the vlc addons repository ;
  2. Have functions activate (), deactivate ();
  3. Depending on the capabilities specified in the description table, the functions needed are input_changed (), meta_changed (), menu (), trigger_menu ();
  4. The maximum can be one dialog box for the extension. Hacking with the removal and re-creation of a dialogue again leads to VLC crashes.

In general, it must be said that the extension mechanism is rather crude, and VLC falls without warning literally from any sneeze. Here are some points that I noted for myself:

Working with Stardict and WordNet formats, as well as exporting to Anki


Description of formats Stardict and WordNet led Bienne in his article , so I will not repeat. Export to Anki works through a csv file. The sequence of the fields in it is hardcoded in accordance with the following card model (or, as it is now called, Note Type):
View screenshots



Import process:


Epilogue


The extension was created for own needs, and its concept changed in the process of writing and use. From here follows a slightly chaotic code and a frightening appearance. Nevertheless, I hope that these developments will seem interesting to someone.

Upd


Now it works on Linux (tested in Ubuntu 12.10 64bit; vlc 2.0.5).

Source: https://habr.com/ru/post/169351/


All Articles