A simple Swift package for counting the Syllables in a sentence.

Related tags

Utility Syllables
Overview



A simple Swift package for counting the Syllables in a sentence.

Usage

let syllables = Syllables()
syllables.count("dog") // 1
syllables.count("rabbit") // 2
syllables.count("octopus") // 3
syllables.count("I like dogs, rabbits and octopi.") // 9

A 5MB dictionary file is loaded upon Syllables initialisation. You may wish to hold a lazy reference to the Syllables instance if you wish to delay the file load until first use.

private lazy var syllables = Syllables()
syllables.count("dog") // 1

The class caches returned values automatically. This saves a trip to the CMU Dictionary or algorithm for future values. You may wish to turn this off if every input is unique.

let syllables = Syllables()
syllables.isCaching = false

Installation

SPM

Add the following to your project:

https://github.com/ptrkstr/syllables

How Does it Work?

Sentences are broken down into words. These words are first processed through the CMU Pronounciation Dictionary and their syllables extracted. Any words that weren't found in the dictionary have their syllables extracted via an algorithm (with a small number of hardcoded exceptions). The total number of syllables in the sentence are then returned.

Found a Wrong Result?

Raise an issue and I'll investigate 🔎 .

Inspiration

This package is inspired by:

Possible Future Features

  • Handle numbers; read number by number, or as a phrase
You might also like...
Azure Maps iOS SDK binary distribution for Swift Package Manager
Azure Maps iOS SDK binary distribution for Swift Package Manager

Azure Maps Control for iOS Installation In your Xcode iOS Project settings, under Project setting’s Package Dependencies, click on + button to add pac

Numerals is a package containing additional numeric types for the Swift programming language.

swift-numerals Numerals is a package containing additional numeric types for the Swift programming language. Contents The package currently provides t

Swift package adding fraction and percentage types.

swift-rationals Rationals is a package containing Fraction and Percentage types for the Swift programming language. Contents The package currently pro

Swift package adding measurable types.

swift-measures Measures is a package containing measurable types for the Swift programming language. Contents The package currently provides the follo

Swift package for accessing SF Symbols in a type safe manner.

Swift Package Information Code Coverage Swift package for accessing SF Symbols in a type safe manner. Features đź’« Contains all SF Symbols - 1.0, 2.0,

This is a Swift package with support for macOS that allows to start Java Jar's with the default or a custom JVM.

Jar.swift jar runner for macos Jar.swift is created and maintaned with ❥ by Sascha Muellner. What? This is a Swift package with support for macOS that

Units is a Swift package to manipulate, compare, and convert between physical quantities.

Units đź“Ź Units is a Swift package to manipulate, compare, and convert between physical quantities. This package models measurements, which are a numer

 WWDCKit - Creating and Using a Swift Package
WWDCKit - Creating and Using a Swift Package

WWDCKit - Creating and Using a Swift Package 1. Create the Package in Xcode Navigate to File New Package. Give the Package a name e.g "WWDCKit".

Protected is a Swift Package that allows you to specify the read and write rights for any type, depending on context by using Phantom types
Protected is a Swift Package that allows you to specify the read and write rights for any type, depending on context by using Phantom types

Protected is a Swift Package that allows you to specify the read and write rights for any type, depending on context by using Phantom types

Owner
null
Swift Package Manager plugin which runs ActionBuilder to create a Github Actions workflow for a swift package.

ActionBuilderPlugin A Swift Package Manager command which builds a Github Actions workflow for the current package. By default the workflow file will

Elegant Chaos 4 Jul 20, 2022
A simple swift package that provides a Swift Concurrency equivalent to `@Published`.

AsyncValue This is a simple package that provides a convenience property wrapper around AsyncStream that behaves almost identically to @Published. Ins

Brent Mifsud 33 Oct 3, 2022
Updeto is a simple package that help update checker for iOS Apps

Updeto is a simple package that will help you to check if the currently installed version is the same as the latest one available on App Store.

Manuel Sánchez 8 Jul 8, 2022
Swift Markdown is a Swift package for parsing, building, editing, and analyzing Markdown documents.

Swift Markdown is a Swift package for parsing, building, editing, and analyzing Markdown documents.

Apple 2k Dec 28, 2022
Approximate is a Swift package that provides implementations of floating point comparisons for the Swift ecosystem

Approximate Approximate floating point equality comparisons for the Swift Programming Language. Introduction Approximate is a Swift package that provi

Christopher Blanchard 1 Jun 1, 2022
A command-line tool and Swift Package for generating class diagrams powered by PlantUML

SwiftPlantUML Generate UML class diagrams from swift code with this Command Line Interface (CLI) and Swift Package. Use one or more Swift files as inp

null 374 Jan 3, 2023
A Swift package for rapid development using a collection of micro utility extensions for Standard Library, Foundation, and other native frameworks.

ZamzamKit ZamzamKit is a Swift package for rapid development using a collection of micro utility extensions for Standard Library, Foundation, and othe

Zamzam Inc. 261 Dec 15, 2022
Swift implementation of the package url spec

PackageURL Swift implementation of the package url specification. Requirements Swift 5.3+ Usage import PackageURL let purl: PackageURL = "pkg:swift/a

Mattt 21 Jun 14, 2022
Mechanical editing support for Package.swift manifests

Mechanical editing support for Package.swift manifests. Implements Swift Evolution proposal SE-301

Owen Voorhees 9 Jan 4, 2023
Swift Package for Decoding RSS Feeds.

SyndiKit Swift Package built on top of XMLCoder for Decoding RSS Feeds. Check out the DocC-Built Site! Table of Contents Introduction Features Install

BrightDigit 34 Dec 27, 2022