pr feedback

This commit is contained in:
Nicholas Rempel 2021-04-27 09:24:48 -07:00
parent 062ada93b2
commit 4ec0bbc3ab
4 changed files with 20 additions and 14 deletions

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"python.formatting.provider": "black"
}

View File

@ -57,7 +57,9 @@ instant-segment = "0.8.1"
### Examples ### Examples
The following examples expect `unigrams` and `bigrams` to exist. See the The following examples expect `unigrams` and `bigrams` to exist. See the
[examples](./examples) to see how to construct these objects. examples ([Rust](./instant-segment/examples/contrived.rs),
[Python](./instant-segment-py/examples/contrived.py)) to see how to construct
these objects.
```python ```python
import instant_segment import instant_segment
@ -71,7 +73,8 @@ print([word for word in search])
``` ```
```rust ```rust
use instant_segment::{Search, Segmenter}; use std::collections::HashMap; use instant_segment::{Search, Segmenter};
use std::collections::HashMap;
let segmenter = Segmenter::from_maps(unigrams, bigrams); let segmenter = Segmenter::from_maps(unigrams, bigrams);
let mut search = Search::default(); let mut search = Search::default();

View File

@ -3,14 +3,14 @@ import instant_segment
def main(): def main():
unigrams = [] unigrams = []
unigrams.append(("choose", 50)) unigrams.append(("choose", 80_000))
unigrams.append(("chooses", 10)) unigrams.append(("chooses", 7_000))
unigrams.append(("spain", 50)) unigrams.append(("spain", 20_000))
unigrams.append(("pain", 10)) unigrams.append(("pain", 90_000))
bigrams = [] bigrams = []
bigrams.append((("choose", "spain"), 10)) bigrams.append((("choose", "spain"), 7))
bigrams.append((("chooses", "pain"), 10)) bigrams.append((("chooses", "pain"), 0))
segmenter = instant_segment.Segmenter(iter(unigrams), iter(bigrams)) segmenter = instant_segment.Segmenter(iter(unigrams), iter(bigrams))
search = instant_segment.Search() search = instant_segment.Search()

View File

@ -4,16 +4,16 @@ use std::collections::HashMap;
fn main() { fn main() {
let mut unigrams = HashMap::default(); let mut unigrams = HashMap::default();
unigrams.insert("choose".into(), 50 as f64); unigrams.insert("choose".into(), 80_000.0);
unigrams.insert("chooses".into(), 10 as f64); unigrams.insert("chooses".into(), 7_000.0);
unigrams.insert("spain".into(), 50 as f64); unigrams.insert("spain".into(), 20_000.0);
unigrams.insert("pain".into(), 10 as f64); unigrams.insert("pain".into(), 90_000.0);
let mut bigrams = HashMap::default(); let mut bigrams = HashMap::default();
bigrams.insert(("choose".into(), "spain".into()), 10 as f64); bigrams.insert(("choose".into(), "spain".into()), 7.0);
bigrams.insert(("chooses".into(), "pain".into()), 10 as f64); bigrams.insert(("chooses".into(), "pain".into()), 0.0);
let segmenter = Segmenter::from_maps(unigrams, bigrams); let segmenter = Segmenter::from_maps(unigrams, bigrams);
let mut search = Search::default(); let mut search = Search::default();