本文整理汇总了Python中rules.Rules.get_gap方法的典型用法代码示例。如果您正苦于以下问题:Python Rules.get_gap方法的具体用法?Python Rules.get_gap怎么用?Python Rules.get_gap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rules.Rules
的用法示例。
在下文中一共展示了Rules.get_gap方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from rules import Rules [as 别名]
# 或者: from rules.Rules import get_gap [as 别名]
#.........这里部分代码省略.........
return i
return self.phonemes.GetSize()-1
# End find_next_break
# ------------------------------------------------------------------
def shift(self, limit):
"""
Add a syllable that ends at the phoneme pointed by "limit".
There can be a difference between the effective limit and the limit
given in parameter if it is between two indivisible phonemes.
@param limit is the index of the phoneme where the segmentation will take place
@return effective limit
"""
# if the limit is between two indivisible phonemes,
# it will be moved except if the move reach the previous syllable
if (self.vow2-self.vow1) > 2 and self.rules.get_class(self.phonemes[self.vow2].GetLabel().GetValue()) != "#" and self.vow2 != self.phonemes.GetSize()-1:
_str = ""
if (limit - 2) > 0 and (limit + 2) < self.phonemes.GetSize():
_str = self.phonemes[limit - 2].GetLabel().GetValue()\
+ " " + self.phonemes[limit - 1].GetLabel().GetValue()\
+ " " + self.phonemes[limit].GetLabel().GetValue()\
+ " " + self.phonemes[limit + 1].GetLabel().GetValue()\
+ " " + self.phonemes[limit + 2].GetLabel().GetValue()
elif (limit - 1) > 0:
_str = "ANY " + self.phonemes[limit - 1].GetLabel().GetValue()\
+ " " + self.phonemes[limit].GetLabel().GetValue()\
+ " " + self.phonemes[limit + 1].GetLabel().GetValue()\
+ " " + self.phonemes[limit + 2].GetLabel().GetValue()
d = self.rules.get_gap( _str )
if d!=0:
if limit+d >= self.vow1:
limit += d
# Adding the syllable
self.add_syllable( limit )
# Beginning of the new syllable
self.vow1 = self.vow2
self.vow2 = self.find_next_break( self.vow1+1 )
return limit
# End shift
# ------------------------------------------------------------------
def is_consonant(self, string):
"""
Return true if string is not a vowel nor a silence.
"""
return string not in ("V", "W", "#")
def analyze_breaks(self):
"""
Deal with the cases where syllabification is systematic (##, #V, V#).
Edit the values of global variables vow1 and vow2
"""
vbreak = True
while vbreak == True: