def-gthill / lexurgy

A high-powered sound change applier
GNU General Public License v3.0
42 stars 5 forks source link

Feature Suggestion: Applying a rule only on a syllable of given structure #50

Closed bigyihsuan closed 1 year ago

bigyihsuan commented 2 years ago

I am not sure if there is a way to do this, but here we go.

I want to be able to have a rule only apply on syllables of given structure.

For example, let's say I want only CVC syllables to gain an additional r (CVrC) but ignore all other syllables (so CV.CV should not work, but CVC.CV will, for example).

Writing this as rules:

Feature Type(C, V)
Syllables:
[C]? [V] ([C] ([C]?))?
# rules...

In the current system I would need to do the following:

insert-r-on-cvc:
* => r / [C] [V] _ [C] // _ . [C]

This is verbose and error prone since you have two conditions you need to worry about.

I propose the following syntax:

insert-r-on-cvc  <syl>([C] [V] [C]):
* => r / [C] [V] _ [C]

which says that this rule only applies on syllables with form [C] [V] [C].

The syntax feels ugly, perhaps a better syntax can be thought up.

def-gthill commented 2 years ago

You should be able to use syllable-level features for this, something like:

Feature (syllable) +cvc
Diacritic ^ [+cvc]
# Rest of declarations

Syllables:
    [C] [V] [C] => [+cvc]
    [C]? [V] [C]? [C]?

insert-r-on-cvc:
    * => r / [V +cvc] _ [C]