Corpus Utilities
lingo.corpus
Generic Corpus and Reference types for data payloads.
Corpus
Bases: BaseModel, Generic[T]
Represents a distinct data payload managed by the Archive.
Source code in lingo/corpus.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
from_file(path: Union[str, Path], content_type: Optional[str] = None) -> Corpus[bytes]
classmethod
Load a corpus from a file.
Source code in lingo/corpus.py
26 27 28 29 30 31 32 33 34 | |
from_object(obj: T) -> Corpus[T]
classmethod
Create a corpus from a Python object.
Source code in lingo/corpus.py
36 37 38 39 40 41 42 43 | |
materialize_content() -> bytes
Materialize corpus to raw bytes.
Source code in lingo/corpus.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
materialize_to_file(path: Union[str, Path]) -> Path
Materialize corpus contents to a file.
Source code in lingo/corpus.py
45 46 47 48 49 50 | |
materialize_to_object() -> T
Materialize corpus contents to a Python object.
Source code in lingo/corpus.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
Reference
Bases: BaseModel, Generic[T]
A pointer to a specific location in the Archive where output should be saved.
Source code in lingo/corpus.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
dump_content(content: bytes, content_type: Optional[str] = None) -> Corpus[bytes]
Save raw content to this reference location.
Source code in lingo/corpus.py
147 148 149 150 151 152 | |
dump_corpus(corpus: Corpus[T]) -> Corpus[T]
Save a corpus to this reference location.
Source code in lingo/corpus.py
132 133 134 135 136 137 | |
dump_file(file_path: Union[str, Path], content_type: Optional[str] = None) -> Corpus[bytes]
Copy a file to this reference location.
Source code in lingo/corpus.py
139 140 141 142 143 144 145 | |
from_path(path: Union[str, Path], content_type: Optional[str] = None, *, object_key: Optional[str] = None, public_url: Optional[str] = None) -> Reference[T]
classmethod
Create a reference pointing to a file path.
Source code in lingo/corpus.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |