def _reverse(doc, attr, rev_attr): for word in all_words(doc): if attr == "lex": for ana in word["Anas"]: val = ana["lex"] if val: _insert_attr(word, rev_attr, val[::-1]) elif attr == "form": val = word["Text"] if val: _insert_attr(word, rev_attr, val[::-1])
def set_capital(doc): for word in all_words(doc): if word["Text"] and word["Text"][0].isupper(): _insert_flag(word, "capital")
def normalize_punct(doc): for word in all_words(doc): word["Punct"] = _normalize_punct_str(word["Punct"]) for sent in all_sents(doc): sent["Punct"] = _normalize_punct_str(sent["Punct"])
def normalize_accents(doc): for word in all_words(doc): word["Text"] = normalize_accents_str(word["Text"])