Lingua...phenate(3pm)

πŸ“¦
version 0.06 Β· 2 versions
  • 0.06 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.06 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Lingua::EN::Hyphenate β€” the perl manual page, but make it cute πŸ’–

okay bestie so this is the page for Lingua::EN::Hyphenate, part of the User Contributed Perl Documentation set, and it's giving "tiny module, big haiku energy". come sit with me, we're breaking words apart at the syllables. πŸŽ€


✨ NAME ✨

Lingua::EN::Hyphenate β€” a Perl extension for syllable-based hyphenation πŸ¦‹


🌸 SYNOPSIS 🌸

  use Lingua::EN::Hyphenate qw( hyphenate syllables def_syl def_hyph );

  my $word = 'intromission';

  my $syllables = syllables($word);     # 'in~tro~mis~sion'
  my @syllables = syllables($word);     # ('in','tro','mis','sion')

  ($end_of_line_1, $start_of_line_2)    # ('intro-','mission')
        = hyphenate($word, 6);          # Break word at or before 6th char

  ($end_of_line_1, $start_of_line_2)    # ('intromis-','sion')
        = hyphenate($word, 8);          # Break word at or before 8th char

  my $hyphen = '...';
  ($end_of_line_1, $start_of_line_2)    # ('intro...','mission')
        = hyphenate($word, 8, $hyphen); # Use specified hyphen (not '-')

  def_syl('here~say');                  # Where the syllables are
  def_syl('he~re~sy');                  # Where the syllables are

  def_hyph('here~say');                 # Where the word may be broken
  def_hyph('her~esy');                  # Where the word may be broken

πŸ‘‘ DESCRIPTION πŸ‘‘

the exportable subroutines of Lingua::EN::Hyphenate are a whole little toolkit, fr fr. they let you:

  • chop words up into syllables 🧚
  • hyphenate words right at the syllable boundaries πŸ’…
  • and redefine the syllables or the hyphenation for specific words when the algorithm is doing too much πŸ’€

πŸ’œ syllables

this one takes a single string argument and goes to town breaking it into syllables.

  • in scalar context: hands you back a string with the syllables separated by '~' characters ✨
  • in list context: hands you back a list of the syllables 🌈

that's it, that's the whole vibe. no cap.


πŸ¦‹ hyphenate

this subroutine takes:

  1. a word to be broken πŸ“
  2. an integer saying the maximum number of characters allowed before the break πŸ”’
  3. (optional) a third argument specifying the hyphenation marker β€” and yeah, '-' is the default πŸŽ€

it returns a list of two elements:

  • the characters before the break, including the hyphenation marker πŸ’–
  • the rest of the word 🌸
and bestie, hear me: the first element is guaranteed to be no longer than the length you gave as the second argument. the module is not out here lying to you about that. periodt.

⭐ def_syl and def_hyph

these two let you specify a specific syllabic decomposition or hyphenation pattern (respectively, iykyk) to be used for the specified word. 🫢

the syllables or hyphenation fragments are separated by '~' characters β€” check the examples up in the synopsis, they ate. πŸ’…


🌈 AUTHOR 🌈

Damian Conway (damian@conway.org) β€” an actual icon, we stan πŸ‘‘


πŸ’€ BUGS AND IRRITATIONS πŸ’€

okay so the tea. β˜•

the syllable extraction is algorithmic, not table-driven. which means the module is very short πŸŽ€ but ALSO means it can be very inaccurate. it's okay for haiku, but it should not be used for serious work. if you need real accuracy, go look at Lingua::EN::Syllable or TeX::Hyphen instead. πŸ™ˆ

there are undoubtedly serious bugs lurking somewhere in this code β€” if only because it gives the impression of understanding a great deal more about English than it actually does. 😭 (it's giving overconfident. it's giving fake-it-till-you-make-it.)

bug reports and other feedback are most welcome though!! send them in bestie 🫢


 Copyright (c) 1997-2000, Damian Conway. All Rights Reserved.
 This module is free software. It may be used, redistributed
and/or modified under the terms of the Perl Artistic License
     (see http://www.perl.com/perl/misc/Artistic.html)

and that's the whole page, bestie!! πŸ’– this one came to you as perl v5.36.0, dated 2022-11-19, and it lives in the perl docs as Lingua...phenate(3pm) β€” go forth and hyphenate responsibly, mwah πŸ’…βœ¨