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

Python tools.warn函数代码示例

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

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



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

示例1: add_VerbForm

def add_VerbForm(word):
    fmap = word.feat_map()

    if word.cpostag not in VERB_TAGS:
        return []

    # (see https://github.com/TurkuNLP/UniversalFinnish/issues/28)
    if 'INF' in fmap:
        # infinitive
        assert 'PCP' not in fmap, 'INF and PCP'
        assert 'PRS' not in fmap, 'INF and PRS'
        assert 'MOOD' not in fmap, 'INF and MOOD'
        value = fmap['INF']
        if value in ('Inf1', 'Inf2', 'Inf3'):
            return [('VerbForm', 'Inf')]
        else:
            warn(u'unexpected INF value ' + value)
            return []
    if 'PCP' in fmap:
        # participle
        assert 'INF' not in fmap, 'PCP and INF'
        assert 'PRS' not in fmap, 'PCP and PRS'
        assert 'MOOD' not in fmap, 'PCP and MOOD'
        return [('VerbForm', 'Part')]
    else:
        # Should be finite, check for some marker. We consider any
        # non-infinitive, non-participle verb finite if it has either
        # MOOD or PRS.
        # (https://github.com/TurkuNLP/UniversalFinnish/issues/28)
        if 'MOOD' in fmap or 'PRS' in fmap:
            return [('VerbForm', 'Fin')]
        else:
            warn(u'failed to assign VerbForm to ' + unicode(word))
            return []
开发者ID:TurkuNLP,项目名称:Finnish-dep-parser,代码行数:34,代码来源:200-add-feats.py


示例2: test_json_HTTPResponse

 def test_json_HTTPResponse(self):
     self.app.route('/')(lambda: py3web.HTTPResponse({'a': 1}, 500))
     try:
         self.assertBody(py3web.json_dumps({'a': 1}))
         self.assertHeader('Content-Type','application/json')
     except ImportError:
         warn("Skipping JSON tests.")
开发者ID:alexandremas,项目名称:py3web,代码行数:7,代码来源:test_outputfilter.py


示例3: rewrite_SUBCAT

def rewrite_SUBCAT(word):
    for tagset, func in subcat_rewrite_func:
        if word.cpostag in tagset:
            return func(word)

    warn(word.cpostag + " with SUBCAT")
    return []
开发者ID:asbaeck,项目名称:Finnish-dep-parser,代码行数:7,代码来源:250-rewrite-feats.py


示例4: setUp

 def setUp(self):
     if self.skip: return
     # Find a free port
     for port in range(8800, 8900):
         self.port = port
         # Start servertest.py in a subprocess
         cmd = [sys.executable, serverscript, self.server, str(port)]
         cmd += sys.argv[1:] # pass cmdline arguments to subprocesses
         self.p = Popen(cmd, stdout=PIPE, stderr=PIPE)
         # Wait for the socket to accept connections
         for i in xrange(100):
             time.sleep(0.1)
             # Accepts connections?
             if ping('127.0.0.1', port): return
             # Server died for some reason...
             if not self.p.poll() is None: break
         rv = self.p.poll()
         if rv is None:
             raise AssertionError("Server took to long to start up.")
         if rv is 128: # Import error
             tools.warn("Skipping %r test (ImportError)." % self.server)
             self.skip = True
             return
         if rv is 3: # Port in use
             continue
     raise AssertionError("Could not find a free port to test server.")
开发者ID:dmpeters,项目名称:bottle,代码行数:26,代码来源:test_server.py


示例5: rewrite_PRON_SUBCAT

def rewrite_PRON_SUBCAT(word):
    value = word.feat_map()["SUBCAT"]

    if value == "Dem":  # demonstrative
        return [("PronType", "Dem")]
    elif value == "Pers":  # personal
        return [("PronType", "Prs")]
    elif value == "Rel":  # relative
        return [("PronType", "Rel")]
    elif value == "Indef":  # indefinite
        return [("PronType", "Ind")]
    elif value == "Interr":  # interrogative
        return [("PronType", "Int")]
    elif value == "Recipr":  # reciprocal
        return [("PronType", "Rcp")]
    elif value == "Refl":  # reflexive
        # NOTE: UD defines Reflexive as a separate feature from PronType
        # (http://universaldependencies.github.io/docs/u/feat/Reflex.html)
        # TODO: consider adding PronType also?
        return [("Reflex", "Yes")]
    elif value == "Qnt":
        # NOTE: UD does not define "quantifier" as a pronoun type, so
        # these are (tentatively) mapped to the closest corresponding
        # subcategory, indefinite pronouns.
        # see https://github.com/TurkuNLP/UniversalFinnish/issues/37
        warn("mapping PRON SUBCAT " + value + " to Ind")
        return [("PronType", "Ind")]
    else:
        return []
开发者ID:asbaeck,项目名称:Finnish-dep-parser,代码行数:29,代码来源:250-rewrite-feats.py


示例6: rewrite_MOOD

