Ignore stress in rulemaker if all vowels of a phonology is tagged unstressed
This commit is contained in:
parent
d8102d8a99
commit
5b52ee1afa
|
@ -229,6 +229,15 @@ class Phonology:
|
|||
phonemeList.append(id)
|
||||
return phonemeList
|
||||
|
||||
def hasStressedVowels(self):
|
||||
"""Check if all vowels are tagged #unstressed"""
|
||||
hasStressed = False
|
||||
for id in self.entries:
|
||||
if self.isNucleus(id) and self.isInStressedSyllables(id):
|
||||
hasStressed = True
|
||||
break
|
||||
return hasStressed
|
||||
|
||||
class Distribution:
|
||||
"""Discrete distribution"""
|
||||
def __init__(self):
|
||||
|
@ -552,7 +561,7 @@ class RuleGenerator(Generator):
|
|||
# Step 1: Generate the word rules based on the min and max number of syllables, and the presence of stress
|
||||
stressId = phonology.getStress()
|
||||
syllableBreakId = phonology.getSyllableBreak()
|
||||
isStressed = stressPosition != 0
|
||||
isStressed = (stressPosition != 0) and phonology.hasStressedVowels()
|
||||
# Add the 'word' rule, initialized with an empty distribution
|
||||
self.rules.update({'word': Distribution()})
|
||||
# Add the syllable rules and word patterns
|
||||
|
@ -578,7 +587,7 @@ class RuleGenerator(Generator):
|
|||
nbSyllables = nbMiddleSyllables + 2
|
||||
wordPattern = []
|
||||
for position in range(1, nbSyllables + 1):
|
||||
isStressPosition = RuleGenerator.isStressPosition(position, nbSyllables, stressPosition)
|
||||
isStressPosition = isStressed and RuleGenerator.isStressPosition(position, nbSyllables, stressPosition)
|
||||
# add syllable separator
|
||||
if isStressPosition:
|
||||
wordPattern.append(stressId)
|
||||
|
|
Loading…
Reference in New Issue