Lingua::Sentence(3pm)
π Lingua::Sentence β the Perl era of sentence splitting π
okay bestie, gather round, because this is the Lingua::Sentence manual page (yes, the 3pm one, user-contributed Perl documentation, we love her) and she is so much more chill than she looks. π
β¨ NAME β¨
Lingua::Sentence β a Perl extension for breaking text paragraphs into sentences. periodt. π
πΈ SYNOPSIS πΈ
use Lingua::Sentence;
my $splitter = Lingua::Sentence->new("en");
my $text = 'This is a paragraph. It contains several sentences. "But why," you ask?';
print $splitter->split($text);
likeβ¦ that's it. that's the whole vibe. three lines and a dream. π¦
π«Ά DESCRIPTION π«Ά
So this module lets you split text paragraphs into sentences. It's built on scripts that Philipp Koehn and Josh Schroeder made for processing the Europarl corpus (<http://www.statmt.org/europarl/>), so it's giving academically sourced, not just vibes. π
It uses punctuation and capitalization clues to chop paragraphs into a newline-separated string with one sentence per line. For example, this:
This is a paragraph. It contains several sentences. "But why," you ask?
goes to:
This is a paragraph.
It contains several sentences.
"But why," you ask?
literally chef's kiss. no cap. β¨
Languages currently supported by the module are:
- Catalan
- Czech
- Dutch
- English
- French
- German
- Greek
- Hungarian
- Icelandic
- Italian
- Latvian
- Polish
- Portuguese
- Russian
- Spanish
- Slovak
- Slovenian
- Swedish
π Nonbreaking Prefixes Files π
ok so, nonbreaking prefixes are loosely defined as any word ending in a period that does NOT indicate an end of sentence marker. the basic English example is Mr. and Ms. β like, Mr. is not the end of anything, bestie, it's just a guy. π
The sentence splitter module uses the nonbreaking prefix files included in this distribution.
Wanna add a file for other languages? Follow the naming convention nonbreaking_prefix.?? and use the two-letter language code you intend to use when creating a Lingua::Sentence object. π
The sentence splitter module will first look for a file for the language it is processing, and fall back to English if a file for that language is not found.
For the splitter, normally a period followed by an uppercase word results in a sentence split. But if the word preceeding the period is a nonbreaking prefix, this line break is not inserted. π
A special case of prefixes, NUMERIC_ONLY, is included for special cases where the prefix should be handled ONLY when before numbers. For example, in "Article No. 24 states this." the No. is a nonbreaking prefix. However, in "No. It is not true." No functions as a word. the duality. the range. π
See the example prefix files included in the distribution for more examples.
π CREDITS π
Thanks for the following individuals for supplying nonbreaking prefix files: Bas Rozema (Dutch), HilΓ‘rio Leal Fontes (Portuguese), JesΓΊs GimΓ©nez (Catalan & Spanish), Anne-Kathrin Schumann (Russian). icons, all of them. π
π EXPORT π
new($lang_id)β Instantiate an object to split sentences in language$lang_id. If the language is not supported, a splitter object for English will be instantiated. (English really said "I got you, babe." π)new($lang_id,$nonbreaking_prefix_file)β Instantiate an object to split sentences in language$lang_idand the nonbreaking prefix file$nonbreaking_prefix_file. If the file does not exist, a splitter object for English will be instantiated. same energy, different file. π«Άsplit($text)β Split sentences in$textby inserting newline characters at the sentence breaks. The resulting string is also terminated with a newline. (yes, it ends with a newline, it's polite like that. β¨)split_array($text)β Split sentences in$textinto an array of sentences. π
π SUPPORT π
Bugs should always be submitted via the project hosting bug tracker
<http://code.google.com/p/corpus-tools/issues/list>
For other issues, contact the maintainer. don't be shy, bestie, they want to hear from you. π
π₯ SEE ALSO π₯
Text::Sentence, Lingua::EN::Sentence, Lingua::DE::Sentence, Lingua::HE::Sentence β the whole friend group, go say hi. π
π AUTHOR π
Achim Ruopp, <achimru@gmail.com>
π COPYRIGHT AND LICENSE π
Copyright (C) 2010 by Digital Silk Road
Portions Copyright (C) 2005 by Philip Koehn and Josh Schroeder (used with permission)
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
fr fr, read the license. it's giving legally binding, not giving optional. π
and that's the whole page, bestie β perl v5.36.0, dated 2022-12-08, and yes it's still out here being Lingua::Sentence(3pm). slay. π
β¨π
π¦ where this page comes from
- debian bookworm: liblingua-sentence-perl 1.100-3 Β· LGPL-3.0-or-later
- debian trixie: liblingua-sentence-perl 1.100-3 Β· LGPL-3.0-or-later
- ubuntu noble: liblingua-sentence-perl 1.100-3 Β· LGPL-3.0-or-later
- ubuntu resolute: liblingua-sentence-perl 1.100-3 Β· LGPL-3.0-or-later
- ubuntu stonking: liblingua-sentence-perl 1.100-3 Β· LGPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms