# `Text.Syllable`
[🔗](https://github.com/kipcole9/text/blob/v0.5.0/lib/syllable.ex#L1)

Syllable counting for English words.

Uses a vowel-group heuristic with a small table of known
exceptions. This is the same family of algorithm used by Python's
`textstat` and is accurate enough (~90%) for the readability
metrics in `Text.Readability`. For exact hyphenation points or
precise syllable boundaries, prefer `Text.Hyphenation`, which uses
Liang's algorithm with TeX hyphenation patterns.

Only English (`:en`) is supported at the moment. Other languages
will raise `ArgumentError`. Multilingual support will arrive when
`Text.Hyphenation` lands and this module can defer to its
pattern-based syllable boundaries.

# `count`

```elixir
@spec count(
  String.t(),
  keyword()
) :: non_neg_integer()
```

Returns the number of syllables in an English word.

### Arguments

* `word` is an English word as a string. Leading and trailing
  non-letter characters are stripped before counting.

### Options

* `:language` is the language of the word. The default is `:en`.
  Only `:en` is supported; other values raise `ArgumentError`.

### Returns

* A non-negative integer count of syllables. Returns `0` for an
  empty string or a token containing no letters.

### Examples

    iex> Text.Syllable.count("syllable")
    3

    iex> Text.Syllable.count("hello")
    2

    iex> Text.Syllable.count("queue")
    1

    iex> Text.Syllable.count("rhythm")
    1

    iex> Text.Syllable.count("")
    0

# `count_text`

```elixir
@spec count_text(
  String.t(),
  keyword()
) :: non_neg_integer()
```

Returns the total syllable count for a sentence or longer text.

Splits on whitespace and sums the syllable count of each token.

### Arguments

* `text` is a string containing zero or more words.

### Options

* `:language` is the language of the text. The default is `:en`.

### Returns

* A non-negative integer total syllable count across all tokens.

### Examples

    iex> Text.Syllable.count_text("the quick brown fox")
    4

    iex> Text.Syllable.count_text("")
    0

---

*Consult [api-reference.md](api-reference.md) for complete listing*
