Download the PHP package mekras/php-speller without Composer
On this page you can find all versions of the php package mekras/php-speller. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package php-speller
php-speller
PHP spell check library.
Currently supported backends:
Installation
With Composer:
$ composer require mekras/php-speller
Usage
- Create a text source object from string, file or something else using one of the
Mekras\Speller\Source\Source
implementations (see Sources below). - Create some speller instance (Hunspell, Ispell or any other implementation of the
Mekras\Speller\Speller
). - Execute
Speller::checkText()
method.
You can list languages supported by backend:
See examples for more info.
Source encoding
For aspell, hunspell and ispell source text encoding should be equal to dictionary encoding. You can use IconvSource to convert source.
Aspell
This backend uses aspell program, so it should be installed in the system.
Path to binary can be set in constructor:
Custom Dictionary
You can use a custom dictionary for aspell. The dictionary needs to be in the following format:
Where [lang]
shout be the shorthand for the language you are using (e.g. en
) and [words]
is the count
of words inside the dictionary. Beware that there should no spaces at the end of words. Each word should be listed
in a new line.
Important
- aspell allow to specify only one language at once, so only first item taken from
$languages argument in
Ispell::checkText()
.
Hunspell
This backend uses hunspell program, so it should be installed in the system.
Path to binary can be set in constructor:
You can set additional dictionary path:
You can specify custom dictionaries to use:
Ispell
This backend uses ispell program, so it should be installed in the system.
Path to binary can be set in constructor:
Important
- ispell allow to use only one dictionary at once, so only first item taken from
$languages argument in
Ispell::checkText()
.
Sources
Sources — is an abstraction layer allowing spellers receive text from different sources like strings or files.
FileSource
Reads text from file.
You can specify file encoding:
StringSource
Use string as text source.
Meta sources
Additionally there is a set of meta sources, which wraps other sources to perform extra tasks.
HtmlSource
Return user visible text from HTML.
Encoding detected via DOMDocument::$encoding.
IconvSource
This is a meta-source which converts encoding of other given source:
XliffSource
Loads text from XLIFF files.
Source filters
Filters used internally to filter out all non text contents received from source. In order to save original word location (line and column numbers) all filters replaces non text content with spaces.
Available filters:
- StripAllFilter — strips all input text;
- HtmlFilter — strips HTML tags.
All versions of php-speller with dependencies
ext-dom Version *
ext-iconv Version *
ext-libxml Version *
phpspec/prophecy-phpunit Version ^2.0
symfony/process Version ^5.4.22 || ^6.0