https://github.com/slashdotted/semola-flutter
Hyphenation engine for the italian language
https://github.com/slashdotted/semola-flutter
Last synced: 6 months ago
JSON representation
Hyphenation engine for the italian language
- Host: GitHub
- URL: https://github.com/slashdotted/semola-flutter
- Owner: slashdotted
- License: bsd-3-clause
- Created: 2023-01-09T12:24:36.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-04-05T21:09:16.000Z (almost 3 years ago)
- Last Synced: 2024-04-22T10:11:31.816Z (over 1 year ago)
- Language: Dart
- Size: 13.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Semola - Hyphenation engine for the italian language
## Features
Semola is used to hyphenate italian words. It mainly uses regular expressions
built upon the rules of the Accademia della Crusca but also has some built-in
exceptions and allows for user-defined exceptions.
The *hyphenate* method accepts a word (String) and returns a list the syllables.
The *addException* method is used to add a user-defined exception (a String where syllables
are separated using '-'), whereas the *clearExceptions* method is used do delete
all user-defined exceptions.
## Getting started
This package only provides the *Semola* class, which exposes several static methods: *hyphenate* (to hyphenate a word), *addException* (to add a user-defined exception), and *clearExceptions* (to remove all user-defined exceptions).
## Usage
Semola can hyphenate simple words (even with some punctuation at the end):
```dart
expect(Semola.hyphenate(r"suonò"), ["suo", "nò"]);
expect(Semola.hyphenate(r"pompiere"), ["pom", "pie", "re"]);
expect(Semola.hyphenate(r"lunghissimo"), ["lun", "ghis", "si", "mo"]);
expect(Semola.hyphenate(r"per"), ["per"]);
expect(Semola.hyphenate(r"perché,"), ["per", "ché,"]);
expect(Semola.hyphenate("perché\""), ["per", "ché\""]);
expect(Semola.hyphenate("CACTUS"), ["CAC", "TUS"]);
expect(Semola.hyphenate("Cactus"), ["Cac", "tus"]);
expect(Semola.hyphenate("cactus"), ["cac", "tus"]);
expect(Semola.hyphenate(r"appioppare"), ["ap", "piop", "pa", "re"]);
expect(Semola.hyphenate(r"viola"), ["vio", "la"]);
expect(Semola.hyphenate(r"suonò..."), ["suo", "nò..."]);
expect(Semola.hyphenate(r"pompiere..."), ["pom", "pie", "re..."]);
expect(Semola.hyphenate(r"lunghissimo..."), ["lun", "ghis", "si", "mo..."]);
expect(Semola.hyphenate(r"per..."), ["per..."]);
```
Since there is no built-in dictionary, some words are dealt with using exceptions:
```dart
expect(Semola.hyphenate("piovra"), ["pio", "vra"]);
expect(Semola.hyphenate("pioli"), ["pi", "o", "li"]);
expect(Semola.hyphenate("piovra..."), ["pio", "vra..."]);
expect(Semola.hyphenate("pioli..."), ["pi", "o", "li..."]);
```
It is also possible to add new exceptions:
```dart
Semola.addException("p-i-o-v-r-a");
expect(Semola.hyphenate("piovra"), ["p", "i", "o", "v", "r", "a"]);
Semola.clearExceptions();
expect(Semola.hyphenate("piovra"), ["pio", "vra"]);
```
## Additional information
Built-in exceptions will be updated in future versions.