Skip to content

_match_terms

Internal helper
This page documents an internal implementation helper, not a primary public API.
Source code in src/fabricops_kit/governance.py
69
70
71
72
73
74
75
76
77
78
79
80
81
def _match_terms(text: str, terms: list[str]) -> list[str]:
    tokens = _tokenize_text(text)
    matched = []
    token_variants = tokens | {t[:-1] for t in tokens if len(t) > 3 and t.endswith("s")}
    for term in terms:
        term_tokens = _tokenize_text(term)
        if not term_tokens:
            continue
        if len(term_tokens) == 1 and next(iter(term_tokens)) in token_variants:
            matched.append(term)
        elif len(term_tokens) > 1 and term_tokens.issubset(tokens):
            matched.append(term)
    return matched