contractions.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:thesis-check 作者: albalitz 项目源码 文件源码
def analyze(line, linenum, lang):
    annotations = []

    if lang is Language.en_EN or lang is None:
        contractions = CONTRACTIONS_EN
    elif lang is Language.de_DE:
        contractions = CONTRACTIONS_DE

    for pattern in contractions:
        for match in re.finditer(pattern, line, flags=re.IGNORECASE):
            if (not verify_match(match, line)) or (not matches_whole_words(match, line)):
                continue

            index = match.start()
            replaced_contraction = re.sub(pattern, contractions[pattern], match.group(0), flags=re.IGNORECASE)
            annotation = Contraction(linenum, line, index, word=match.group(0), contraction=replaced_contraction)
            annotations.append(annotation)

    return annotations
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号