PHPackages                             vanderlee/php-sentence - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. vanderlee/php-sentence

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

vanderlee/php-sentence
======================

Simple text sentence splitting and counting. Supports at least english, german and dutch, possibly more.

1.0.8(2y ago)85595.6k↓13.7%23[8 issues](https://github.com/vanderlee/php-sentence/issues)6MITPHPPHP &gt;=5.4.0

Since Feb 11Pushed 2y ago6 watchersCompare

[ Source](https://github.com/vanderlee/php-sentence)[ Packagist](https://packagist.org/packages/vanderlee/php-sentence)[ Docs](https://github.com/vanderlee/php-sentence.git)[ RSS](/packages/vanderlee-php-sentence/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (1)Versions (10)Used By (6)

Sentence
========

[](#sentence)

![License](https://camo.githubusercontent.com/f81881d253df2503a982c6b5a0de1450f3c436ea6bbedb60556a6a9981b6a5a7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f76616e6465726c65652f7068702d73656e74656e63652e737667)[![Build Status](https://camo.githubusercontent.com/d608a2a763802ff9f743acbabd84cbfa3d88da45c96d07e0d027519c4c4d2361/68747470733a2f2f7472617669732d63692e6f72672f76616e6465726c65652f7068702d73656e74656e63652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/vanderlee/php-sentence)[![Quality](https://camo.githubusercontent.com/6416d5f972ce6e00131c05378bcb1b8e0f6c01bb34da02f86d8cce870301459b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f76616e6465726c65652f7068702d73656e74656e63652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/vanderlee/php-sentence)

Version 1.0.8

Copyright © 2016-2024 Martijn van der Lee (@vanderlee), parts copyright © 2017 @marktaw.

MIT Open Source license applies.

Introduction
------------

[](#introduction)

PHP natural language sentence segmentation (splitting) and counting. Sentence boundary disambiguation.

Still early, but should support most western languages. If you find any problems, please let me know.

Supports PHP 5.3 and up, so you can use it on older servers.

Installation
------------

[](#installation)

Requires PHP 5.4 or greater. PHP 5.3 is supported as long as no more recent features are absolutely necessary.

To install using Composer:

```
composer require vanderlee/php-sentence

```

Methods
-------

[](#methods)

### ***`integer`*** `count(`***`string`*** `$text)`

[](#integer-countstring-text)

Counts the number of sentences in the text. Provided for convenience; this is exactly the same as counting the number of returned array items from `split`, so if you need both results, just do that.

### ***`array`*** `split(`***`string`*** `$text, `***`integer`*** `$flags = 0)`

[](#array-splitstring-text-integer-flags--0)

Splits the text into sentences.

`$flags` is zero (`0`, default) or the following class constant:

- **`Sentence::SPLIT_TRIM`**: Trim whitespace off the left and right sides of each returned sentence.

Documentation
-------------

[](#documentation)

You can find documentation generated from the source code by ApiGen here: [ApiGen documentation](doc/)

Examples
========

[](#examples)

```
