Introduction
Phonex is a pattern matching language for IPA transcriptions. Where regular expressions operate on characters, phonex operates on phones — matching by IPA character, phonetic features, syllable position, and stress.
Phonex vs Regular Expressions
| Concept | Regex | Phonex |
|---|---|---|
| Match a literal | p | p |
| Character class | [aeiou] | \v (any vowel) |
| Feature match | — | {fricative, voiceless} |
| Syllable position | — | \c:O (consonant in onset) |
| Stress match | — | \v!1 (primary-stressed vowel) |
| Quantifier | a+ | \v+ |
| Capture group | (abc) | (\c\v) |
Features include:
- Query based on features. E.g.,
{fricative} - Custom phone classes. E.g.,
\c,\v,\w(consonants, vowels, consonant or vowel respectively.) - Query based on constituent type. E.g.,
{fricative}:C(fricative codas) - Query based on stress. E.g.,
\c!1(stressed consonants) - Query based on tone. E.g.,
\v:tn("214")(vowel with tone 214) - Aligned phonex for comparing IPA Target vs IPA Actual transcriptions
- Comments for annotating complex expressions
Note: An understanding of regular expressions (or regex) is useful for understanding phonex. Many online regular expression tutorials and guides are available for reference.
Multi-Expression Union (||)
The || operator combines results from independent expressions. Each expression is evaluated separately against the input, and all matches from all expressions are returned together.
(\c)$ || (?<\v)(\c)(?>\v)This finds consonants that are either word-final or intervocalic. Each side of || runs as a separate pattern; the results are unioned.
Unlike alternation (|) inside a group, || produces separate match results for each expression. Use || when you need to combine independent queries that cannot be expressed as a single pattern.
Next Steps
- Phone Matchers — character, feature, regex, and class matchers
- Quantifiers — greedy, reluctant, and possessive
- Groups — capture, named, lookahead/behind, back references
- Supplementary Matchers — stress, syllable type, diacritics, tone
- Syllable Matcher — the sigma (
σ) matcher - Aligned Phonex — alignment operator, deletions, deferred matching
- Phonex Constructs — complete single-page reference table
