Initial commit

This commit is contained in:
Oystein Kristoffer Tveit 2022-02-08 01:39:19 +01:00
commit 2bb0d90e8b
18 changed files with 42050 additions and 0 deletions

7
.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
data/tex
# TODO: fix
# tex/**/*
# !tex/**/*.tex
# !tex/**/*.tex

21
README.md Normal file
View File

@ -0,0 +1,21 @@
# JLPT Nx 単語帳
List of words to use when making flashcards to learn japanese.
## Intended use case
First of all, get some kind of flashcard solution.
This might be a mobile app, it might be a bunch of paper slices.
Personally, I would recommend getting a [pack of premade paper cards (image)][tangocho-link]
[![Memorization cards][tangocho-img]][tangocho-link]
Secondly, get one of these bad bois:
![Highlighter/text marker][highlighter-img]
Although not strictly required, keeping track of which of the words you've put into your memorization cards will help you avoid duplicates.
[tangocho-link]: https://www.amazon.com/Copies-Books-Each-Yellow-Assortment/dp/B0012OV700/133-2864506-7558164
[tangocho-img]: https://m.media-amazon.com/images/I/71CrpXAXmML._AC_SL1000_.jpg
[highlighter-img]: https://static2.jetpens.com/images/a/000/178/178843.jpg?auto=format&ba=middle%2Ccenter&balph=3&blend64=aHR0cDovL3d3dy5qZXRwZW5zLmNvbS9pbWFnZXMvYXNzZXRzL3dhdGVybWFyazIucG5n&bm=difference&bs=inherit&chromasub=444&fm=jpg&h=400&mark64=aHR0cDovL3d3dy5qZXRwZW5zLmNvbS9pbWFnZXMvYXNzZXRzL3dhdGVybWFyazEucG5n&markalign=top%2Cright&markalpha=30&markscale=16&q=90&usm=20&w=600&s=78167e64fe93cce86b3e07da0f53578c

17387
data/html/n1.html Normal file

File diff suppressed because it is too large Load Diff

9184
data/html/n2.html Normal file

File diff suppressed because it is too large Load Diff

9024
data/html/n3.html Normal file

File diff suppressed because it is too large Load Diff

2919
data/html/n4.html Normal file

File diff suppressed because it is too large Load Diff

3354
data/html/n5.html Normal file

File diff suppressed because it is too large Load Diff

25
main.tex Normal file
View File

@ -0,0 +1,25 @@
% !TeX program = xelatex
\documentclass[a5paper, twoside]{article}
\usepackage{xeCJK}
\usepackage{adjustbox}
\usepackage{graphicx}
\usepackage{tabu}
\usepackage{longtable}
\usepackage{makecell}
\usepackage[bindingoffset=0.5in]{geometry}
\setCJKmainfont{Noto Sans CJK JP}
\begin{document}
\renewcommand{\arraystretch}{2}
\input{tex/n5.tex}
\newline{}
\input{tex/n4.tex}
\newline{}
\input{tex/n3.tex}
\newline{}
\input{tex/n2.tex}
\newline{}
\input{tex/n1.tex}
\end{document}

19
make.sh Executable file
View File

@ -0,0 +1,19 @@
#!/usr/bin/env bash
python3 ./toTex.py
xelatex main.tex
numberOfPages=$(pdfinfo main.pdf | awk '/^Pages:/ {print $2}')
echo $numberOfPages
cat >wrapper.tex <<EOF
\\documentclass[a4paper, twoside]{article}
\\usepackage[T1]{fontenc}
\\usepackage[utf8]{inputenc}
\\usepackage{pdfpages}
\\begin{document}
\\includepdf[pages=-,nup=1x2,signature=${numberOfPages},landscape,booklet=true]{main.pdf}
\\end{document}
EOF
pdflatex wrapper.tex

View File

