2026-02-18 00:32:49 +00:00
2026-02-18 00:32:49 +00:00
2025-08-09 23:33:42 +04:00
2025-08-09 23:33:42 +04:00
2025-09-21 00:01:30 +02:00
2025-09-21 00:01:30 +02:00
2025-08-28 21:13:39 +04:00

Tests

syllabreak-swift

Multilingual library for accurate and deterministic hyphenation and syllable counting without relying on dictionaries.

This is a Swift port of syllabreak Python library.

Supported Languages

  • 🇬🇧 English (eng)
  • 🇷🇺 Russian (rus)
  • 🇷🇸 Serbian Cyrillic (srp-cyrl)
  • 🇷🇸 Serbian Latin (srp-latn)
  • 🇹🇷 Turkish (tur)
  • 🇬🇪 Georgian (kat)
  • 🇩🇪 German (deu)

Usage

Auto-detect language

When no language is specified, the library automatically detects the most likely language:

import Syllabreak

let s = Syllabreak(softHyphen: "-")
print(s.syllabify("hello"))
// hel-lo
print(s.syllabify("здраво"))  // Serbian Cyrillic
// здра-во
print(s.syllabify("привет"))  // Russian
// при-вет

Specify language explicitly

You can specify the language code for more predictable results:

let s = Syllabreak(softHyphen: "-")
print(s.syllabify("problem", lang: "eng"))  // Force English rules
// pro-blem
print(s.syllabify("problem", lang: "srp-latn"))  // Force Serbian Latin rules
// prob-lem

This is useful when:

  • The text could match multiple languages
  • You want consistent rules for a specific language
  • Processing text in a known language

Language Detection

The library returns all matching languages sorted by confidence:

import Syllabreak

let s = Syllabreak()
print(s.detectLanguage("hello"))
// ["eng", "srp-latn", "tur"]  // Matches English, Serbian Latin and Turkish
print(s.detectLanguage("čovek"))
// ["srp-latn", "eng", "tur"]  // Serbian Latin has highest confidence due to č

Lines of Code

Lines of Code graph
S
Description
Multilingual library for accurate and deterministic hyphenation and syllable counting without relying on dictionaries.
Readme MIT 504 KiB
Languages
Swift 98.1%
Makefile 1.9%