-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from stephantul/64-feat-add-support-for-legacy…
…-fast-format Add legacy loading
- Loading branch information
Showing
4 changed files
with
94 additions
and
12 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import json | ||
from pathlib import Path | ||
|
||
import numpy as np | ||
import numpy.typing as npt | ||
|
||
|
||
def load_old_fast_format_data( | ||
path: Path, | ||
) -> tuple[npt.NDArray, list[str], str | None, str]: | ||
"""Load data from fast format.""" | ||
with open(f"{path}_items.json") as file_handle: | ||
items = json.load(file_handle) | ||
tokens, unk_index, name = items["items"], items["unk_index"], items["name"] | ||
|
||
with open(f"{path}_vectors.npy", "rb") as file_handle: | ||
vectors = np.load(file_handle) | ||
|
||
unk_token = tokens[unk_index] if unk_index is not None else None | ||
return vectors, tokens, unk_token, name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters