本文整理匯總了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