File: vectors.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 (34 lines) | stat: -rw-r--r-- 1,108 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
def __getattr__(name):

    moved_apis = ["FastText", "GloVe", "load_vectors_from_file_path", "build_vectors", "Vectors"]

    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 == "FastText":
            from torchtext.prototype.vectors import FastText

            return FastText
        elif name == "GloVe":
            from torchtext.prototype.vectors import GloVe

            return GloVe
        elif name == "load_vectors_from_file_path":
            from torchtext.prototype.vectors import load_vectors_from_file_path

            return load_vectors_from_file_path
        elif name == "build_vectors":
            from torchtext.prototype.vectors import build_vectors

            return build_vectors
        else:
            from torchtext.prototype.vectors import Vectors

            return Vectors

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