本文整理汇总了Python中pattern.text.Parser类的典型用法代码示例。如果您正苦于以下问题:Python Parser类的具体用法?Python Parser怎么用?Python Parser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Parser类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: find_tags
def find_tags(self, tokens, **kwargs):
if kwargs.get("tagset") in (PENN, None):
kwargs.setdefault("map", lambda token, tag: (token, tag))
if kwargs.get("tagset") == UNIVERSAL:
kwargs.setdefault(
"map", lambda token, tag: penntreebank2universal(token, tag))
return _Parser.find_tags(self, tokens, **kwargs)
示例2: find_tokens
def find_tokens(self, tokens, **kwargs):
# 's in Dutch preceded by a vowel indicates plural ("auto's"): don't replace.
kwargs.setdefault("abbreviations", ABBREVIATIONS)
kwargs.setdefault("replace", {"'n": " 'n"})
s = _Parser.find_tokens(self, tokens, **kwargs)
s = [re.sub(r"' s (ochtends|morgens|middags|avonds)", "'s \\1", s) for s in s]
return s
示例3: find_tokens
def find_tokens(self, tokens, **kwargs):
kwargs.setdefault("abbreviations", ABBREVIATIONS)
kwargs.setdefault("replace", replacements)
s = _Parser.find_tokens(self, tokens, **kwargs)
s = [s.replace("&rsquo ;", u"’") if isinstance(
s, unicode) else s for s in s]
return s
示例4: find_tokens
def find_tokens(self, tokens, **kwargs):
kwargs.setdefault("abbreviations", ABBREVIATIONS)
kwargs.setdefault("replace", replacements)
#return _Parser.find_tokens(self, tokens, **kwargs)
s = _Parser.find_tokens(self, tokens, **kwargs)
s = [s.replace(" &contraction ;", u"'").replace("XXX -", "-") for s in s]
return s
示例5: find_tags
def find_tags(self, tokens, **kwargs):
if kwargs.get("tagset") != STTS:
kwargs.setdefault("map", stts2penntreebank)
# The lexicon uses Swiss spelling: "ss" instead of "ß".
# We restore the "ß" after parsing.
tokens_ss = [t.replace(u"ß", "ss") for t in tokens]
tokens_ss = _Parser.find_tags(self, tokens_ss, **kwargs)
return [[w] + tokens_ss[i][1:] for i, w in enumerate(tokens)]
示例6: find_tags
def find_tags(self, tokens, **kwargs):
if kwargs.get("tagset") in (PENN, None):
kwargs.setdefault("map", lambda token, tag: stts2penntreebank(token, tag))
if kwargs.get("tagset") == UNIVERSAL:
kwargs.setdefault("map", lambda token, tag: stts2universal(token, tag))
if kwargs.get("tagset") is STTS:
kwargs.setdefault("map", lambda token,tag: (token, tag))
# The lexicon uses Swiss spelling: "ss" instead of "ß".
# We restore the "ß" after parsing.
tokens_ss = [t.replace(u"ß", "ss") for t in tokens]
tokens_ss = _Parser.find_tags(self, tokens_ss, **kwargs)
return [[w] + tokens_ss[i][1:] for i, w in enumerate(tokens)]
示例7: find_chunks
def find_chunks(self, tokens, **kwargs):
return _Parser.find_chunks(self, tokens, **kwargs)
示例8: find_tags
def find_tags(self, tokens, **kwargs):
kwargs.setdefault("map", tagset2penntreebank)
return _Parser.find_tags(self, tokens, **kwargs)
示例9: find_tokens
def find_tokens(self, tokens, **kwargs):
kwargs.setdefault("abbreviations", ABBREVIATIONS)
kwargs.setdefault("replace", REPLACEMENTS)
return _Parser.find_tokens(self, tokens, **kwargs)
示例10: find_tags
def find_tags(self, tokens, **kwargs):
# Parser.find_tags() can take an optional map(token, tag) function,
# which returns an updated (token, tag)-tuple for each token.
kwargs.setdefault("map", parole2penntreebank)
return Parser.find_tags(self, tokens, **kwargs)