@ -0,0 +1,31 @@
\usepackage{fontawesome}
\usepackage{hyperref}
\usepackage[
type={CC},
modifier={by},
version={3.0},
]{doclicense}
\newfontfamily\nscjksixty[SizeFeatures={Size=120}]{Noto Sans CJK JP}
\newcommand{\NXfrontpage}[1]{
{
\topskip0pt
\vspace*{\fill}
\begin{center}
{ \nscjksixty{ N#1 } } \\
\vspace*{5mm}
{ \Huge 単語帳 } \\
\vspace*{15mm}
\doclicenseImage \\
Data made by Jonathan Waller at \url{http://www.tanos.co.uk/jlpt/jlpt#1/} \\
\vspace*{10mm}
Project at \\
{ \Huge \faicon{github-square} } \url{https://github.com/h7x4abk3g}
\end{center}
\vspace*{\fill}
}
\newpage{}
}

0
tex/common/wrapper.tex Normal file
View File

24
tex/main.tex Normal file
View File

@ -0,0 +1,24 @@
% !TeX program = xelatex
\documentclass[a5paper, twoside]{article}
\usepackage{xeCJK}
\usepackage{adjustbox}
\usepackage{graphicx}
\usepackage{tabu}
\usepackage{longtable}
\usepackage{makecell}
\usepackage[bindingoffset=0.5in]{geometry}
\setCJKmainfont{Noto Sans CJK JP}
\begin{document}
\renewcommand{\arraystretch}{2}
\input{tex/n5.tex}
\newline{}
\input{tex/n4.tex}
\newline{}
\input{tex/n3.tex}
\newline{}
\input{tex/n2.tex}
\newline{}
\input{tex/n1.tex}
\end{document}

20
tex/n1.tex Normal file
View File

@ -0,0 +1,20 @@
% !TeX program = xelatex
\documentclass[a5paper, twoside]{article}
\usepackage{xeCJK}
\usepackage{adjustbox}
\usepackage{graphicx}
\usepackage{tabu}
\usepackage{longtable}
\usepackage{makecell}
\usepackage[bindingoffset=0.5in]{geometry}
\input{common/frontPageNx.tex}
\setCJKmainfont{Noto Sans CJK JP}
\begin{document}
\renewcommand{\arraystretch}{2}
\NXfrontpage{1}
\input{../data/tex/n1.tex}
\end{document}

0
tex/n2.tex Normal file
View File

0
tex/n3.tex Normal file
View File

0
tex/n4.tex Normal file
View File

0
tex/n5.tex Normal file
View File

35
toTex.py Normal file
View File

@ -0,0 +1,35 @@
#!/usr/bin/env python3
from lxml import etree;
from re import sub
for n in reversed(range(1,6)):
with open(f'./data/html/n{n}.html', 'r') as file:
doc = etree.parse(file)
def extractCellText(col):
a = col.xpath('a')
if len(a) == 0: return ''
return sub(r'(-?\d+(?:\.\d+)?\^-?\d+(?:\.\d+)?)', r'$\1$', a[0].text.replace('#', '\\#'))
rows = (tuple(map(extractCellText, tr.xpath("td"))) for tr in doc.xpath("//tbody/tr"))
# Skip header
next(rows)
# Make cell with multiple rows in latex if there's multiple meanings/readings
def makeMultiCellIfMultipleEntries(cellText, rowtype = 'j'):
if rowtype == 'j' and '/' in cellText:
return '\\makecell[l]{ %s }' % cellText.replace('/', ' \\\\ ')
elif rowtype == 'e' and ',' in cellText:
return '\\makecell[l]{ %s }' % cellText.replace(',', ' \\\\ ')
else:
return cellText
with open(f'./data/tex/n{n}.tex', 'w') as file:
file.write('\\begin{longtabu} to \\textwidth {ll|l}\n')
file.write(
" \\\\\\hline\n".join(f'{makeMultiCellIfMultipleEntries(row[0])} & {makeMultiCellIfMultipleEntries(row[1])} & {makeMultiCellIfMultipleEntries(row[2], rowtype="e")}' for row in rows)
)
file.write('\n\\end{longtabu}')