-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Simon Paitrault <contact@freyskeyd.fr>
- Loading branch information
Simon Paitrault
committed
Dec 2, 2015
1 parent
250c189
commit fac78e2
Showing
6 changed files
with
10,071 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#![feature(test)] | ||
|
||
extern crate nlp; | ||
use nlp::distance::*; | ||
|
||
use std::io::prelude::*; | ||
use std::fs::File; | ||
use std::path::Path; | ||
extern crate test; | ||
|
||
use test::Bencher; | ||
|
||
#[bench] | ||
fn bench_levenshtein(b: &mut Bencher) { | ||
b.iter(|| levenshtein("rubert", "rupert")); | ||
} | ||
|
||
// #[bench] | ||
// fn bench_levenshtein_fast(b: &mut Bencher) { | ||
// b.iter(|| levenshtein_fast("rubert", "rupert")); | ||
// } | ||
|
||
#[bench] | ||
fn bench_levenshtein_fast_10K(b: &mut Bencher) { | ||
|
||
let path = Path::new("words2.txt"); | ||
let mut s = String::new(); | ||
let mut file = File::open(&path).unwrap(); | ||
file.read_to_string(&mut s).unwrap(); | ||
|
||
let wbyl: Vec<String> = s.lines().map(|s| s.to_owned()).collect(); | ||
b.iter(|| { | ||
for i in &wbyl { | ||
levenshtein("rubert", &i); | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// use core::str::CharEq; | ||
|
||
// fn tokenize(text: &str) -> Vec<&str> { | ||
// text.split(Splitter).filter(|s| s.len() > 0).collect() | ||
// } | ||
|
||
// struct Splitter; | ||
|
||
// impl CharEq for Splitter { | ||
// fn matches(&mut self, c: char) -> bool { | ||
// match c { | ||
// ' ' | ',' | '.' | '!' | '?' | ';' | '\'' | '"' | ||
// | ':' | '\t' | '\n' | '(' | ')' | '-' => true, | ||
// _ => false | ||
// } | ||
// } | ||
|
||
// fn only_ascii(&self) -> bool { | ||
// true | ||
// } | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
extern crate nlp; | ||
use nlp::tokenize::tokenize; | ||
|
||
#[test] | ||
fn test_tokenize() { | ||
assert_eq!(tokenize("hello, world!"), vec!["hello", "world"]); | ||
} |
Oops, something went wrong.