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)
|
phonemeList.append(id)
|
||||||
return phonemeList
|
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:
|
class Distribution:
|
||||||
"""Discrete distribution"""
|
"""Discrete distribution"""
|
||||||
def __init__(self):
|
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
|
# Step 1: Generate the word rules based on the min and max number of syllables, and the presence of stress
|
||||||
stressId = phonology.getStress()
|
stressId = phonology.getStress()
|
||||||
syllableBreakId = phonology.getSyllableBreak()
|
syllableBreakId = phonology.getSyllableBreak()
|
||||||
isStressed = stressPosition != 0
|
isStressed = (stressPosition != 0) and phonology.hasStressedVowels()
|
||||||
# Add the 'word' rule, initialized with an empty distribution
|
# Add the 'word' rule, initialized with an empty distribution
|
||||||
self.rules.update({'word': Distribution()})
|
self.rules.update({'word': Distribution()})
|
||||||
# Add the syllable rules and word patterns
|
# Add the syllable rules and word patterns
|
||||||
|
@ -578,7 +587,7 @@ class RuleGenerator(Generator):
|
||||||
nbSyllables = nbMiddleSyllables + 2
|
nbSyllables = nbMiddleSyllables + 2
|
||||||
wordPattern = []
|
wordPattern = []
|
||||||
for position in range(1, nbSyllables + 1):
|
for position in range(1, nbSyllables + 1):
|
||||||
isStressPosition = RuleGenerator.isStressPosition(position, nbSyllables, stressPosition)
|
isStressPosition = isStressed and RuleGenerator.isStressPosition(position, nbSyllables, stressPosition)
|
||||||
# add syllable separator
|
# add syllable separator
|
||||||
if isStressPosition:
|
if isStressPosition:
|
||||||
wordPattern.append(stressId)
|
wordPattern.append(stressId)
|
||||||
|
|
Loading…
Reference in New Issue