natural language toolkit compatibility c 20012023 nltk project url https www nltk org for license information see license txt compatibility for datasets that care about python versions the following datasets have a py3 subdirectory containing a full copy of the data which has been reencoded or repickled for use in adding py3 to the second filename argument of the file pointers in data py natural language toolkit compatibility c 2001 2023 nltk project url https www nltk org for license information see license txt compatibility for datasets that care about python versions the following datasets have a py3 subdirectory containing a full copy of the data which has been re encoded or repickled for use in adding py3 to the second filename argument of the file pointers in data py
import os
from functools import wraps





DATA_UPDATES = [
    ("chunkers", "maxent_ne_chunker"),
    ("help", "tagsets"),
    ("taggers", "maxent_treebank_pos_tagger"),
    ("tokenizers", "punkt"),
]

_PY3_DATA_UPDATES = [os.path.join(*path_list) for path_list in DATA_UPDATES]


def add_py3_data(path):
    for item in _PY3_DATA_UPDATES:
        if item in str(path) and "/PY3" not in str(path):
            pos = path.index(item) + len(item)
            if path[pos : pos + 4] == ".zip":
                pos += 4
            path = path[:pos] + "/PY3" + path[pos:]
            break
    return path




def py3_data(init_func):
    def _decorator(*args, **kwargs):
        args = (args[0], add_py3_data(args[1])) + args[2:]
        return init_func(*args, **kwargs)

    return wraps(init_func)(_decorator)