Skip to content

Lightweight library to count syllables in words, based on the excellent Java implementation found at https://github.com/m09/syllable-counter

License

Notifications You must be signed in to change notification settings

wfreitag/syllable-counter-swift

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

syllable-counter-swift

Lightweight library to count syllables in words, based on the excellent Java implementation found at https://github.com/m09/syllable-counter

Requirements

Swift 5.3 or newer on macOS or Linux.

Installation

Add the following dependency to your project's Package.swift:

.package(url: "https://github.com/wfreitag/syllable-counter-swift.git", .revision("08cd024da5f30ac32939e718a2a964445a4aab4a"))

How to use

SyllableCounter uses a shared instance that is initialized on first use. There is one public method: count(), which takes a string.

let syllableCount = SyllableCounter.shared.count(word: "wonderful")
print("There are \(syllableCount) syllables in 'wonderful'.")

... or you can use the extension on String:

let syllableCount = "wonderful".syllables
print("There are \(syllableCount) syllables in 'wonderful'.)

The original Java implementation has a caching option. This feature was not ported over to this implementation.

License

Licensed under the Apache 2.0 License. Feel free to use and modify according to the terms expressed in the license. Contributions welcome.

About

Lightweight library to count syllables in words, based on the excellent Java implementation found at https://github.com/m09/syllable-counter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages