pr feedback
This commit is contained in:
parent
062ada93b2
commit
4ec0bbc3ab
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"python.formatting.provider": "black"
|
||||
}
|
|
@ -57,7 +57,9 @@ instant-segment = "0.8.1"
|
|||
### Examples
|
||||
|
||||
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
|
||||
import instant_segment
|
||||
|
@ -71,7 +73,8 @@ print([word for word in search])
|
|||
```
|
||||
|
||||
```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 mut search = Search::default();
|
||||
|
|
|
@ -3,14 +3,14 @@ import instant_segment
|
|||
|
||||
def main():
|
||||
unigrams = []
|
||||
unigrams.append(("choose", 50))
|
||||
unigrams.append(("chooses", 10))
|
||||
unigrams.append(("spain", 50))
|
||||
unigrams.append(("pain", 10))
|
||||
unigrams.append(("choose", 80_000))
|
||||
unigrams.append(("chooses", 7_000))
|
||||
unigrams.append(("spain", 20_000))
|
||||
unigrams.append(("pain", 90_000))
|
||||
|
||||
bigrams = []
|
||||
bigrams.append((("choose", "spain"), 10))
|
||||
bigrams.append((("chooses", "pain"), 10))
|
||||
bigrams.append((("choose", "spain"), 7))
|
||||
bigrams.append((("chooses", "pain"), 0))
|
||||
|
||||
segmenter = instant_segment.Segmenter(iter(unigrams), iter(bigrams))
|
||||
search = instant_segment.Search()
|
|
@ -4,16 +4,16 @@ use std::collections::HashMap;
|
|||
fn main() {
|
||||
let mut unigrams = HashMap::default();
|
||||
|
||||
unigrams.insert("choose".into(), 50 as f64);
|
||||
unigrams.insert("chooses".into(), 10 as f64);
|
||||
unigrams.insert("choose".into(), 80_000.0);
|
||||
unigrams.insert("chooses".into(), 7_000.0);
|
||||
|
||||
unigrams.insert("spain".into(), 50 as f64);
|
||||
unigrams.insert("pain".into(), 10 as f64);
|
||||
unigrams.insert("spain".into(), 20_000.0);
|
||||
unigrams.insert("pain".into(), 90_000.0);
|
||||
|
||||
let mut bigrams = HashMap::default();
|
||||
|
||||
bigrams.insert(("choose".into(), "spain".into()), 10 as f64);
|
||||
bigrams.insert(("chooses".into(), "pain".into()), 10 as f64);
|
||||
bigrams.insert(("choose".into(), "spain".into()), 7.0);
|
||||
bigrams.insert(("chooses".into(), "pain".into()), 0.0);
|
||||
|
||||
let segmenter = Segmenter::from_maps(unigrams, bigrams);
|
||||
let mut search = Search::default();
|
Loading…
Reference in New Issue