PhonologicalRule#

class montreal_forced_aligner.db.PhonologicalRule(**kwargs)[source]#

Bases: Base

Database class for storing information about a phonological rule

Parameters:
  • id (int) – Primary key

  • segment (str) – Segment to replace

  • preceding_context (str) – Context before segment to match

  • following_context (str) – Context after segment to match

  • replacement (str) – Replacement of segment

  • probability (float) – Probability of the rule application

  • silence_after_probability (float) – Probability of silence following forms with rule application

  • silence_before_correction (float) – Correction factor for silence before forms with rule application

  • non_silence_before_correction (float) – Correction factor for non-silence before forms with rule application

  • pronunciations (list[RuleApplication]) – List of rule applications

apply_rule(pronunciation)[source]#

Apply the rule on a pronunciation by replacing any matching segments with the replacement

Parameters:

pronunciation (str) – Pronunciation to apply rule

Returns:

Pronunciation with rule applied

Return type:

str

property match_regex#

Regular expression of the rule

to_json()[source]#

Serializes the rule for export

Returns:

Serialized rule

Return type:

dict[str, Any]