Coder Social home page Coder Social logo

imranhamzah / fuzzywuzzy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xdrop/fuzzywuzzy

0.0 2.0 0.0 140 KB

Java fuzzy string matching implemenation of the well known Python's fuzzywuzzy algorithm. Fuzzy search for Java

License: GNU General Public License v3.0

Java 84.53% Groovy 15.32% Shell 0.15%

fuzzywuzzy's Introduction

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.1.9</version>
</dependency>

Gradle

compile 'me.xdrop:fuzzywuzzy:1.1.9'

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)
FuzzySearch.extractTop("goolge", ["google", "bing", "facebook", "linkedin", "twitter", "googleplus", "bingnews", "plexoogl"], 3)
[(string: google, score:83), (string: googleplus, score:63), (string: plexoogl, score:43)]
FuzzySearch.extractAll("goolge", ["google", "bing", "facebook", "linkedin", "twitter", "googleplus", "bingnews", "plexoogl"]);
[(string: google, score:83), (string: bing, score:20), (string: facebook, score:29), (string: linkedin, score:29), (string: twitter, score:15), (string: googleplus, score:63), (string: bingnews, score:29), (string: plexoogl, score:43)]
// score cutoff
FuzzySearch.extractAll("goolge", ["google", "bing", "facebook", "linkedin", "twitter", "googleplus", "bingnews", "plexoogl"], 40) 
[(string: google, score:83), (string: googleplus, score:63), (string: plexoogl, score:43)]
FuzzySearch.extractSorted("goolge", ["google", "bing", "facebook", "linkedin", "twitter", "googleplus", "bingnews", "plexoogl"]);
[(string: google, score:83), (string: googleplus, score:63), (string: plexoogl, score:43), (string: facebook, score:29), (string: linkedin, score:29), (string: bingnews, score:29), (string: bing, score:20), (string: twitter, score:15)]
// score cutoff
FuzzySearch.extractSorted("goolge", ["google", "bing", "facebook", "linkedin", "twitter", "googleplus", "bingnews", "plexoogl"], 3);
[(string: google, score:83), (string: googleplus, score:63), (string: plexoogl, score:43)]

Credits

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

fuzzywuzzy's People

Contributors

xdrop avatar efritzsche avatar michaeltandecki avatar

Watchers

James Cloos avatar Imran Hamzah avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.