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