Upgrade to PyO3 0.23
This commit is contained in:
parent
6cd525c6a6
commit
8861aa7865
|
@ -18,5 +18,5 @@ crate-type = ["cdylib"]
|
|||
[dependencies]
|
||||
bincode = "1.3.2"
|
||||
instant-segment = { version = "0.11", path = "../instant-segment", features = ["with-serde"] }
|
||||
pyo3 = { version = "0.22", features = ["extension-module"] }
|
||||
pyo3 = { version = "0.23", features = ["extension-module"] }
|
||||
smartstring = "1"
|
||||
|
|
|
@ -34,7 +34,7 @@ impl Segmenter {
|
|||
#[new]
|
||||
fn new(unigrams: &Bound<'_, PyIterator>, bigrams: &Bound<'_, PyIterator>) -> PyResult<Self> {
|
||||
let unigrams = unigrams
|
||||
.iter()?
|
||||
.try_iter()?
|
||||
.map(|result| {
|
||||
let item = result?;
|
||||
let key = item.get_item(0)?;
|
||||
|
@ -46,7 +46,7 @@ impl Segmenter {
|
|||
.collect::<Result<Vec<_>, PyErr>>()?;
|
||||
|
||||
let bigrams = bigrams
|
||||
.iter()?
|
||||
.try_iter()?
|
||||
.map(|item| {
|
||||
let item = item?;
|
||||
|
||||
|
@ -108,7 +108,7 @@ impl Segmenter {
|
|||
/// this `Segmenter`. Will return `None` iff given an empty iterator argument.
|
||||
fn score_sentence(&self, words: &Bound<'_, PyIterator>) -> PyResult<Option<f64>> {
|
||||
let words = words
|
||||
.iter()?
|
||||
.try_iter()?
|
||||
.map(|result| result?.extract::<PyBackedStr>())
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
Ok(self.inner.score_sentence(words.iter().map(|s| &**s)))
|
||||
|
|
Loading…
Reference in New Issue