當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。