mirror of
https://github.com/mii443/tokenizers.git
synced 2025-08-22 16:25:30 +00:00
Quick improvement over python bindings
This commit is contained in:
@ -1,4 +1,5 @@
|
|||||||
extern crate tokenizers as tk;
|
extern crate tokenizers as tk;
|
||||||
|
|
||||||
use pyo3::prelude::*;
|
use pyo3::prelude::*;
|
||||||
use pyo3::wrap_pyfunction;
|
use pyo3::wrap_pyfunction;
|
||||||
|
|
||||||
@ -6,8 +7,7 @@ use pyo3::wrap_pyfunction;
|
|||||||
/// Tokenize
|
/// Tokenize
|
||||||
fn tokenize(a: String) -> PyResult<Vec<u32>> {
|
fn tokenize(a: String) -> PyResult<Vec<u32>> {
|
||||||
println!("Tokenize in rust");
|
println!("Tokenize in rust");
|
||||||
tk::test();
|
Ok(tk::tokenize(&a))
|
||||||
Ok(vec![1, 2, 3])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pymodule]
|
#[pymodule]
|
||||||
@ -20,6 +20,6 @@ fn tokenizers(py: Python, m: &PyModule) -> PyResult<()> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn it_works() {
|
fn it_works() {
|
||||||
assert_eq!(2 + 2, 4);
|
assert_eq!(tk::tokenize("Hey man!"), vec![1, 2, 3]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
tokenizers/Cargo.lock
generated
2
tokenizers/Cargo.lock
generated
@ -1,6 +1,6 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokenizers"
|
name = "tokenizers-lib"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
/// This is the CLI binary for the Tokenizers project
|
/// This is the CLI binary for the Tokenizers project
|
||||||
use tokenizers::test;
|
use tokenizers;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("Hello, world!");
|
println!("Hello, world!");
|
||||||
test();
|
let s = "Hey man!";
|
||||||
|
println!("Tokenizing {:?} gives {:?}", s, tokenizers::tokenize(&s));
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
pub fn test() {
|
pub fn tokenize(s: &str) -> Vec<u32> {
|
||||||
println!("Test");
|
vec![1, 2, 3]
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user