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