本文整理汇总了Python中regex.VERBOSE属性的典型用法代码示例。如果您正苦于以下问题:Python regex.VERBOSE属性的具体用法?Python regex.VERBOSE怎么用?Python regex.VERBOSE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类regex
的用法示例。
在下文中一共展示了regex.VERBOSE属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_parser
# 需要导入模块: import regex [as 别名]
# 或者: from regex import VERBOSE [as 别名]
def setup_parser():
from lexnlp.extract.en.amounts import CURRENCY_SYMBOL_MAP
symbols = '|'.join([k for k in CURRENCY_SYMBOL_MAP]).replace('$', r'\$')
ParsedTextCorrector.PATTERN_MONEY_BREAK = ParsedTextCorrector.PATTERN_MONEY_BREAK.format(symbols=symbols)
ParsedTextCorrector.REGEX_MONEY_BREAK = re.compile(
ParsedTextCorrector.PATTERN_MONEY_BREAK,
re.IGNORECASE | re.DOTALL | re.MULTILINE | re.VERBOSE | re.UNICODE)
示例2: _matches
# 需要导入模块: import regex [as 别名]
# 或者: from regex import VERBOSE [as 别名]
def _matches(regex):
"""Regular expression compiling function decorator."""
def match_decorator(fn):
automaton = compile(regex, UNICODE | VERBOSE)
fn.split = automaton.split
fn.match = automaton.match
return fn
return match_decorator
示例3: split_sentences
# 需要导入模块: import regex [as 别名]
# 或者: from regex import VERBOSE [as 别名]
def split_sentences(text):
"""Returns split sentences list
Reference:
http://stackoverflow.com/questions/8465335/a-regex-for-extracting-
sentence-from-a-paragraph-in-python
"""
sentenceEnders = regex.compile(r"""
# Split sentences on whitespace between them.
(?: # Group for two positive lookbehinds.
(?<=[.!?]) # Either an end of sentence punct,
| (?<=[.!?]['"]) # or end of sentence punct and quote.
) # End group of two positive lookbehinds.
(?<! Mr\. ) # Don't end sentence on "Mr."
(?<! Mrs\. ) # Don't end sentence on "Mrs."
(?<! Jr\. ) # Don't end sentence on "Jr."
(?<! Dr\. ) # Don't end sentence on "Dr."
(?<! Prof\. ) # Don't end sentence on "Prof."
(?<! Sr\. ) # Don't end sentence on "Sr."
(?<! Sen\. )
(?<! Ms\. )
(?<! Rep\. )
(?<! Gov\. )
(?<! et\ al\. )
(?<! i\.e\. )
(?<! U\.S\. )
(?<! p\. ) # Don't end sentence on "p." (page)
\s+ # Split on whitespace between sentences.
""", regex.IGNORECASE | regex.VERBOSE)
sentenceList = sentenceEnders.split(text)
return sentenceList