Skip to content

Commit f787942

Browse files
committed
fix notes on wratio
1 parent 09991c5 commit f787942

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

src/fuzzywuzzy_compatible/process.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,13 @@ where
115115
/// Quickly, stably dedupe strings by fuzzily comparing them to each other.
116116
/// Delegates to [dedupe_full].
117117
pub fn dedupe<'a>(items: &[&'a str], threshold: Score) -> Vec<&'a str> {
118-
// TODO: use a better default scorer
119-
let temp_scorer = |a: &&str, b: &&str| wratio(a, b, true, true).try_into().unwrap();
120-
// TODO: extract this default sorter
118+
let scorer = |a: &&str, b: &&str| wratio(a, b, true, true).try_into().unwrap();
121119
let sorter = |a: &&str, b: &&str| match a.len().cmp(&b.len()) {
122120
Ordering::Less => Ordering::Less,
123121
Ordering::Greater => Ordering::Greater,
124122
Ordering::Equal => a.cmp(b),
125123
};
126-
dedupe_full(items, threshold, temp_scorer, sorter, true)
124+
dedupe_full(items, threshold, scorer, sorter, true)
127125
.into_iter()
128126
.map(|s| *s)
129127
.collect()
@@ -152,6 +150,7 @@ pub fn dedupe<'a>(items: &[&'a str], threshold: Score) -> Vec<&'a str> {
152150
/// # use core::cmp::Ordering;
153151
/// # use core::convert::TryInto;
154152
/// # use fuzzywuzzy::primitives::{Match, Score};
153+
/// # use fuzzywuzzy::fuzzywuzzy_compatible::fuzz::wratio;
155154
/// # use fuzzywuzzy::fuzzywuzzy_compatible::process::{ default_processor, default_scorer, dedupe_full };
156155
/// let frodo_baggin = "Frodo Baggin";
157156
/// let frodo_baggins = "Frodo Baggins";
@@ -164,23 +163,16 @@ pub fn dedupe<'a>(items: &[&'a str], threshold: Score) -> Vec<&'a str> {
164163
/// let expected_stable = vec![&frodo_baggins, &samwise, &gandalf, &bilbo];
165164
/// // ... but not when we don't require `stable`.
166165
/// let expected_unstable = vec![&samwise, &gandalf, &frodo_baggins, &bilbo];
167-
/// # // TODO: fix temp scorer
168-
/// let temp_scorer = |a: &&str, b: &&str| {
169-
/// if a.chars().next() == b.chars().next() {
170-
/// 100u8.try_into().unwrap()
171-
/// } else {
172-
/// 0u8.try_into().unwrap()
173-
/// }
174-
/// };
166+
/// let scorer = |a: &&str, b: &&str| wratio(a, b, true, true).try_into().unwrap();
175167
/// let sorter = |a: &&str, b: &&str| {
176168
/// match a.len().cmp(&b.len()) {
177169
/// Ordering::Less => Ordering::Less,
178170
/// Ordering::Greater => Ordering::Greater,
179171
/// Ordering::Equal => a.cmp(b),
180172
/// }
181173
/// };
182-
/// assert_eq!(dedupe_full(&contains_dupes, 70.try_into().unwrap(), temp_scorer, sorter, true), expected_stable);
183-
/// assert_eq!(dedupe_full(&contains_dupes, 70.try_into().unwrap(), temp_scorer, sorter, false), expected_unstable);
174+
/// assert_eq!(dedupe_full(&contains_dupes, 70.try_into().unwrap(), scorer, sorter, true), expected_stable);
175+
/// assert_eq!(dedupe_full(&contains_dupes, 70.try_into().unwrap(), scorer, sorter, false), expected_unstable);
184176
/// ```
185177
pub fn dedupe_full<'a, A: 'a + Eq + Ord>(
186178
items: &'a [A],

0 commit comments

Comments
 (0)