Skip to content

Commit

Permalink
Read KyTea's model in allow_threads
Browse files Browse the repository at this point in the history
  • Loading branch information
vbkaisetsu committed Jun 10, 2022
1 parent 3604e2f commit 5b6e4ec
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,11 @@ impl Vaporetto {
norm: bool,
) -> PyResult<Self> {
let f = Cursor::new(model);
let kytea_model = py.allow_threads(|| {
KyteaModel::read(f).map_err(|e| PyValueError::new_err(e.to_string()))
let model = py.allow_threads(|| {
let kytea_model =
KyteaModel::read(f).map_err(|e| PyValueError::new_err(e.to_string()))?;
Model::try_from(kytea_model).map_err(|e| PyValueError::new_err(e.to_string()))
})?;
let model =
Model::try_from(kytea_model).map_err(|e| PyValueError::new_err(e.to_string()))?;
Self::create_internal(py, model, predict_tags, wsconst, norm)
}

Expand Down

0 comments on commit 5b6e4ec

Please sign in to comment.