• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python parse.normalize函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mycroft.util.parse.normalize函数的典型用法代码示例。如果您正苦于以下问题:Python normalize函数的具体用法?Python normalize怎么用?Python normalize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了normalize函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_spaces_fr

 def test_spaces_fr(self):
     self.assertEqual(normalize("  c'est   le     test", lang="fr-fr"),
                      "c'est test")
     self.assertEqual(normalize("  c'est  le    test  ", lang="fr-fr"),
                      "c'est test")
     self.assertEqual(normalize("  c'est     un    test", lang="fr-fr"),
                      "c'est 1 test")
开发者ID:MycroftAI,项目名称:mycroft-core,代码行数:7,代码来源:test_parse_fr.py


示例2: test_spaces

 def test_spaces(self):
     self.assertEqual(normalize("  this   is  a    test"),
                      "this is test")
     self.assertEqual(normalize("  this   is  a    test  "),
                      "this is test")
     self.assertEqual(normalize("  this   is  one    test"),
                      "this is 1 test")
开发者ID:antlarr,项目名称:mycroft-core,代码行数:7,代码来源:test_parse.py


示例3: test_articles_es

 def test_articles_es(self):
     self.assertEqual(normalize("esta es la prueba", lang="es",
                                remove_articles=True),
                      "esta es prueba")
     self.assertEqual(normalize("y otra prueba", lang="es",
                                remove_articles=True),
                      "y otra prueba")
开发者ID:antlarr,项目名称:mycroft-core,代码行数:7,代码来源:test_parse.py


示例4: test_spaces_pt

 def test_spaces_pt(self):
     self.assertEqual(normalize("  isto   e  o    teste", lang="pt"),
                      "isto teste")
     self.assertEqual(normalize("  isto   sao os    testes  ", lang="pt"),
                      "isto sao testes")
     self.assertEqual(normalize("  isto   e  um    teste", lang="pt",
                                remove_articles=False),
                      "isto e 1 teste")
开发者ID:antlarr,项目名称:mycroft-core,代码行数:8,代码来源:test_parse.py


示例5: test_agressive_pruning_pt

 def test_agressive_pruning_pt(self):
     self.assertEqual(normalize("uma palavra", lang="pt"),
                      "1 palavra")
     self.assertEqual(normalize("esta palavra um", lang="pt"),
                      "palavra 1")
     self.assertEqual(normalize("o homem batia-lhe", lang="pt"),
                      "homem batia")
     self.assertEqual(normalize("quem disse asneira nesse dia", lang="pt"),
                      "quem disse asneira dia")
开发者ID:antlarr,项目名称:mycroft-core,代码行数:9,代码来源:test_parse.py


示例6: test_articles_pt

 def test_articles_pt(self):
     self.assertEqual(normalize(u"isto � o teste",
                                lang="pt", remove_articles=True),
                      u"isto teste")
     self.assertEqual(
         normalize(u"isto � a frase", lang="pt", remove_articles=True),
         u"isto frase")
     self.assertEqual(
         normalize("e outro teste", lang="pt", remove_articles=True),
         "outro teste")
开发者ID:antlarr,项目名称:mycroft-core,代码行数:10,代码来源:test_parse.py


示例7: test_articles

 def test_articles(self):
     self.assertEqual(
         normalize("dies ist der test", lang="de-de", remove_articles=True),
         "dies ist test")
     self.assertEqual(
         normalize("und noch ein Test", lang="de-de", remove_articles=True),
         "und noch 1 Test")
     self.assertEqual(normalize("dies ist der Extra-Test", lang="de-de",
                                remove_articles=False),
                      "dies ist der Extra-Test")
开发者ID:Dark5ide,项目名称:mycroft-core,代码行数:10,代码来源:test_parse_de.py


示例8: test_articles

 def test_articles(self):
     self.assertEqual(normalize("this is a test", remove_articles=True),
                      "this is test")
     self.assertEqual(normalize("this is the test", remove_articles=True),
                      "this is test")
     self.assertEqual(normalize("and another test", remove_articles=True),
                      "and another test")
     self.assertEqual(normalize("this is an extra test",
                                remove_articles=False),
                      "this is an extra test")
开发者ID:antlarr,项目名称:mycroft-core,代码行数:10,代码来源:test_parse.py


示例9: test_articles

 def test_articles(self):
     self.assertEqual(
         normalize("dette er en test", lang="da-dk", remove_articles=True),
         "dette er 1 test")
     self.assertEqual(
         normalize("og endnu en test", lang="da-dk", remove_articles=True),
         "og endnu 1 test")
     self.assertEqual(normalize("dette er en extra-test",
                                lang="da-dk", remove_articles=False),
                      "dette er 1 extra-test")
开发者ID:MycroftAI,项目名称:mycroft-core,代码行数:10,代码来源:test_parse_da.py


