{
    "mode": "perldoc",
    "parameter": "Lingua::EN::Sentence",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Lingua%3A%3AEN%3A%3ASentence/json",
    "generated": "2026-10-05T07:46:31Z",
    "synopsis": "use Lingua::EN::Sentence qw( getsentences addacronyms );",
    "sections": {
        "NAME": {
            "content": "Lingua::EN::Sentence - split text into sentences\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Lingua::EN::Sentence qw( getsentences addacronyms );\n",
            "subsections": [
                {
                    "name": "add_acronyms",
                    "content": "with a dot, exclamation or question mark optionally followed by a space! A string followed by 2\ncarriage returns denotes a sentence, even though it doesn't end in a dot\n\nDots after single letters such as U.S.A. or in numbers like -12.34 will not cause a split as\nwell as common abbreviations such as Dr. I. Smith, Ms. A.B. Jones, Apr. Calif. Esq. and (some\ntext) ellipsis such as ... or . . are ignored. Some valid cases canot be deteected, such as the\nanswer is X. It cannot easily be differentiated from the single letter-dot sequence to\nabbreviate a person's given name. Numbered points within a sentence will not cause a split 1.\nLike this one. See the code for all the rules that apply. This string has 7 sentences. };\n\nif (defined($sentences)) { my $sentences = getsentences($text); foreach my $sent (@$sentences)\n{ $i++; print(\"SENTENCE $i:$sent\\n\"); } }\n"
                }
            ]
        },
        "DESCRIPTION": {
            "content": "The \"Lingua::EN::Sentence\" module contains the function getsentences, which splits text into\nits constituent sentences, based on a regular expression and a list of abbreviations (built in\nand given).\n\nCertain well know exceptions, such as abbreviations, may cause incorrect segmentations. But some\nof them are already integrated into this code and are being taken care of. Still, if you see\nthat there are words causing the getsentences function to fail, you can add those to the\nmodule, so it notices them. Note that abbreviations are case sensitive, so 'Mrs.' is recognised\nbut not 'mrs.'\n",
            "subsections": []
        },
        "ALGORITHM": {
            "content": "The first step is to mark the dot ending an abbreviation by changing it to a special character.\nNow it won't cause a sentence split. The original dot is restored after the sentences are split\n\nBasically, I use a 'brute' regular expression to split the text into sentences. (Well, nothing\nis yet split - I just mark the end-of-sentence). Then I look into a set of rules which decide\nwhen an end-of-sentence is justified and when it's a mistake. In case of a mistake, the\nend-of-sentence mark is removed. What are such mistakes?\n\nLetter-dot sequences: U.S.A. , i.e. , e.g. Dot sequences: '..' or '...' or 'text . . more text'\nTwo carriage returns denote the end of a sentence even if it doesn't end with a dot\n",
            "subsections": []
        },
        "LIMITATIONS": {
            "content": "1) John F. Kennedy was a former president 2) The answer is F. That ends the quiz\n\nIn the first sentence, F. is detected as a persons initial and not the end of a sentence. But\nthis means we cannot detect the true end of sentence 2, which is after the 'F'. This case is not\ncommon though.\n",
            "subsections": []
        },
        "FUNCTIONS": {
            "content": "All functions used should be requested in the 'use' clause. None is exported by default.\n",
            "subsections": [
                {
                    "name": "get_sentences",
                    "content": "The getsentences function takes a scalar containing ascii text as an argument and returns a\nreference to an array of sentences that the text has been split into. Returned sentences\nwill be trimmed (beginning and end of sentence) of white space. Strings with no\nalpha-numeric characters in them, won't be returned as sentences. If no text is supplied, a\nreference to an empty array is returned.\n"
                },
                {
                    "name": "add_acronyms",
                    "content": "This function is used for adding acronyms not supported by this code. The input should be\nregular expressions for matching the desired acronyms, but should not include the final\nperiod (\".\"). So, for example, \"blv?d\" matches \"blvd.\" and \"bld.\". \"a\\.mlf\" will match\n\"a.mlf.\". You do not need to bother with acronyms consisting of single letters and dots\n(e.g. \"U.S.A.\"), as these are found automatically. Note also that acronyms are searched for\non a case insensitive basis.\n\nPlease see 'Acronym/Abbreviations list' section for the abbreviations already supported by\nthis module.\n"
                },
                {
                    "name": "get_acronyms",
                    "content": "This function will return the defined list of acronyms.\n"
                },
                {
                    "name": "set_acronyms",
                    "content": "This function replaces the predefined acronym list with the given list. See \"addacronyms\"\nfor details on the input specifications.\n"
                },
                {
                    "name": "get_EOS",
                    "content": "This function returns the value of the string used to mark the end of sentence. You might\nwant to see what it is, and to make sure your text doesn't contain it. You can use setEOS()\nto alter the end-of-sentence string to whatever you desire.\n"
                },
                {
                    "name": "set_EOS",
                    "content": "This function alters the end-of-sentence string used to mark the end of sentences.\n"
                },
                {
                    "name": "set_locale",
                    "content": "for example: \"frCA.ISO8859-1\" for Canadian French using character set ISO8859-1.\nReturns a reference to a hash containing the current locale formatting values. Returns undef\nif got undef.\n\nThe following will set the LCCOLLATE behaviour to Argentinian Spanish. NOTE: The naming and\navailability of locales depends on your operating sysem. Please consult the perllocale\nmanpage for how to find out which locales are available in your system.\n\n$loc = setlocale( \"esAR.ISO8859-1\" );\n\nThis actually does this:\n\n$loc = setlocale( LCALL, \"esAR.ISO8859-1\" );\n"
                }
            ]
        },
        "Acronym/Abbreviations list": {
            "content": "You can use the getacronyms() function to get acronyms. It has become too long to specify in\nthe documentation.\n\nIf I come across a good general-purpose list - I'll incorporate it into this module. Feel free\nto suggest such lists.\n",
            "subsections": []
        },
        "FUTURE WORK": {
            "content": "[1] Object Oriented like usage\n[2] Supporting more than just English/French\n[3] Code optimization. Currently everything is RE based and not so optimized RE\n[4] Possibly use more semantic heuristics for detecting a beginning of a sentence\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "Text::Sentence\nLingua::Sentence\nRaku port of Lingua::EN::Sentence\n",
            "subsections": []
        },
        "REPOSITORY": {
            "content": "<https://github.com/kimryan/Lingua-EN-Sentence>\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Shlomo Yona shlomo@cs.haifa.ac.il\n\nCurrently being maintained by Kim Ryan, kimryan at CPAN d o t org\n",
            "subsections": []
        },
        "COPYRIGHT AND LICENSE": {
            "content": "Copyright (c) 2001-2016 Shlomo Yona. All rights reserved. Copyright (c) 2022 Kim Ryan. All\nrights reserved.\n\nThis library is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself.\n",
            "subsections": []
        }
    },
    "summary": "Lingua::EN::Sentence - split text into sentences",
    "flags": [],
    "examples": [],
    "see_also": []
}