|
2 | 2 | A command-line sound change applier written in Python. |
3 | 3 |
|
4 | 4 | ## Setup |
5 | | -To begin using this sound change applier, you just need to download the executable (`.exe`) file in the [releases](https://github.com/erickcan/sound-change-applier/releases) tab. |
6 | | - |
7 | | -You can also clone this repo and use the `sca.bat` file: |
| 5 | +To begin using this sound change applier, you just need to download the executable (`.exe`) file in the [Releases page](https://github.com/erickcan/sound-change-applier/releases) and use it through the command-line prompt: |
| 6 | +``` |
| 7 | +$ sca sca-options |
8 | 8 | ``` |
| 9 | +You can also clone this repo and use the `sca.bat` or `sca.sh` file: |
| 10 | +```sh |
9 | 11 | $ git clone https://github.com/erickcan/sound-change-applier.git |
| 12 | +$ sca sca-options # if Windows |
| 13 | +$ ./sca.sh sca-options # if Linux |
10 | 14 | ``` |
11 | 15 |
|
12 | 16 | ## Command line |
13 | | -There are two ways of applying sound changes using the command line: `--file-based-sound-change` and `--named-sound-change`. |
14 | | - |
15 | | -- `--file-based-sound-change` (or `-f`) applies a set of rules to a set of words, each defined in their own files, and creates a text file with the changed words. |
16 | | -- `--named-sound-change` (or `-n`) applies a named sound change to words passed on the command line, and then prints the words after the change. |
17 | | - |
18 | | -### Usage |
19 | | -For `--file-based-sound-change`:<sup name="a1">[[1]](#f1)</sup> |
20 | 17 | ``` |
21 | | -$ sca sound-classes-file -f rules-file words-file [--csv-output] |
| 18 | +sca (-f rules-file words-file | -n named-rules-json named-rule words) |
| 19 | + [--csv-output] [-s sound-classes-json | --no-sound-classes] |
22 | 20 | ``` |
23 | | -where: |
24 | | -- `sca` is the sound change applier; |
25 | | -- `sound-classes-file` is a JSON file where sound classes are defined; |
26 | | -- `rules-file` is a text file where the rules to apply are; |
27 | | -- `words-file` is a text file where the words to which the rules will be applied; |
28 | | -- `--csv-output` is an optional argument that, if selected, creates a CSV file with the before and after of the words instead of a text file. |
29 | | - |
30 | | ---- |
31 | | - |
32 | | -For `--named-sound-change`:<sup name="a2">[[2]](#f2)</sup> |
33 | | -``` |
34 | | -$ sca sound-classes-file -n named-rules-file named-rule words [--csv-output] |
35 | | -``` |
36 | | -where: |
37 | | -- `sca` is the sound change applier; |
38 | | -- `sound-classes-file` is a JSON file where sound classes are defined; |
39 | | -- `named-rules-file` is a JSON file where sound changes and their names are defined; |
40 | | -- `named-rule` is the name of the rule to apply (should be defined in the `named-rules-file` file); |
41 | | -- `words` is a string with the words to change (if more than one word, should be inside quotes and separed by spaces); |
42 | | -- `--csv-output` is an optional argument that, if selected, creates a CSV file with the before and after of the words instead of just printing the words. |
| 21 | +### Usage |
| 22 | +- `--file-based-sound-change` | `-f` to apply a set of rules to a set of words, each defined in a separate file, creating a text file with the changed words; |
| 23 | + - `rules-file`: text file with the rules |
| 24 | + - `words-file`: text file with the words |
| 25 | +- `--named-sound-change` | `-n` to apply a named sound change to words passed on the command line, and then prints the words after the change; |
| 26 | + - `named-rules-json`: JSON file where sound classes are defined |
| 27 | + - `named-rule`: name of the rule to apply (defined in `named-rules-json`) |
| 28 | + - `words`: words to apply the sound change |
| 29 | +- `--csv-output` to create a before and after of the changed words; |
| 30 | +- `--sound-classes-file` | `-s` to specify the JSON file where the sound classes are defined (see also [Default sound classes](#default-sound-classes)); |
| 31 | +- `--no-sound-classes` to not make use of sound classes. |
43 | 32 |
|
44 | 33 | ### Examples |
45 | 34 | Suppose the following files: |
46 | | - |
47 | | -> sound_classes.json |
48 | | -```json |
49 | | -{ |
50 | | - "V": "aeiou", |
51 | | - "C": "bcdfghjklmnpqrstvwxyz", |
52 | | - "P": "pbtdkg", |
53 | | - "F": "fvsz", |
54 | | - "N": "mn", |
55 | | - "S": "sz" |
56 | | -} |
57 | | -``` |
58 | 35 | > named_rules.json |
59 | 36 | ```json |
60 | 37 | { |
61 | | - "terminal-devoicing": "[bdgz] -> [ptks] / _#", |
62 | | - "h-dropping": "h -> _ / _", |
63 | | - "z-rhotacization": "z -> r / V_V", |
64 | | - "/æ/-raising": "æ -> eə / _N" |
| 38 | + "terminal-devoicing": "[bdgz] > [ptks] / _#", |
| 39 | + "h-dropping": "h -> _ / _", |
| 40 | + "z-rhotacization": "z -> r / V_V", |
| 41 | + "l-vocalization": "l => w / _!V", |
| 42 | + "/æ/-raising": "æ => eə / _N", |
| 43 | + "th-fronting": "[θð] -> [fv] / _" |
65 | 44 | } |
66 | 45 | ``` |
67 | | - |
68 | 46 | > rules.txt |
69 | 47 | ``` |
70 | | -d -> ð / V_V |
71 | | -[ae] -> [ãẽ] / _N |
72 | | -[aou] -> [äöü] / _e |
73 | | -l -> w / _# |
74 | | -s -> z / [bdg]_ |
| 48 | +d => ð / V_V |
| 49 | +[gk] -> _ / #_n |
| 50 | +a -> ə / _# |
| 51 | +l -> w / _!V |
| 52 | +[aou]e>[æøy]/ _ |
| 53 | +sw > s / _[ou] |
| 54 | +[ao]N > [ãõ]/ _ |
| 55 | +s => z /[bdg]_ |
| 56 | +e -> _ / CC_# |
75 | 57 | ``` |
76 | | - |
77 | 58 | > words.txt |
78 | 59 | ``` |
79 | | -ada |
| 60 | +aeon |
80 | 61 | beds |
81 | 62 | clue |
82 | 63 | daemon |
| 64 | +knowledge |
| 65 | +laterals |
| 66 | +media |
83 | 67 | sand |
84 | | -vowel |
| 68 | +swords |
85 | 69 | ``` |
86 | 70 |
|
87 | | -If this were passed to the command line: |
| 71 | +If this were passed to the command line, |
88 | 72 | ``` |
89 | | -$ sca sound_classes.json -f rules.txt words.txt --csv-output |
| 73 | +$ sca -f rules.txt words.txt --csv-output |
90 | 74 | ``` |
91 | | -The following file would be created: |
92 | | - |
| 75 | +the following file would be created: |
93 | 76 | > sound-change-YYYY-MM-DD-HH-MM-SS.csv |
94 | 77 | ```csv |
95 | | -ada,aða |
| 78 | +aeon,æõ |
96 | 79 | beds,bedz |
97 | | -clue,clüe |
98 | | -daemon,daẽmon |
99 | | -sand,sãnd |
100 | | -vowel,vowew |
| 80 | +clue,cly |
| 81 | +daemon,dæmõ |
| 82 | +knowledge,nowledg |
| 83 | +laterals,lateraws |
| 84 | +media,meðiə |
| 85 | +sand,sãd |
| 86 | +swords,sordz |
101 | 87 | ``` |
102 | 88 |
|
103 | | -And if the following were passed into the command line: |
| 89 | +And if the following were passed into the command line, |
104 | 90 | ``` |
105 | | -$ sca sound_classes.json -n named_rules.json h-dropping "here he had hallucinated" |
| 91 | +$ sca -n named_rules.json h-dropping "here he had hallucinated" |
106 | 92 | ``` |
107 | | -It would print: |
| 93 | +it would print: |
108 | 94 | ``` |
109 | | -ere |
110 | | -e |
111 | | -ad |
112 | | -allucinated |
| 95 | +ere e ad allucinated |
113 | 96 | ``` |
114 | 97 |
|
115 | 98 | ## Rule notation |
116 | | -The rules should be written in the form `x -> y / a_b`, where `x` becomes `y` when `x` is between `a` and `b`. |
| 99 | +The rules can be written in any of the following forms: |
| 100 | +``` |
| 101 | +x > y / a_b |
| 102 | +x -> y / a_b |
| 103 | +x => y / a_b |
| 104 | +``` |
| 105 | +where `x` becomes `y` when `x` is between `a` and `b`. (Spaces between `>`, `->`, `=>` and `/` are insignificant.) |
117 | 106 |
|
118 | 107 | ### Symbols |
119 | | -| symbol | meaning | example | |
120 | | -| ------- | ------------- | ----------------------------------------- | |
121 | | -| `#` | word boundary | `_#` : end of word | |
122 | | -| `A..Z` | sound class | `Gt` : class `G` followed by `t` | |
123 | | -| `[xyz]` | ad-hoc class | `u[rl]` : `u` followed by `r` or `l` | |
124 | | -| `_` | everywhere | `ð -> d / _` : `ð` becomes `d` everywhere | |
125 | | -| `_` | sound-eraser | `h -> _` : deletes `h` | |
126 | | - |
127 | | - |
128 | | -## Dependencies |
129 | | -This project has no dependencies. It only uses modules of the Python Standard Library. |
130 | | - |
131 | | -## Footnotes |
132 | | -1. <b name="f1"></b> `$ sca -f rules-file words-file [--csv-output] sound-classes-file` and `$ sca [--csv-output] -f rules-file words-file sound-classes-file` are also valid. [↩](#a1) |
133 | | -2. <b name="f2"></b> `$ sca -n named-rules-file named-rule words [--csv-output] sound-classes-file` and `$ sca [--csv-output] -n named-rules-file named-rule words` are also valid. [↩](#a2) |
| 108 | +| symbol | meaning | example | |
| 109 | +| ------- | ---------------- | ------------------------------------------- | |
| 110 | +| `#` | word boundary | `_#`: end of word, `#_`: start of word | |
| 111 | +| `A..Z` | sound class | `Gt`: class `G` followed by `t` | |
| 112 | +| `[xyz]` | ad-hoc class | `u[rl]`: `u` followed by `r` or `l` | |
| 113 | +| `> _` | sound-eraser | `h -> _`: deletes `h` | |
| 114 | +| `_` | everywhere, when | `_x`: when followed by `x`, `_`: everywhere | |
| 115 | +| `!_` | not proceeded by | `u!_`: when not proceeded by `u` | |
| 116 | +| `_!` | not followed by | `_!n`: when not followed by `n` | |
| 117 | + |
| 118 | +## Appendix |
| 119 | + |
| 120 | +### Default sound classes |
| 121 | +If neither `--sound-classes-file` nor `--no-sound-classes` are used, the following sound classes are used: |
| 122 | +```json |
| 123 | +{ |
| 124 | + "V": "aeiou", |
| 125 | + "C": "bcdfghjklmnpqrstvwxyz", |
| 126 | + "P": "pbtdkg", |
| 127 | + "F": "fvsz", |
| 128 | + "N": "mn", |
| 129 | + "S": "sz" |
| 130 | +} |
| 131 | +``` |
0 commit comments