当前位置: 首页>>代码示例>>Python>>正文


Python regex.I属性代码示例

本文整理汇总了Python中regex.I属性的典型用法代码示例。如果您正苦于以下问题:Python regex.I属性的具体用法?Python regex.I怎么用?Python regex.I使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在regex的用法示例。


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

示例1: _get_simplifications

# 需要导入模块: import regex [as 别名]
# 或者: from regex import I [as 别名]
def _get_simplifications(self, settings=None):
        no_word_spacing = eval(self.info.get('no_word_spacing', 'False'))
        if settings.NORMALIZE:
            if self._normalized_simplifications is None:
                self._normalized_simplifications = []
                simplifications = self._generate_simplifications(normalize=True)
                for simplification in simplifications:
                    pattern, replacement = list(simplification.items())[0]
                    if not no_word_spacing:
                        pattern = r'(?<=\A|\W|_)%s(?=\Z|\W|_)' % pattern
                    pattern = re.compile(pattern, flags=re.I | re.U)
                    self._normalized_simplifications.append({pattern: replacement})
            return self._normalized_simplifications

        else:
            if self._simplifications is None:
                self._simplifications = []
                simplifications = self._generate_simplifications(normalize=False)
                for simplification in simplifications:
                    pattern, replacement = list(simplification.items())[0]
                    if not no_word_spacing:
                        pattern = r'(?<=\A|\W|_)%s(?=\Z|\W|_)' % pattern
                    pattern = re.compile(pattern, flags=re.I | re.U)
                    self._simplifications.append({pattern: replacement})
            return self._simplifications 
开发者ID:scrapinghub,项目名称:dateparser,代码行数:27,代码来源:locale.py

示例2: _try_hardcoded_formats

# 需要导入模块: import regex [as 别名]
# 或者: from regex import I [as 别名]
def _try_hardcoded_formats(self):
        hardcoded_date_formats = [
            '%B %d, %Y, %I:%M:%S %p',
            '%b %d, %Y at %I:%M %p',
            '%d %B %Y %H:%M:%S',
            '%A, %B %d, %Y',
            '%Y-%m-%dT%H:%M:%S.%fZ'
        ]
        try:
            return parse_with_formats(
                self._get_translated_date_with_formatting(),
                hardcoded_date_formats,
                settings=self._settings
            )
        except TypeError:
            return None 
开发者ID:scrapinghub,项目名称:dateparser,代码行数:18,代码来源:date.py

示例3: from_morse_code

# 需要导入模块: import regex [as 别名]
# 或者: from regex import I [as 别名]
def from_morse_code(
        self,
        dot: str = ".",
        dash: str = "-",
        letter_delim: str = " ",
        word_delim: str = "\n",
    ):
        """Decode morse code
        
        Args:
            dot (str, optional): The char for dot. Defaults to ".".
            dash (str, optional): The char for dash. Defaults to "-".
            letter_delim (str, optional): Letter delimiter. Defaults to " ".
            word_delim (str, optional): Word delimiter. Defaults to "\\n".
        
        Returns:
            Chepy: The Chepy object. 
        """
        decode = ""
        morse_code_dict = EncryptionConsts.MORSE_CODE_DICT
        for k, v in morse_code_dict.items():
            morse_code_dict[k] = v.replace(".", dot).replace("-", dash)

        morse_code_dict = {value: key for key, value in morse_code_dict.items()}

        for chars in self._convert_to_str().split(letter_delim):
            if word_delim in chars:
                print("here", chars)
                chars = re.sub(word_delim, "", chars, re.I)
                print(chars)
                if morse_code_dict.get(chars) is not None:
                    decode += " " + morse_code_dict.get(chars)
            else:
                decode += morse_code_dict.get(chars)
        self.state = decode
        return self 
开发者ID:securisec,项目名称:chepy,代码行数:38,代码来源:encryptionencoding.py

示例4: extract

# 需要导入模块: import regex [as 别名]
# 或者: from regex import I [as 别名]
def extract(s: str, entities: Iterable[str], useregex=False, ignorecase=True) -> Iterable[str]:
    for m in re.compile(
            r"\b(?:{})\b".format(r"|".join(
                e if useregex else re.escape(e).replace(' ', r"s+") for e in entities
            )),
            re.I if ignorecase else 0
        ).finditer(s):
        yield m.group(0) 
开发者ID:chuanconggao,项目名称:extratools,代码行数:10,代码来源:strtools.py

示例5: _construct_regex

# 需要导入模块: import regex [as 别名]
# 或者: from regex import I [as 别名]
def _construct_regex(self, g2p_keys):
        """Build a regular expression that will greadily match segments from
           the mapping table.
        """
        graphemes = sorted(g2p_keys, key=len, reverse=True)
        return re.compile(r'({})'.format(r'|'.join(graphemes)), re.I) 
开发者ID:dmort27,项目名称:epitran,代码行数:8,代码来源:simple.py

示例6: search_citation

# 需要导入模块: import regex [as 别名]
# 或者: from regex import I [as 别名]
def search_citation(sentences, exp):
    '''Finds sentences around citations, where the regexp `exp matches'''
    print("Search...'{0!s}'".format(exp))

    rx = regex.compile(exp, flags=(regex.I))

    founds = set()
    for sent in sentences:
        if rx.search(sent):
            founds.add(sent)
    return founds 
开发者ID:soodoku,项目名称:autosum,代码行数:13,代码来源:autosum_arxiv.py


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