示例10: test_spaces_it

 def test_spaces_it(self):
     self.assertEqual(normalize(u"questo   e'  il    test",
                                lang="it"), u"questo e' test")
     self.assertEqual(normalize(u"questo   è    un    test  ",
                                lang="it"), u"questo è 1 test")
     self.assertEqual(normalize(u"un  altro test  ",
                                lang="it"), u"1 altro test")
     self.assertEqual(normalize(u"questa è un'  altra amica   ", lang="it",
                                remove_articles=False),
                      u"questa è 1 altra amica")
     self.assertEqual(normalize(u"questo   è  un    test   ", lang="it",
                                remove_articles=False), u"questo è 1 test")
开发者ID:seymour-bootay,项目名称:mycroft-core,代码行数:12,代码来源:test_parse_it.py


示例11: test_numbers

 def test_numbers(self):
     self.assertEqual(
         normalize("dette er en to tre test", lang="da-dk"),
         "dette er 1 2 3 test")
     self.assertEqual(
         normalize("dette er fire fem seks test", lang="da-dk"),
         "dette er 4 5 6 test")
     self.assertEqual(
         normalize("dette er syv otte ni test", lang="da-dk"),
         "dette er 7 8 9 test")
     self.assertEqual(
         normalize("dette er ti elve tolv test", lang="da-dk"),
         "dette er 10 11 12 test")
开发者ID:MycroftAI,项目名称:mycroft-core,代码行数:13,代码来源:test_parse_da.py


示例12: test_spaces_it

 def test_spaces_it(self):
     """
     Test cases for Italian remove spaces
     """
     self.assertEqual(normalize('questo   è    un    test  ',
                                lang='it'), 'questo è 1 test')
     self.assertEqual(normalize('un  altro test  ',
                                lang='it'), '1 altro test')
     self.assertEqual(normalize('questa è un\'  altra amica   ', lang='it',
                                remove_articles=False),
                      'questa è 1 altra amica')
     self.assertEqual(normalize('questo   è  un    test   ', lang='it',
                                remove_articles=False), 'questo è 1 test')
开发者ID:MycroftAI,项目名称:mycroft-core,代码行数:13,代码来源:test_parse_it.py


示例13: test_articles_fr

 def test_articles_fr(self):
     self.assertEqual(normalize("c'est le test", remove_articles=True,
                                lang="fr-fr"),
                      "c'est test")
     self.assertEqual(normalize("et l'autre test", remove_articles=True,
                                lang="fr-fr"),
                      "et autre test")
     self.assertEqual(normalize("et la tentative", remove_articles=True,
                                lang="fr-fr"),
                      "et tentative")
     self.assertEqual(normalize("la dernière tentative",
                                remove_articles=False, lang="fr-fr"),
                      "la dernière tentative")
开发者ID:MycroftAI,项目名称:mycroft-core,代码行数:13,代码来源:test_parse_fr.py


示例14: test_articles_it

 def test_articles_it(self):
     self.assertEqual(normalize(u"questo è il test",
                                lang="it", remove_articles=True),
                      u"questo è test")
     self.assertEqual(normalize(u"questa è la frase",
                                lang="it", remove_articles=True),
                      u"questa è frase")
     self.assertEqual(normalize(u"questo è lo scopo", lang="it",
                                remove_articles=True),
                      u"questo è scopo")
     self.assertEqual(normalize(u"questo è il test extra",
                                lang="it", remove_articles=False),
                      u"questo è il test extra")
开发者ID:seymour-bootay,项目名称:mycroft-core,代码行数:13,代码来源:test_parse_it.py


示例15: test_numbers_pt

 def test_numbers_pt(self):
     self.assertEqual(normalize(u"isto e o um dois tr�s teste", lang="pt"),
                      u"isto 1 2 3 teste")
     self.assertEqual(normalize(u"� a sete oito nove  test", lang="pt"),
                      u"7 8 9 test")
     self.assertEqual(
         normalize("teste zero dez onze doze treze", lang="pt"),
         "teste 0 10 11 12 13")
     self.assertEqual(
         normalize("teste mil seiscentos e sessenta e seis", lang="pt",
                   remove_articles=False),
         "teste 1000 600 e 66")
     self.assertEqual(
         normalize("teste sete e meio", lang="pt",
                   remove_articles=False),
         "teste 7 e meio")
     self.assertEqual(
         normalize("teste dois ponto nove", lang="pt"),
         "teste 2 ponto 9")
     self.assertEqual(
         normalize("teste cento e nove", lang="pt",
                   remove_articles=False),
         "teste 100 e 9")
     self.assertEqual(
         normalize("teste vinte e 1", lang="pt"),
         "teste 20 1")
开发者ID:antlarr,项目名称:mycroft-core,代码行数:26,代码来源:test_parse.py


