diff --git a/instant-segment-py/src/lib.rs b/instant-segment-py/src/lib.rs index e493dec..4a00b39 100644 --- a/instant-segment-py/src/lib.rs +++ b/instant-segment-py/src/lib.rs @@ -90,6 +90,17 @@ impl Segmenter { )), } } + + /// Returns the sentence's score + /// + /// Returns the relative probability for the given sentence in the the corpus represented by + /// this `Segmenter`. Will return `None` iff given an empty iterator argument. + fn sentence_score(&self, words: &PyIterator) -> PyResult> { + let words = words + .map(|s| s?.extract::<&str>()) + .collect::, _>>()?; + Ok(self.inner.sentence_score(words.into_iter())) + } } /// Search buffer and result set