def rewrite_MOOD(word):
    value = word.feat_map()["MOOD"]

    if value == "Ind":  # indicative
        return [("Mood", "Ind")]
    elif value == "Imprt":  # imperative
        return [("Mood", "Imp")]
    elif value == "Cond":  # conditional
        return [("Mood", "Cnd")]
    elif value == "Pot":  # potential
        return [("Mood", "Pot")]
    elif value == "Opt":  # optative
        # Omorfi defines the archaic optative mood (e.g. "kävellös"),
        # which is extremely rare (e.g. no occurrences in TDT). Should
        # this ever appear, we will approximate as imperative.
        warn("mapping optative mood to imperative")
        return [("Mood", "Imp")]
    elif value == "Eve":  # eventive
        # Omorfi defines the archaic eventive mood (e.g. "kävelleisin"),
        # which is extremely rare (e.g. no occurrences in TDT). Should
        # this ever appear, we will approximate as potential.
        warn("mapping eventive mood to potential")
        return [("Mood", "Pot")]
    else:
        return []  # assert False, 'unknown MOOD value ' + value
开发者ID:asbaeck,项目名称:Finnish-dep-parser,代码行数:25,代码来源:250-rewrite-feats.py


示例7: test_json

 def test_json(self):
     self.app.route('/')(lambda: {'a': 1})
     try:
         self.assertBody(bottle.json_dumps({'a': 1}))
         self.assertHeader('Content-Type','application/json')
     except ImportError:
         warn("Skipping JSON tests.")
开发者ID:alisaifee,项目名称:bottle,代码行数:7,代码来源:test_outputfilter.py


示例8: rewrite_A

def rewrite_A(word):
    # Assign "Pron" to instances of particular words given "A"
    # analyses by lemma.
    # (see https://github.com/TurkuNLP/UniversalFinnish/issues/66)
    if word.lemma in ('muu', 'sama'):
        warn('assigning %s to Pron/PRON' % word.form)
        return ('PRON', 'Pron')

    return 'ADJ'
开发者ID:TurkuNLP,项目名称:Finnish-dep-parser,代码行数:9,代码来源:100-rewrite-pos.py


示例9: rewrite_VOICE

def rewrite_VOICE(word):
    if word.cpostag not in VERB_TAGS:
        warn(word.cpostag + " with VOICE")

    value = word.feat_map()["VOICE"]
    if value == "Act":
        return [("Voice", "Act")]
    elif value == "Pass":
        return [("Voice", "Pass")]
    else:
        return []  # assert False, 'unknown VOICE value %s' % value
开发者ID:asbaeck,项目名称:Finnish-dep-parser,代码行数:11,代码来源:250-rewrite-feats.py


示例10: rewrite_TENSE

def rewrite_TENSE(word):
    if word.cpostag not in VERB_TAGS:
        warn(word.cpostag + " with TENSE")

    value = word.feat_map()["TENSE"]
    if value == "Prs":
        return [("Tense", "Pres")]
    elif value == "Prt":
        return [("Tense", "Past")]
    else:
        return []  # assert False, 'unknown TENSE value %s' % value
开发者ID:asbaeck,项目名称:Finnish-dep-parser,代码行数:11,代码来源:250-rewrite-feats.py


示例11: test_json_serialization_error

 def test_json_serialization_error(self):
     """
     Verify that 500 errors serializing dictionaries don't return
     content-type application/json
     """
     self.app.route('/')(lambda: {'a': set()})
     try:
         self.assertStatus(500)
         self.assertHeader('Content-Type','text/html; charset=UTF-8')
     except ImportError:
         warn("Skipping JSON tests.")
开发者ID:alisaifee,项目名称:bottle,代码行数:11,代码来源:test_outputfilter.py


示例12: rewrite_Punct

def rewrite_Punct(word):
    # NOTE: likely not a final mapping, see
    # https://github.com/TurkuNLP/UniversalFinnish/issues/1
    if is_symbol(word.form):
        assert not is_punctuation(word.form), 'internal error'
        return 'SYM'
    elif is_punctuation(word.form):
        assert not is_symbol(word.form), 'internal error'
        return 'PUNCT'
    else:
        warn(u'assigning SYM to unrecognized word ' + word.form)
        return 'SYM'
开发者ID:TurkuNLP,项目名称:Finnish-dep-parser,代码行数:12,代码来源:100-rewrite-pos.py


示例13: rewrite_Pron

def rewrite_Pron(word):
    # Assign "A" to pro-adjectives such as "millainen" based on lemma
    # (see https://github.com/TurkuNLP/UniversalFinnish/issues/67).
    if word.lemma in pro_adjective_lemmas:
        warn('assigning %s to A/ADJ' % word.form)
        return ('ADJ', 'A')

    # NOTE: this is not a full mapping: some words tagged Pron should
    # map into DET instead. See
    # https://github.com/TurkuNLP/UniversalFinnish/issues/1,
    # https://github.com/TurkuNLP/UniversalFinnish/issues/27,
    # https://github.com/UniversalDependencies/docs/issues/97.
    # However, we're currently postponing this exception.
    return 'PRON'
