本文整理匯總了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")