MCPcopy Index your code
hub / github.com/xdrop/fuzzywuzzy

github.com/xdrop/fuzzywuzzy @1.3.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release 1.3.0 ↗ · + Follow
110 symbols 242 edges 27 files 34 documented · 31% 7 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

JavaWuzzy

Build Status Download

FuzzyWuzzy Java Implementation

Fuzzy string matching for java based on the FuzzyWuzzy Python algorithm. The algorithm uses Levenshtein distance to calculate similarity between strings.

I've personally needed to use this but all of the other Java implementations out there either had a crazy amount of dependencies, or simply did not output the correct results as the python one, so I've decided to properly re-implement this in Java. Enjoy!

  • No dependencies!
  • Includes implementation of the super-fast python-Levenshtein in Java!
  • Simple to use!
  • Lightweight!
  • Credits to the great folks at seatgeek for coming up with the algorithm (More here)

Installation

Maven Central

<dependency>
    <groupId>me.xdrop</groupId>
    <artifactId>fuzzywuzzy</artifactId>
    <version>1.2.0</version>
</dependency>

Gradle

repositories {
    jcenter()
}

dependencies {
    implementation 'me.xdrop:fuzzywuzzy:1.2.0'
}

Jar release

Download the latest release here and add to your classpath

Usage

Simple Ratio

FuzzySearch.ratio("mysmilarstring","myawfullysimilarstirng")
72

FuzzySearch.ratio("mysmilarstring","mysimilarstring")
97

Partial Ratio

FuzzySearch.partialRatio("similar", "somewhresimlrbetweenthisstring")
71

Token Sort Ratio

FuzzySearch.tokenSortPartialRatio("order words out of","  words out of order")
100
FuzzySearch.tokenSortRatio("order words out of","  words out of order")
100

Token Set Ratio

FuzzySearch.tokenSetRatio("fuzzy was a bear", "fuzzy fuzzy fuzzy bear")
100
FuzzySearch.tokenSetPartialRatio("fuzzy was a bear", "fuzzy fuzzy fuzzy bear")
100

Weighted Ratio

FuzzySearch.weightedRatio("The quick brown fox jimps ofver the small lazy dog", "the quick brown fox jumps over the small lazy dog")
97

Extract

// groovy

FuzzySearch.extractOne("cowboys", ["Atlanta Falcons", "New York Jets", "New York Giants", "Dallas Cowboys"])
(string: Dallas Cowboys, score: 90, index: 3)
FuzzySearch.extractTop("goolge", ["google", "bing", "facebook", "linkedin", "twitter", "googleplus", "bingnews", "plexoogl"], 3)
[(string: google, score: 83, index: 0), (string: googleplus, score: 63, index:5), (string: plexoogl, score: 43, index: 7)]
FuzzySearch.extractAll("goolge", ["google", "bing", "facebook", "linkedin", "twitter", "googleplus", "bingnews", "plexoogl"]);
[(string: google, score: 83, index: 0), (string: bing, score: 20, index: 1), (string: facebook, score: 29, index: 2), (string: linkedin, score: 29, index: 3), (string: twitter, score: 15, index: 4), (string: googleplus, score: 63, index: 5), (string: bingnews, score: 29, index: 6), (string: plexoogl, score: 43, index: 7)]
// score cutoff
FuzzySearch.extractAll("goolge", ["google", "bing", "facebook", "linkedin", "twitter", "googleplus", "bingnews", "plexoogl"], 40) 
[(string: google, score: 83, index: 0), (string: googleplus, score: 63, index: 5), (string: plexoogl, score: 43, index: 7)]
FuzzySearch.extractSorted("goolge", ["google", "bing", "facebook", "linkedin", "twitter", "googleplus", "bingnews", "plexoogl"]);
[(string: google, score: 83, index: 0), (string: googleplus, score: 63, index: 5), (string: plexoogl, score: 43, index: 7), (string: facebook, score: 29, index: 2), (string: linkedin, score: 29, index: 3), (string: bingnews, score: 29, index: 6), (string: bing, score: 20, index: 1), (string: twitter, score: 15, index: 4)]
// score cutoff
FuzzySearch.extractSorted("goolge", ["google", "bing", "facebook", "linkedin", "twitter", "googleplus", "bingnews", "plexoogl"], 3);
[(string: google, score: 83, index: 0), (string: googleplus, score: 63, index: 5), (string: plexoogl, score: 43, index: 7)]

Extract using any object

extractOne and related methods can receive Collection<T> and produce BoundExtractedResult<T>

List<Foo> foo = ...;
BoundExtractedResult<Foo> match = FuzzySearch.extractOne("cowboys", foo, x -> x.toString());
Foo matchFoo = match.getReferent();

Credits

  • seatgeek
  • Adam Cohen
  • David Necas (python-Levenshtein)
  • Mikko Ohtamaa (python-Levenshtein)
  • Antti Haapala (python-Levenshtein)
  • Tobias Burdow (burdoto)

Extension points exported contracts — how you extend this code

Ratio (Interface)
Interface for the different ratios [11 implementers]
src/me/xdrop/fuzzywuzzy/Ratio.java
ToStringFunction (Interface)
Transforms an item of type T to a String. @param The type of the item to transform. [9 implementers]
src/me/xdrop/fuzzywuzzy/ToStringFunction.java
Applicable (Interface)
A ratio/algorithm that can be applied [10 implementers]
src/me/xdrop/fuzzywuzzy/Applicable.java

Core symbols most depended-on inside this repo

apply
called by 30
src/me/xdrop/fuzzywuzzy/Ratio.java
extractTop
called by 16
src/me/xdrop/fuzzywuzzy/Extractor.java
extractWithoutOrder
called by 14
src/me/xdrop/fuzzywuzzy/Extractor.java
max
called by 7
src/me/xdrop/fuzzywuzzy/algorithms/Utils.java
extractOne
called by 4
src/me/xdrop/fuzzywuzzy/Extractor.java
sortAndJoin
called by 4
src/me/xdrop/fuzzywuzzy/algorithms/Utils.java
ratio
called by 2
src/me/xdrop/fuzzywuzzy/FuzzySearch.java
partialRatio
called by 2
src/me/xdrop/fuzzywuzzy/FuzzySearch.java

Shape

Method 83
Class 23
Interface 3
Enum 1

Languages

Java100%

Modules by API surface

src/me/xdrop/fuzzywuzzy/FuzzySearch.java12 symbols
src/me/xdrop/fuzzywuzzy/model/BoundExtractedResult.java9 symbols
src/me/xdrop/fuzzywuzzy/model/ExtractedResult.java8 symbols
src/me/xdrop/fuzzywuzzy/Extractor.java8 symbols
diffutils/src/me/xdrop/diffutils/DiffUtils.java8 symbols
src/me/xdrop/fuzzywuzzy/algorithms/Utils.java7 symbols
src/me/xdrop/fuzzywuzzy/algorithms/BasicAlgorithm.java7 symbols
src/me/xdrop/fuzzywuzzy/algorithms/RatioAlgorithm.java6 symbols
src/me/xdrop/fuzzywuzzy/algorithms/DefaultStringProcessor.java4 symbols
src/me/xdrop/fuzzywuzzy/algorithms/DefaultStringFunction.java4 symbols
test/me/xdrop/fuzzywuzzy/ContractCheck.java3 symbols
src/me/xdrop/fuzzywuzzy/algorithms/TokenSort.java3 symbols

For agents

$ claude mcp add fuzzywuzzy \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact