-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .genimtools.utils import * |
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,11 @@ | ||
from typing import List | ||
|
||
def write_tokens_to_gtok(filename: str, tokens: List[int]) -> None: | ||
""" | ||
Write a list of tokens to a gtok file. | ||
""" | ||
|
||
def read_tokens_from_gtok(filename: str) -> List[int]: | ||
""" | ||
Read a list of tokens from a gtok 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use pyo3::prelude::*; | ||
|
||
|
||
#[pyfunction] | ||
pub fn write_tokens_to_gtok(filename: &str, tokens: Vec<u32>) -> PyResult<()> { | ||
genimtools::io::write_tokens_to_gtok(filename, &tokens)?; | ||
Ok(()) | ||
} | ||
|
||
#[pyfunction] | ||
pub fn read_tokens_from_gtok(filename: &str) -> PyResult<Vec<u32>> { | ||
let tokens = genimtools::io::read_tokens_from_gtok(filename)?; | ||
Ok(tokens) | ||
} | ||
|
||
#[pymodule] | ||
pub fn utils(_py: Python, m: &PyModule) -> PyResult<()> { | ||
m.add_wrapped(wrap_pyfunction!(write_tokens_to_gtok))?; | ||
m.add_wrapped(wrap_pyfunction!(read_tokens_from_gtok))?; | ||
Ok(()) | ||
} |
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