当前位置: 首页>>代码示例>>Python>>正文


Python Rules.get_boundary方法代码示例

本文整理汇总了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")
开发者ID:drammock,项目名称:sppas,代码行数:70,代码来源:syllabification.py


注:本文中的rules.Rules.get_boundary方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。