Lingua-SoundChange
view release on metacpan or search on metacpan
SoundChange.pm view on Meta::CPAN
civitatem Z => 'bdg' cidade
adoptare adotar
opera Rules obra
secundus segundo
s//_#
m//_#
e//Vr_#
v//V_V
u/o/_#
gn/nh/_
S/Z/V_V
c/i/F_t
c/u/B_t
p//V_t
ii/i/_
e//C_rV
=head3 Format of sound change rules
Hopefully, the format of the rules will be familiar to any linguist.
For instance, here's one sound change:
c/g/V_V
This rule says to change C<c> to C<g> between vowels. (We'll see how
to generalize this rule below.)
More generally, a sound change looks like this:
x/y/z
where C<x> is the thing to be changed, C<y> is what it changes to,
and C<z> is the environment.
The C<z> part must always contain an underline C<_>, representing the
part that changes. That can be all there is, as in
gn/nh/_
which tells the module to replace C<gn> with C<nh> unconditionally.
The character C<#> represents the B<beginning or end> of the word. So
u/o/_#
means to replace C<u> with C<o>, but only at the end of the word.
The middle (C<y>) part can be B<blank>, as in
s//_#
This means that C<s> is B<deleted> when it ends a word.
=head3 Variables
The evironment (the C<z> part) can contain B<variables>, like C<V>
above. These are defined in the first parameter to the constructor.
I use capital letters for this, though this is not a requirement.
Variables can only be one character long. You can defined any variables
needed to state your sound changed. E.g. you could define C<S> to be
any stop, or C<K> for any coronal, or whatever.
So the variable definition and rule
F => 'ie'
c/i/F_t
means that C<c> changes to C<i> after a front vowel and before a C<t>.
You can use variables in the first two parts as well. For instance,
suppose you've defined
S => 'ptc',
Z => 'bdg'
S/Z/V_V
This means that the stops C<ptc> change to their voiced equivalents
C<bdg> between vowels. In this usage, the variables must correspond
one for one--C<p> goes to C<b>, C<t> goes to C<d>, etc. Each character
in the replacement variable (here C<Z>) gives the transformed value
of each character in the input variable (here C<S>). Make sure the two
variable definitions are the same length!
A variable can also be set to a fixed value, or deleted. E.g.
Z//V_V
says to delete voiced stops between vowels, and
Z/?/V_V
would translate all voiced stops between vowels to a glottal stop C<?>.
=head3 Rule order
Rules apply in the B<order> they're listed. So, with the word C<opera>
and the rules
p/b/V_V
e//C_rV
the first rule voices the C<p>, resulting in C<obera>; the second
deletes an C<e> between a consonant and an intervocalic C<r>, resulting
in C<obra>.
The C<printRules> option can assist in debugging rules, since it causes
the output to show exactly what rules applied to each word.
=head3 Optional elements in the environment
One or more elements in the environment can be marked as B<optional>
with parentheses. E.g.
u/ü/_C(C)F
says to change C<u> to C<ü> when it's followed by one or two
consonants and then a front vowel.
=head2 How to use it
( run in 2.871 seconds using v1.01-cache-2.11-cpan-df04353d9ac )