本文整理汇总了Python中rules.Rules.get_boundary方法的典型用法代码示例。如果您正苦于以下问题:Python Rules.get_boundary方法的具体用法?Python Rules.get_boundary怎么用?Python Rules.get_boundary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rules.Rules
的用法示例。
在下文中一共展示了Rules.get_boundary方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from rules import Rules [as 别名]
# 或者: from rules.Rules import get_boundary [as 别名]
#.........这里部分代码省略.........
else:
#Sometimes, there can be consonants, without vowel, between two breaks
self.add_syllable( self.vow1)
self.shift(self.vow2-1)
else:
vbreak = False
if self.vow1 >= self.vow2:
vbreak = False
# End analyze_breaks
# ------------------------------------------------------------------
def syllabificationVV(self):
"""
Break down into syllables: continue until positioning itself between
two vowels (others cases are systematics), apply the suited rule.
"""
# Call the rules only if we are between two vowels
self.analyze_breaks()
if self.vow1 >= self.vow2:
return
# Build two strings, one for the classes and one for the phonemes
classes = "V"
phones = self.phonemes[self.vow1].GetLabel().GetValue()
for i in range(self.vow1+1, self.vow2+1):
classes += self.rules.get_class( self.phonemes[i].GetLabel().GetValue() )
phones += " "+self.phonemes[i].GetLabel().GetValue()
# Apply the rule, add the syllable
d = self.rules.get_boundary( phones )
if d ==-1:
if self.logfile:
self.logfile.print_message("No rule found for" +classes,status=3)
else:
sys.stderr.write("INFO: no rule found for" +classes+"\n")
d = 0
self.shift( self.vow1 + d)
# End syllabificationVV
# ------------------------------------------------------------------
def syllabify(self, phonemes):
"""
Syllabify (after loading the rules).
@param phonemes (Tier) is the tier to syllabify
"""
# Init
self.phonemes = phonemes
self.syllables = None
self.prevlimit = 0
# Verifications: is there any data to syllabify?
if self.phonemes.IsEmpty() is True:
raise IOError("Syll::sppasSyll. Empty phoneme tier.\n")
# Create output Transcription
self.syllables = Transcription("Syllabification")
self.syll = self.syllables.NewTier(name="Syllables")