Updated readme, and examples.

Updated the readme to describe the product.
Added a few examples to show specific mechanics.
This commit is contained in:
Luke 2017-08-20 18:14:03 -07:00
parent 90368c778a
commit b0a9749559
6 changed files with 67 additions and 0 deletions

View file

@ -1,2 +1,60 @@
# jaPitchPlotter
A tool to produce SVGs of Japanese pitch accent patterns
## About
This tool is designed to produce simple SVG images of Japanese pitch accent
patterns. If you want to dig into the specifics about what they are, do like I
do and learn from [Dogen at Patreon](https://www.patreon.com/dogen).
The tool is designed to take in three strings describing a given word or phrase
and the corresponding pitch accent patterns. The tool generally makes few
assumptions about language, and relies upon you, the user to describe the
pattern. It generally assumes that a small "y" kana (やゆよ) in either katakana
or in hiragana is lumped with the prior kana, even if this doesn't make any
sense. If you write るょ then the tool will quite happily keep going. Other than
that it does assume that a small tsu (as in けっこう) is it's own mora.
The three strings are a key (or a name) for internal use. This can be a number
if you want. Secondly the phonetics of the word or phrase in either katakana or
hiragana, and finally a code representing the pitch accent of the phonetic
phrase. Examples are given in the 'example_codes.txt' file in this repository
separated by colons.
## Examples
Note by default the examples assume you do not change the default option of
dropping the final point indicating the difference between a heiban (平板) and
odaka (尾高) word. This is easily overridden by using the named variable
`includeFinalOpen=True` in the parseToneString call.
| Phonetics | Code | Result |
| :---: | :---: | :--- |
| べんきょう | `0/4` | 4 mora 平板 |
| べんきょうになる | `0/4,1/2` | 4 mora 平板 connected to particle and 2 mora 頭高 |
| べんきょうになる | `0/4,*1/2` | disconnected line between particle and second word |
| でんしゃは | `2/3` | 3 mora 中高 with marked particle |
| べんきょうして | `0/4*,*0/2` | disconnected line, no implied particle |
In short rules are:
+ <downstep location\>/<length of word\>
+ commas separating groups
+ trailing \* to drop an implied particle
+ leading \* to remove a connecting line
+ no whitespace tolerance (BUG!)
## Misc
Example images are available in the examples directory. Color, font, spacing,
padding, size, and plot styles are configurable. I personally use Inkscape to
convert SVG to other formats when needed. A handy bash command to do this for
is:
```bash
for SVG_FILE in examples/*.svg; do
PNG_FILE="${SVG_FILE/.svg/.png}"
inkscape --export-png="${PNG_FILE}" "${SVG_FILE}"
done
```
Send me your bugs (gently).
-Luke ([@siriusfox](https://twitter.com/siriusfox))

View file

@ -2,3 +2,6 @@
銀行じゃない:ぎんこうじゃない:0/4,1/2
電車は:でんしゃは:2/3
電車:でんしゃ:2/3
勉強:べんきょう:0/4
勉強になる:べんきょうになる:0/4,1/2
実施が:じっしが:0/3

2
examples/勉強.svg Normal file
View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8" ?>
<svg baseProfile="full" height="127" version="1.1" width="210" xmlns="http://www.w3.org/2000/svg" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink"><defs /><g id="master_group" transform="translate(30,65)"><g id="graph"><circle cx="0" cy="0" fill="#000000" r="7" stroke="#000000" stroke-width="3" /><circle cx="50" cy="-50" fill="#000000" r="7" stroke="#000000" stroke-width="3" /><line stroke="#000000" stroke-width="3" x1="45.05025253169417" x2="4.949747468305833" y1="-45.05025253169417" y2="-4.949747468305833" /><circle cx="100" cy="-50" fill="#000000" r="7" stroke="#000000" stroke-width="3" /><line stroke="#000000" stroke-width="3" x1="93" x2="57" y1="-50" y2="-50" /><circle cx="150" cy="-50" fill="#000000" r="7" stroke="#000000" stroke-width="3" /><line stroke="#000000" stroke-width="3" x1="143" x2="107" y1="-50" y2="-50" /></g><g fill="#000000" font-family="Noto Sans" font-size="27" id="moras" text-anchor="middle"><text id="moras" style="text-align:center;font-weight:bold;" x="0" y="47"></text><text id="moras" style="text-align:center;font-weight:bold;" x="50" y="47"></text><text id="moras" style="text-align:center;font-weight:bold;" x="100" y="47">きょ</text><text id="moras" style="text-align:center;font-weight:bold;" x="150" y="47"></text></g></g></svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8" ?>
<svg baseProfile="full" height="127" version="1.1" width="360" xmlns="http://www.w3.org/2000/svg" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink"><defs /><g id="master_group" transform="translate(30,65)"><g id="graph"><circle cx="0" cy="0" fill="#000000" r="7" stroke="#000000" stroke-width="3" /><circle cx="50" cy="-50" fill="#000000" r="7" stroke="#000000" stroke-width="3" /><line stroke="#000000" stroke-width="3" x1="45.05025253169417" x2="4.949747468305833" y1="-45.05025253169417" y2="-4.949747468305833" /><circle cx="100" cy="-50" fill="#000000" r="7" stroke="#000000" stroke-width="3" /><line stroke="#000000" stroke-width="3" x1="93" x2="57" y1="-50" y2="-50" /><circle cx="150" cy="-50" fill="#000000" r="7" stroke="#000000" stroke-width="3" /><line stroke="#000000" stroke-width="3" x1="143" x2="107" y1="-50" y2="-50" /><circle cx="200" cy="-50" fill="none" r="7" stroke="#000000" stroke-width="3" /><line stroke="#000000" stroke-width="3" x1="193" x2="157" y1="-50" y2="-50" /><circle cx="250" cy="-50" fill="#000000" r="7" stroke="#000000" stroke-width="3" /><line stroke="#000000" stroke-width="3" x1="243" x2="207" y1="-50" y2="-50" /><circle cx="300" cy="0" fill="#000000" r="7" stroke="#000000" stroke-width="3" /><line stroke="#000000" stroke-width="3" x1="295.0502525316942" x2="254.94974746830584" y1="-4.949747468305833" y2="-45.05025253169417" /></g><g fill="#000000" font-family="Noto Sans" font-size="27" id="moras" text-anchor="middle"><text id="moras" style="text-align:center;font-weight:bold;" x="0" y="47"></text><text id="moras" style="text-align:center;font-weight:bold;" x="50" y="47"></text><text id="moras" style="text-align:center;font-weight:bold;" x="100" y="47">きょ</text><text id="moras" style="text-align:center;font-weight:bold;" x="150" y="47"></text><text id="moras" style="text-align:center;font-weight:bold;" x="200" y="47"></text><text id="moras" style="text-align:center;font-weight:bold;" x="250" y="47"></text><text id="moras" style="text-align:center;font-weight:bold;" x="300" y="47"></text></g></g></svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

2
examples/実施が.svg Normal file
View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8" ?>
<svg baseProfile="full" height="127" version="1.1" width="210" xmlns="http://www.w3.org/2000/svg" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink"><defs /><g id="master_group" transform="translate(30,65)"><g id="graph"><circle cx="0" cy="0" fill="#000000" r="7" stroke="#000000" stroke-width="3" /><circle cx="50" cy="-50" fill="#000000" r="7" stroke="#000000" stroke-width="3" /><line stroke="#000000" stroke-width="3" x1="45.05025253169417" x2="4.949747468305833" y1="-45.05025253169417" y2="-4.949747468305833" /><circle cx="100" cy="-50" fill="#000000" r="7" stroke="#000000" stroke-width="3" /><line stroke="#000000" stroke-width="3" x1="93" x2="57" y1="-50" y2="-50" /><circle cx="150" cy="-50" fill="none" r="7" stroke="#000000" stroke-width="3" /><line stroke="#000000" stroke-width="3" x1="143" x2="107" y1="-50" y2="-50" /></g><g fill="#000000" font-family="Noto Sans" font-size="27" id="moras" text-anchor="middle"><text id="moras" style="text-align:center;font-weight:bold;" x="0" y="47"></text><text id="moras" style="text-align:center;font-weight:bold;" x="50" y="47"></text><text id="moras" style="text-align:center;font-weight:bold;" x="100" y="47"></text><text id="moras" style="text-align:center;font-weight:bold;" x="150" y="47"></text></g></g></svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

0
parse_examples.py Normal file → Executable file
View file