开发者ID:TurkuNLP,项目名称:Finnish-dep-parser,代码行数:14,代码来源:100-rewrite-pos.py


示例14: rewrite_CMP

def rewrite_CMP(word):
    value = word.feat_map()["CMP"]

    if word.cpostag not in (ADJ_TAGS | VERB_TAGS | ADV_TAGS):
        warn(word.cpostag + " with CMP")

    if value == "Comp":
        return [("Degree", "Cmp")]
    elif value == "Pos":
        return [("Degree", "Pos")]
    elif value == "Superl":
        return [("Degree", "Sup")]
    else:
        return []  # assert False, 'unknown CMP value ' + value
开发者ID:asbaeck,项目名称:Finnish-dep-parser,代码行数:14,代码来源:250-rewrite-feats.py


示例15: rewrite_pos

def rewrite_pos(sentence):
    for w in sentence.words():
        try:
            rewritten = rewrite_func[w.cpostag](w)
        except KeyError:
            warn(u'unexpected cpostag ' + w.cpostag)
            assert False, 'unexpected cpostag ' + w.cpostag

        # if rewrite_func returns a tuple, assign both cpostag and
        # postag; otherwise assign only cpostag
        if isinstance(rewritten, tuple):
            w.cpostag, w.postag = rewritten
        else:
            w.cpostag = rewritten
开发者ID:TurkuNLP,项目名称:Finnish-dep-parser,代码行数:14,代码来源:100-rewrite-pos.py


示例16: add_SUBCAT_to_Pron

def add_SUBCAT_to_Pron(word):
    # Assign feature SUBCAT to pronouns lacking it using surface
    # form-based heuristics.

    fmap = word.feat_map()

    if 'SUBCAT' in fmap or word.postag != 'Pron':
        return []

    try:
        sc = Pron_SUBCAT_by_lemma[word.lemma]
    except KeyError:
        warn(u'failed to assign SUBCAT to Pron')
        return []

    return [('SUBCAT', sc)]
开发者ID:TurkuNLP,项目名称:Finnish-dep-parser,代码行数:16,代码来源:200-add-feats.py


示例17: tearDown

 def tearDown(self):
     if self.skip: return
     for i in range(10):
         if self.p.poll() != None: break
         os.kill(self.p.pid, signal.SIGINT)
         time.sleep(0.1*i)
     for i in range(10):
         if self.p.poll() != None: break
         os.kill(self.p.pid, signal.SIGINT)
         time.sleep(i)
     for stream in (self.p.stdout, self.p.stderr):
         for line in stream:
             if tob('warning') in line.lower():
                 tools.warn(line.strip().decode('utf8'))
             elif tob('error') in line.lower():
                 raise AssertionError(line.strip().decode('utf8'))
开发者ID:dmpeters,项目名称:bottle,代码行数:16,代码来源:test_server.py


示例18: tearDown

    def tearDown(self):
        if self.skip: return

        if self.p.poll() == None:
            os.kill(self.p.pid, signal.SIGINT)
            time.sleep(0.5)
        while self.p.poll() == None:
            os.kill(self.p.pid, signal.SIGTERM)
            time.sleep(1)

        for stream in (self.p.stdout, self.p.stderr):
            for line in stream:
                if tob('warning') in line.lower():
                    tools.warn(line.strip().decode('utf8'))
                elif tob('error') in line.lower():
                    raise AssertionError(line.strip().decode('utf8'))
开发者ID:FedericoCeratto,项目名称:bottle,代码行数:16,代码来源:test_server.py


示例19: rewrite_NUM

def rewrite_NUM(word):
    fmap = word.feat_map()

    if word.cpostag not in (VERB_TAGS | NOUN_TAGS | ADJ_TAGS | PRON_TAGS):
        warn(word.cpostag + " with NUM")

    # Both PRS and NUM would generate redundant Number features
    assert "PRS" not in fmap

    value = word.feat_map()["NUM"]
    if value == "Sg":
        return [("Number", "Sing")]
    elif value == "Pl":
        return [("Number", "Plur")]
    else:
        # assert False, 'unknown NUM value %s' % value
        return []
开发者ID:asbaeck,项目名称:Finnish-dep-parser,代码行数:17,代码来源:250-rewrite-feats.py


示例20: add_Person

def add_Person(word):
    # Assign feature Person to personal pronouns, which for some
    # reason lack it in Omorfi analyses.

    fmap = word.feat_map()

    if word.cpostag != 'PRON':
        return []
    elif fmap.get('SUBCAT') != 'Pers':
        return []
    else:
        p = person_by_lemma.get(word.lemma, None)
        if p is not None:
            return [('Person', p)]
        else:
            warn(u'missing person for pronoun lemma ' + word.lemma)
            return []
开发者ID:TurkuNLP,项目名称:Finnish-dep-parser,代码行数:17,代码来源:200-add-feats.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python tools.DHadTable类代码示例发布时间:2022-05-27
下一篇:
Python tools.ustr函数代码示例发布时间: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