PHPackages                             ssola/monachus - 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. ssola/monachus

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

ssola/monachus
==============

Library to handle texts, includes: Spell checker, Stemer, Language detection

1.0.0(12y ago)435PHPPHP &gt;=5.3.0

Since Jan 16Pushed 11y ago1 watchersCompare

[ Source](https://github.com/ssola/monachus)[ Packagist](https://packagist.org/packages/ssola/monachus)[ RSS](/packages/ssola-monachus/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Monachus [![Build Status](https://camo.githubusercontent.com/6e0e08754e09228e86fc83f8e02be5ef694a38ed5a617ae856b3c3909297a6af/68747470733a2f2f7472617669732d63692e6f72672f73736f6c612f6d6f6e61636875732e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/ssola/monachus)
==================================================================================================================================================================================================================================================================================

[](#monachus-)

Monachus is a library that helps you working with text, in any language. Monachus means Monk in Latin language, I think it's a good name to define this library. Monks were used to work a lot with books (strings) in a wide range of languages.

This library has been created keeping in mind these PHP versions: 5.5, 5.4, 5.3

Install
-------

[](#install)

The simplest way is with Composer, just add these lines to your composer.json:

```
"repositories": [
    {
    "type": "git",
    "url": "https://github.com/ssola/monachus.git"
    }
]

```

How it works
------------

[](#how-it-works)

**String**

---

The first thing we need to know is how to use the String class. This class generates an object with a specific text. It will preserve that text in UTF-8 charset along the way.

```
include_once("./vendor/autoload.php");

use Monachus\String as String;

$text = new String("Hello World!");
echo $text;
```

Obviously this code is generating a new String object with a value and then it's printed.

Then you can do things like:

```
include_once("./vendor/autoload.php");

use Monachus\String as String;

$text = new String("Hello World!");
echo $text->length();
echo $text->find("World");
echo $text->toUppercase();

if($text->equals("Hello World!"))
  echo $text->toLowercase();
```

This kind of objects is used extensively in this library in order to perform all the actions with the proper charset.

**Tokenizer**

---

Do you need to tokenize a string? Monachus can do it for you! We support a lot of languages, Japanese included! But if your language is not supported... relax! You can create your own adapters in order to tokenize different languages.

Let's do a simple example:

```
include_once("./vendor/autoload.php");

use Monachus\String as String;
use Monachus\Tokenizer as Tokenizer;

$text = new String("This is a text");
$tokenizer = new Tokenizer();

var_dump($tokenizer->tokenize($text));

// Now imagine you need to tokenize a Japanase text
$textJp = new String("は太平洋側を中心に晴れた所が多いが");
$tokenizerJp = new Tokenizer(new Monachus\Tokenizers\Japanase());

var_dump($tokenizerJp);
```

As you have seen, we can use our own adapters to tokenize complex languages like Japanase or Chinese. Now it's time to explain you how to create these adapters.

```
class MyTokenizer implements Monachus\Interfaces\TokenizerInterface
{
  public function tokenize(Monachus\String $string)
  {
    // your awesome code!
  }
}

$tokenizer = new Monachus\Tokenizer(new MyTokenizer());
var_dump($tokenizer->tokenize(new Monachus\String("Поиск информации в интернете"));
```

**N-Gram**

---

Yeah! Monachus is able to generate different levels of N-gram sequences, for example a bigram or trigram. But let's see how it works.

```
include_once("./vendor/autoload.php");

use Monachus\String as String;
use Monachus\Ngram as Ngram;
use Monachus\Config as Config;

$text = new String("This is an awesome text");

$config = new Config();
$config->max = 3; // we're creating trigrams.

$ngram = new Ngram($config);
var_dump($ngram->parse($text));
```

Do you need your own N-gram parser? No problem! You can create your own parsers as well.

```
class MyParser implements Monachus\Interfaces\NgramParserInterface
{
  public function parse(String $string, $level)
  {
    // your awesome code!
  }
}
```

And then...

```
include_once("./vendor/autoload.php");

use Monachus\String as String;
use Monachus\Ngram as Ngram;
use Monachus\Config as Config;

$text = new String("This is an awesome text");

$config = new Config();
$config->max = 3; // we're creating trigrams.

$ngram = new Ngram($config);
$ngram->setParser(new MyParser());
var_dump($ngram->parse($text));
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

4501d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0489f67bef65773d8ec49277f1f0a82efffaab33adf47b0b9ba753cc72633d44?d=identicon)[ssola](/maintainers/ssola)

---

Top Contributors

[![ssola](https://avatars.githubusercontent.com/u/1267434?v=4)](https://github.com/ssola "ssola (7 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ssola-monachus/health.svg)

```
[![Health](https://phpackages.com/badges/ssola-monachus/health.svg)](https://phpackages.com/packages/ssola-monachus)
```

###  Alternatives

[vivait/string-generator-bundle

Generate random strings for IDs or keys using property annotations

1759.4k](/packages/vivait-string-generator-bundle)[withinboredom/time

Converting time to units

152.7k1](/packages/withinboredom-time)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
