Skip to content

Instantly share code, notes, and snippets.

@keeler
Created July 7, 2020 04:07
Show Gist options
  • Save keeler/3c61a0485583ab498a90c2044e2f43e3 to your computer and use it in GitHub Desktop.
Save keeler/3c61a0485583ab498a90c2044e2f43e3 to your computer and use it in GitHub Desktop.
Transforms HSK vocab lists on Github into TSVs of flashcards for import into AnkiApp on iOS.
#!/bin/bash
# Transform list into flashcards with chars on front and pinyin/defn on back.
list_to_flashcards () {
LEVEL=$1
URL="https://raw.githubusercontent.com/glxxyz/hskhsk.com/main/data/lists/HSK%20Official%20With%20Definitions%202012%20L${LEVEL}%20freqorder.txt"
OUTFILE="HSK${LEVEL}.tsv"
curl -s $URL \
| sed 's/\r$//' \
| awk -F '\t' '{if($1 == $2){printf("%s\t%s<br/>%s\n", $1, $4, $5)} else{printf("%s / %s\t%s<br/>%s\n", $2, $1, $4, $5)} }' \
> $OUTFILE
}
list_to_flashcards 1
list_to_flashcards 2
list_to_flashcards 3
list_to_flashcards 4
list_to_flashcards 5
list_to_flashcards 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment