GitXplorerGitXplorer
r

cram

public
3 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
7438faeb1c5c5dfab66a3afdc052b6fb9e1636e7

rfg: Use YAML.safe_load_file convenience method

rrlue committed 3 years ago
Unverified
a270badff6def944e670c3c0f920cd31cd1cbc2b

dst: Bump to v0.0.2

rrlue committed 3 years ago
Unverified
b1bdf7c25e3c6409bbcb50c427481fa6ec566c83

ftr: Add append:google-images command

rrlue committed 3 years ago
Unverified
b972706558b81030b0603d4da4dacf7f990f7fdc

ftr: Auto-detect Anki media directory

rrlue committed 3 years ago
Unverified
d9a1562d889b94e479ed315def64c536fc1e25e1

doc: Clarify wording in zh-audio-char-hint help banner

rrlue committed 3 years ago
Unverified
269c95efd9640a600d7b49c12677edcfdf4b15b5

bfx: Fix faulty Cangjie code

rrlue committed 3 years ago

README

The README file for this repository.

🧑‍🎓 Cram

Studying with Anki? Build “notes” (flash cards) faster with cram.

Cram is a toolkit for automating the creation of CSVs that can then be imported as notes in Anki.

(Currently, cram only includes tools for studying Traditional Chinese. See the Design section to learn how you can extend cram for your own purposes.)

Installation

Requires Ruby.

See Releases to download package files for Linux.

# macOS
$ brew install rlue/utils/cram

# Debian / Ubuntu
$ sudo dpkg -i cram_0.0.4_amd64.deb

# Red Hat / Fedora / CentOS
$ sudo rpm -i cram-0.0.4-1.x86_64.rpm

# Arch Linux
$ sudo pacman -U cram-0.0.4-1-x86_64.pkg.tar.zst

# from source
$ git clone https://github.com/rlue/cram
$ cd cram
$ make install  # undo with `make uninstall`

Usage

Explicitly / verbosely

Command

$ cram extract:zh input.txt \  # Print only Chinese characters from input file, one per line, without duplicates
  | cram append:zhuyin \       # add a field to each line for that character’s 注音 pronunciation
  | cram append:cangjie \      # add a field to each line for that character’s cangjie code
  | cram append:zh-compounds \ # add a field to each line for compound words containing that character
  >> output.csv

Input

你可不可以教我怎麼用 Anki?

Output

你,ㄋㄧˇ,人弓火,~好
可,ㄎㄜˇ,一弓口,~能
不,ㄅㄨˋ,一火,對~起
以,ㄧˇ,女戈人,所~
教,ㄐㄧㄠ,十木人大,~室
我,ㄨㄛˇ,竹手戈,自~
怎,ㄗㄣˇ,人尸心,~樣
麼,ㄇㄜ˙,戈木女戈,什~
用,ㄩㄥˋ,月手,使~

Or, configure a shortcut

With the configuration below, the above command can be substituted with:

$ cram use zh-literacy input.txt
# ~/.config/cram/config.yml

pipelines:
  zh-literacy:
    extract:zh:
    append:zhuyin:
    append:cangjie:
    append:zh-compounds:
    output:
      path: ~/notes/chinese-characters.csv
      append: true

Design

Cram is built according to the UNIX philosophy:

  • Write programs that do one thing and do it well.
  • Write programs to work together.
  • Write programs to handle text streams, because that is a universal interface.

Like git, cram is actually a collection of scripts which each perform one specific task. These tasks all operate on text streams, incrementally transforming them to produce an importable CSV.

Development / Contributing

Cram can be extended with your own custom scripts. Your scripts do not have to be written in Ruby, nor do they have to be stored in cram’s installation directory.

For instance, to create a new cram extract:he command for extracting Hebrew text from a document, place your script here:

📁 $HOME/.local/lib
└── 📁 cram
    └── 📁 extract
        └── 🗎 he

You can even create bare (non-namespaced) commands by saving custom scripts directly to lib/cram/. To create a cram foo command, use:

📁 $HOME/.local/lib
└── 📁 cram
    └── 🗎 foo

All CLI arguments and options will be passed directly to your script.

License

© 2024 Ryan Lue. This project is licensed under the terms of the MIT License.