File: vocab_factory.py

package info (click to toggle)
pytorch-text 0.14.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 11,560 kB
  • sloc: python: 14,197; cpp: 2,404; sh: 214; makefile: 20
file content (20 lines) | stat: -rw-r--r-- 740 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
def __getattr__(name):
    moved_apis = ["build_vocab_from_text_file", "load_vocab_from_file"]
    if name in moved_apis:
        import warnings

        warnings.warn(
            "experimental package has been moved to prototype. You may change all imports from `torchtext.experimental` to `torchtext.prototype`",
            UserWarning,
        )

        if name == "build_vocab_from_text_file":
            from torchtext.prototype.vocab_factory import build_vocab_from_text_file

            return build_vocab_from_text_file
        else:
            from torchtext.prototype.vocab_factory import load_vocab_from_file

            return load_vocab_from_file

    raise AttributeError(f"module {__name__} has no attribute {name}")