Latest 0.0.2
Homepage https://github.com/lxian/Fuzzywuzzy_swift
License MIT
Platforms ios 8.0, requires ARC
Authors

Fuzzy String Matching in Swift using Levenshtein Distance. Ported from the python fuzzywuzzy library https://github.com/seatgeek/fuzzywuzzy

It has no external dependancies. And thanks to Swift String, it can support multi-language.

Installation

Carthage

Add the following line to your Cartfile. And run carthage update

github "lxian/Fuzzywuzzy_swift"

Cocoapod

Add the following line to your Podfile. And run pod install

pod 'Fuzzywuzzy_swift', :git=> 'https://github.com/lxian/Fuzzywuzzy_swift.git'

Manually

drag the Fuzzywuzzy_swift folder into your project

Usage

import Fuzzywuzzy_swift

Simple Ratio

String.fuzzRatio(str1: "some text here", str2: "same text here!") // => 93

Partial Ratio

Partial Ratio tries to match the shoter string to a substring of the longer one

String.fuzzPartialRatio(str1: "some text here", str2: "I found some text here!") // => 100

Token Sort Ratio

Split strings by white space into arrays of tokens. Sort two arrays of Tokens. Calculate the effort needed to transform on arry of token into another. Characters other than letters and numbers are removed as a pre-processing by default.

String.fuzzTokenSortRatio(str1: "fuzzy wuzzy was a bear", str2: "wuzzy fuzzy was a bear") // => 100

String.fuzzTokenSortRatio(str1: "fuzzy+wuzzy(was) a bear", str2: "wuzzy fuzzy was a bear") // => 100

set fullProcess to false to remove this pre-processing

String.fuzzTokenSortRatio(str1: "fuzzy+wuzzy(was) a bear", str2: "wuzzy fuzzy was a bear", fullProcess: false) // => 77

Token Set Ratio

Similiar to token sort ratio while it put tokens into a set trying to remove duplicated tokens.

String.fuzzTokenSortRatio(str1: "fuzzy was a bear", str2: "fuzzy fuzzy was a bear") // => 84

String.fuzzTokenSetRatio(str1: "fuzzy was a bear", str2: "fuzzy fuzzy was a bear") // => 100

Latest podspec

{
    "name": "Fuzzywuzzy_swift",
    "version": "0.0.2",
    "summary": "Fuzzy String Matching in Swift using Levenshtein Distance. Inspired by the python fuzzywuzzy library https://github.com/seatgeek/fuzzywuzzy",
    "description": "Fuzzy String Matching in Swift using Levenshtein Distance. Ported from the python fuzzywuzzy library https://github.com/seatgeek/fuzzywuzzynIt supports multiple types of string matching.nIt has no external dependancies. And thanks to Swift String, it can support multi-language.",
    "homepage": "https://github.com/lxian/Fuzzywuzzy_swift",
    "license": {
        "type": "MIT",
        "file": "LICENSE.txt"
    },
    "authors": {
        "Li Xian": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "source": {
        "git": "https://github.com/lxian/Fuzzywuzzy_swift.git",
        "tag": "0.0.2",
        "submodules": true
    },
    "source_files": "Fuzzywuzzy_swift/**/*.{h,swift}"
}

Pin It on Pinterest

Share This