GitXplorerGitXplorer
r

cram

public
3 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
8b5a9c303b3b543d50d54f200eee7b20194f7ef9

dst: Add package metadata to fpm options

rrlue committed 4 years ago
Unverified
6e4af2d2272f24e9b568c6c7a3b278832690340d

dst: Simplify 'make install' target

rrlue committed 4 years ago
Unverified
1ff8d2111cd588472644ee57adf67b6a6bdf5ae2

bfx: Avoid 'no implicit conversion of nil into String' in cram use

rrlue committed 4 years ago
Unverified
4cdc65faec1032bb65b622270628fa81ed25b0f7

bfx: Add error handling when invoked with no args

rrlue committed 4 years ago
Unverified
67c6cbab907c49ad40e22b8fe00410439c102be8

bfx: Fix fault character in cangjie table

rrlue committed 4 years ago
Unverified
dd201ef0e4c37d98630eaa050ffae822ce0b2d8e

doc: Add installation instructions to README

rrlue committed 4 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.