We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 26d507a commit 5a79f53Copy full SHA for 5a79f53
lib/ratios/simple_ratio.dart
@@ -4,6 +4,10 @@ import '../diffutils/diff_utils.dart';
4
class SimpleRatio implements Applicable {
5
@override
6
int apply(String s1, String s2) {
7
- return (100 * DiffUtils.getRatio(s1, s2)).round();
+ final diff = DiffUtils.getRatio(s1, s2);
8
+ if (diff.isNaN) {
9
+ return 0;
10
+ }
11
+ return (diff * 100).round();
12
}
13
test/fuzzywuzzy_test.dart
@@ -60,6 +60,11 @@ void main() {
60
'the quick brown fox jumps over the small lazy dog');
61
expect(result, 97);
62
});
63
+
64
+ test('Weighted ratio with newlines', () {
65
+ final result = weightedRatio('\n \n ', 'test');
66
+ expect(result, 0);
67
+ });
68
69
70
group('Extractors', () {
0 commit comments