# AUTOGENERATED! DO NOT EDIT! File to edit: nbs/02_text_quality.ipynb (unless otherwise specified).

__all__ = ['non_words_ratio']

# Cell
from botok import WordTokenizer

# Cell
def non_words_ratio(text):
    wt = WordTokenizer()
    tokens = wt.tokenize(text)
    total_words = len(tokens)
    n_non_words = 0

    for token in tokens:
        if token["pos"] == "NON_WORD":
            n_non_words += 1

    return round(n_non_words / total_words, 4)