Latest 0.1.1
Homepage https://github.com/mathiasquintero/Fuzzi
License MIT
Platforms ios 8.0
Authors

Locally searching in Swift made simple (and fuzzily).

Wat?

Fuzzi allows you to search efficiently through a lot of data.
It uses BK-Tree’s as well as a weigthed size based score with the Levenshtein distance of strings to find the correct results and sort them accordingly.

Installing

Fuzzi is available on Cocoapods. (at least soon)
Simply add the following to your podfile:

pod 'Fuzzi'

Usage

Start by defining what you want to search. Let it implement the protocol Searchable.
This will require it your data to be both Hashable, Equatable and Codable as well as provide the strings by which the data should be searched.

Like say:

struct Repo {
  let name: String
  let description: String
  let link: URL
}

extension Repo: Searchable {

  var hashValue: Int {
    return name.hashValue ^ description.hashValue ^ link.hashValue
  }

  static func == (lhs: Repo, rhs: Repo) -> Bool {
    return lhs.name == rhs.name && 
      lhs.description == rhs.description && 
      lhs.link == rhs.link
  }

  var searchableProperties: [KeyPath<Repo, String>] {
    return [
      .name,
      .description,
    ]
  }

}

Then whenever you have a collection of these objects simply use .tree() to create a searchTree.

let tree = repos.tree()

tree.search(for: "Fzzi") // Should return the "Fuzzi" repo

Contributing

PRs are welcome!

Latest podspec

{
    "name": "Fuzzi",
    "version": "0.1.1",
    "summary": "Locally searching in Swift made simple (and fuzzily)",
    "description": "Locally searching in Swift made simple (and fuzzily)",
    "homepage": "https://github.com/mathiasquintero/Fuzzi",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "mathiasquintero": "[email protected]"
    },
    "source": {
        "git": "https://github.com/mathiasquintero/Fuzzi.git",
        "tag": "0.1.1"
    },
    "social_media_url": "https://twitter.com/nerdsupremacist",
    "swift_version": "4.1",
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "Fuzzi/Classes/**/*"
}

Pin It on Pinterest

Share This