Skip to content
/ lat Public

Tools to automate language acquisition through immersion. Includes sentence analysis (from books, subtitles) and Anki cards creation.

License

Notifications You must be signed in to change notification settings

pigoz/lat

Repository files navigation

LaT

Overview

Language Tools is a set of tools to automate language acquisition through immersion. Includes sentence analysis (from books, subtitles) and Anki cards creation. The most interesting feature is looking up Japanese words of the current subtitle line, and exporting the current subtitle line to Anki. A screenshot is worth a lot more than words, so here's two screenshots:

Automatic anki card creation

Words lookup inside mpv

Installation

  1. Install the required dependencies
  • mpv master (the current stable release doesn't have the new scripting interface used here)
  • myougiden (I'm working on internal dictionaries, but it will take a while)
  • mecab
  • ffmpeg
  • ruby
  1. Install Bundler
$ gem install bundler
  1. Clone repository and install dependencies
$ git clone https://github.com/pigoz/lat.git
$ cd lat
$ bundle install
  1. Create a symbolic link in your mpv scripts folder
$ ln -nfs bin/lat-mpv ~/.mpv/scripts/lat.run

NOTE Sometimes the mpv scripts folder might be following the XDG spec and be located in ~/.config/mpv/scripts

Configuration

You have to create a config file at ~/lat.yaml or $XDG_CONFIG_HOME/lat/config.yaml.

Minimal required config file

anki:
  collection: ~/Library/Application Support/Anki2/User 1

Full config file

anki:
  collection: ~/Library/Application Support/Anki2/User 1
  export:
    deck_name: sub2srs
    tag_name: sub2srs
    note_type: Japanese sub2srs
  fields:
    source: Source
    line: Line
    reading: Reading
    words: Words
    time: Time
    sound: Sound
    image: Image

blacklist:
  morphemes:
    active: false
    fields:
      - note_type: Japanese sub2srs
        field_name: Line
  files:
    - share/blacklist.txt

NOTE Click here for more details on Anki media collection folder

NOTE To use subdecks in anki.export.deck_name, simply add :: after parent deck (eg: Japanese::sub2srs)

NOTE To not export a field to Anki set it's value to null. (eg: time: null will skip the time field)

mpv default bindings

  • l and GAMEPAD_ACTION_UP are bound to the dictionary lookup
  • b triggers card creation mode starting from the current subtitle
  • g triggers card creation mode and automatically selects 1 adjacent subtitles lines

Myougiden

Install myougiden if haven't already and you need compile the dictionary database at least once

$ sudo updatedb-myougiden -f

Improvement from mpv-nihongo

  • Code is much better, and every part is test driven which makes adding new features easier
  • Dictionary access is multithreaded
  • Generated furigana matches the sigle Kanji, which results in a much nicer alignment. i.e.: 先[せん] 生[せい] instead of 先生[せんせい]. I have a very visual memory so this helped me immensely, and was the feature I could not add to mpv-nihongo since the code was so bad.
  • You can also add stuff to Anki that comes from books (and the code uses TTS to create audio)
  • Blacklist based on your subs2srs deck (BETA)

About

Tools to automate language acquisition through immersion. Includes sentence analysis (from books, subtitles) and Anki cards creation.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published