diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0c673b3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +# Flutter/Dart/Pub related +**/doc/api/ +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ +build/ \ No newline at end of file diff --git a/lib/fuzzy_search.dart b/lib/fuzzy_search.dart index dc53766..42e0909 100644 --- a/lib/fuzzy_search.dart +++ b/lib/fuzzy_search.dart @@ -1,5 +1,6 @@ import 'algorithms/token_set.dart'; import 'algorithms/token_sort.dart'; +import 'algorithms/weighted_ratio.dart'; import 'ratios/partial_ratio.dart'; import 'ratios/simple_ratio.dart'; @@ -26,3 +27,14 @@ int tokenSetRatio(String s1, String s2) { int tokenSetPartialRatio(String s1, String s2) { return TokenSet().apply(s1, s2, PartialRatio()); } + +/// Calculates a weighted ratio between [s1] and [s2] using several different +/// fuzzy matching algorithms +/// +/// Example: +/// ```dart +/// weightedRatio("The quick brown fox jimps ofver the small lazy dog", "the quick brown fox jumps over the small lazy dog") // 97 +/// ``` +int weightedRatio(String s1, String s2) { + return WeightedRatio().apply(s1.toLowerCase(), s2.toLowerCase()); +} diff --git a/lib/main.dart b/lib/main.dart deleted file mode 100644 index e69de29..0000000 diff --git a/pubspec.lock b/pubspec.lock new file mode 100644 index 0000000..0902e0e --- /dev/null +++ b/pubspec.lock @@ -0,0 +1,5 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: {} +sdks: + dart: ">=2.7.0 <3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 922e3c8..3399615 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,7 @@ name: "fuzzywuzzy" version: "0.1.0" homepage: "https://github.com/sphericalkat/dart-fuzzywuzzy" +description: An implementation of the popular fuzzywuzzy package in dart environment: sdk: ">=2.7.0 <3.0.0" \ No newline at end of file