-
Notifications
You must be signed in to change notification settings - Fork 1
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 #27 from databio/dev
Hierarchical tokenizers
- Loading branch information
Showing
46 changed files
with
3,496 additions
and
671 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Compute coverage | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
pull_request: | ||
branches: [ "master" ] | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
coverage: | ||
runs-on: ubuntu-latest | ||
env: | ||
CARGO_TERM_COLOR: always | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install Rust | ||
run: rustup update stable | ||
- name: Install cargo-llvm-cov | ||
uses: taiki-e/install-action@cargo-llvm-cov | ||
- name: Generate code coverage | ||
run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info | ||
working-directory: ./gtars | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
files: lcov.info | ||
fail_ci_if_error: true | ||
working-directory: ./gtars |
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,22 @@ | ||
name: Run tests | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
pull_request: | ||
branches: [ "master" ] | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
run: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Build | ||
run: cargo build --verbose | ||
working-directory: ./gtars | ||
- name: Run tests | ||
run: cargo test --verbose | ||
working-directory: ./gtars |
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
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
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,48 @@ | ||
// TODO: stil a work in progress | ||
use pyo3::prelude::*; | ||
|
||
use anyhow::Result; | ||
|
||
use std::path::Path; | ||
|
||
|
||
use gtars::tokenizers::TokenizerConfig; | ||
|
||
use super::{ | ||
PyMetaTokenizer, | ||
PyTreeTokenizer | ||
}; | ||
|
||
#[pyclass(name="TokenizerBuilder")] | ||
pub struct PyTokenizerBuilder; | ||
|
||
#[pymethods] | ||
impl PyTokenizerBuilder { | ||
|
||
#[classmethod] | ||
pub fn from_toml(path: String) -> Result<PyObject> { | ||
let config = TokenizerConfig::new(Path::new(&path))?; | ||
|
||
match config.tokenizer_type { | ||
Some(tokenizer_type) => { | ||
match tokenizer_type.as_str() { | ||
"tree" => { | ||
let t = PyTreeTokenizer::new(path)?; | ||
t.to_object() | ||
}, | ||
"meta" => { | ||
PyMetaTokenizer::new(path) | ||
}, | ||
_ => { | ||
anyhow::bail!("Tokenizer type {} not supported", tokenizer_type) | ||
} | ||
} | ||
}, | ||
None => { | ||
println!("No tokenizer type found in config file. Instantiating a default TreeTokenizer. Note that this may lead to unexpected behavior."); | ||
PyTreeTokenizer::new(path) | ||
} | ||
}; | ||
|
||
} | ||
} |
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
Oops, something went wrong.