Skip to content

Awesome AhoCorasick based bad word filtering ๐Ÿ˜ก๐Ÿ’ฅ

License

Notifications You must be signed in to change notification settings

gomminjae/SwiftyCorasick

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

12 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

SwiftyCorasick

Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • iOS 16.0+
  • Xcode 12.0+
  • Swift 5.0+

Installation

Podfile

pod 'SwiftyCorasick'

Package.swift

let package = Package(
  name: "MyPackage",
  dependencies: [
    .package(url: "https://github.com/gomminjae/SwiftyCorasick.git")
  ],
  targets: [
    .target(name: "MyTarget", dependencies: ["SwiftyCorasick"])
  ]
)

๐Ÿ“– Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Basic Example

Below is a simple example of how to use SwiftyCorasick to search for patterns in a given text.

import SwiftyCorasick

// Define patterns to search
let patterns = ["swift", "code", "corasick"]
let ac = SwiftyCorasick.shared

// Bind patterns to the trie
ac.bindKeywords(patterns)

// Text to search
let text = "swift and code with Aho-Corasick algorithm"

// Search for patterns in the text
ac.processTextAsync(text) { filteredText in
    print("Filtered Text: \(filteredText)")
}

Output

Filtered Text: "***** and **** with Aho-******** algorithm"

Author

gomminjae, gommj0611@naver.com

License

SwiftyCorasick is available under the MIT license. See the LICENSE file for more info.

About

Awesome AhoCorasick based bad word filtering ๐Ÿ˜ก๐Ÿ’ฅ

Resources

License

Stars

Watchers

Forks

Packages

No packages published