示例16: test_numbers

 def test_numbers(self):
     self.assertEqual(
         normalize("dies ist eins zwei drei test", lang="de-de"),
         "dies ist 1 2 3 test")
     self.assertEqual(
         normalize(u"es ist vier fünf sechs test", lang="de-de"),
         "es ist 4 5 6 test")
     self.assertEqual(
         normalize("es ist sieben acht neun test", lang="de-de"),
         "es ist 7 8 9 test")
     self.assertEqual(
         normalize("es ist sieben acht neun test", lang="de-de"),
         "es ist 7 8 9 test")
     self.assertEqual(
         normalize(u"dies ist zehn elf zwölf test", lang="de-de"),
         "dies ist 10 11 12 test")
     self.assertEqual(
         normalize("dies ist dreizehn vierzehn test", lang="de-de"),
         "dies ist 13 14 test")
     self.assertEqual(
         normalize(u"dies ist fünfzehn sechzehn siebzehn", lang="de-de"),
         "dies ist 15 16 17")
     self.assertEqual(
         normalize("dies ist achtzehn neunzehn zwanzig", lang="de-de"),
         "dies ist 18 19 20")
开发者ID:Dark5ide,项目名称:mycroft-core,代码行数:25,代码来源:test_parse_de.py


示例17: test_articles_pt

 def test_articles_pt(self):
     self.assertEqual(normalize(u"isto é o teste",
                                lang="pt", remove_articles=True),
                      u"isto teste")
     self.assertEqual(
         normalize(u"isto é a frase", lang="pt", remove_articles=True),
         u"isto frase")
     self.assertEqual(
         normalize("e outro teste", lang="pt", remove_articles=True),
         "outro teste")
     self.assertEqual(normalize(u"isto é o teste extra",
                                lang="pt",
                                remove_articles=False), u"isto e o teste"
                                                        u" extra")
开发者ID:Ceda-EI,项目名称:mycroft-core,代码行数:14,代码来源:test_parse_pt.py


示例18: parse_utterances

    def parse_utterances(self, utterances, lang):
        """
            Parse the utteracne using adapt  to find a matching intent.

            Args:
                utterances (list):  list of utterances
                lang (string):      4 letter ISO language code

            Returns: Intent structure, or None if no match was found.
        """
        best_intent = None
        for utterance in utterances:
            try:
                # normalize() changes "it's a boy" to "it is boy", etc.
                best_intent = next(self.engine.determine_intent(
                    normalize(utterance, lang), 100,
                    include_tags=True,
                    context_manager=self.context_manager))
                # TODO - Should Adapt handle this?
                best_intent['utterance'] = utterance
            except StopIteration:
                # don't show error in log
                continue
            except Exception as e:
                LOG.exception(e)
                continue

        if best_intent and best_intent.get('confidence', 0.0) > 0.0:
            self.update_context(best_intent)
            # update active skills
            skill_id = int(best_intent['intent_type'].split(":")[0])
            self.add_active_skill(skill_id)
            return best_intent
开发者ID:Ceda-EI,项目名称:mycroft-core,代码行数:33,代码来源:intent_service.py


示例19: test_articles_it

 def test_articles_it(self):
     """
     Test cases for Italian remove_articles
     """
     self.assertEqual(normalize('questo è il test',
                                lang='it', remove_articles=True),
                      'questo è test')
     self.assertEqual(normalize('questa è la frase',
                                lang='it', remove_articles=True),
                      'questa è frase')
     self.assertEqual(normalize('questo è lo scopo', lang='it',
                                remove_articles=True),
                      'questo è scopo')
     self.assertEqual(normalize('questo è il test extra',
                                lang='it', remove_articles=False),
                      'questo è il test extra')
开发者ID:MycroftAI,项目名称:mycroft-core,代码行数:16,代码来源:test_parse_it.py


示例20: handle_utterance

    def handle_utterance(self, message):
        # Get language of the utterance
        lang = message.data.get('lang', None)
        if not lang:
            lang = "en-us"

        utterances = message.data.get('utterances', '')

        # check for conversation time-out
        self.active_skills = [skill for skill in self.active_skills
                              if time.time() - skill[
                                  1] <= self.converse_timeout * 60]

        # check if any skill wants to handle utterance
        for skill in self.active_skills:
            if self.do_converse(utterances, skill[0], lang):
                # update timestamp, or there will be a timeout where
                # intent stops conversing whether its being used or not
                self.add_active_skill(skill[0])
                return

        # no skill wants to handle utterance
        best_intent = None
        for utterance in utterances:
            try:
                # normalize() changes "it's a boy" to "it is boy", etc.
                best_intent = next(self.engine.determine_intent(
                    normalize(utterance, lang), 100,
                    include_tags=True,
                    context_manager=self.context_manager))
                # TODO - Should Adapt handle this?
                best_intent['utterance'] = utterance
            except StopIteration, e:
                LOG.exception(e)
                continue
开发者ID:aatchison,项目名称:mycroft-core,代码行数:35,代码来源:intent_service.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python logger.debug函数代码示例发布时间:2022-05-27
下一篇:
Python log.LOG类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap