{"id":16884292,"url":"https://github.com/mekras/php-speller","last_synced_at":"2025-04-05T20:07:48.802Z","repository":{"id":31695122,"uuid":"35260775","full_name":"mekras/php-speller","owner":"mekras","description":"PHP spell check library","archived":false,"fork":false,"pushed_at":"2024-07-20T20:00:13.000Z","size":188,"stargazers_count":68,"open_issues_count":6,"forks_count":22,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-14T16:17:01.625Z","etag":null,"topics":["aspell","hunspell","ispell","php","spelling"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mekras.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-05-08T05:47:00.000Z","updated_at":"2024-10-05T15:25:08.000Z","dependencies_parsed_at":"2024-10-25T18:42:43.392Z","dependency_job_id":null,"html_url":"https://github.com/mekras/php-speller","commit_stats":{"total_commits":114,"total_committers":14,"mean_commits":8.142857142857142,"dds":"0.29824561403508776","last_synced_commit":"06c0a26f3203310b699386e5a03737c6c612482d"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mekras%2Fphp-speller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mekras%2Fphp-speller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mekras%2Fphp-speller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mekras%2Fphp-speller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mekras","download_url":"https://codeload.github.com/mekras/php-speller/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247393570,"owners_count":20931812,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aspell","hunspell","ispell","php","spelling"],"created_at":"2024-10-13T16:17:10.170Z","updated_at":"2025-04-05T20:07:48.777Z","avatar_url":"https://github.com/mekras.png","language":"PHP","readme":"# php-speller\n\nPHP spell check library.\n\n[![Latest Stable Version](https://poser.pugx.org/mekras/php-speller/v/stable.png)](https://packagist.org/packages/mekras/php-speller)\n[![License](https://poser.pugx.org/mekras/php-speller/license.png)](https://packagist.org/packages/mekras/php-speller)\n[![Build Pipeline](https://github.com/mekras/php-speller/actions/workflows/build.yml/badge.svg)](https://github.com/mekras/php-speller/actions/workflows/build.yml)\n\nCurrently supported backends:\n\n* [aspell](http://aspell.net/);\n* [hunspell](http://hunspell.sourceforge.net/);\n* [ispell](https://www.cs.hmc.edu/~geoff/ispell.html).\n\n## Installation\n\nWith [Composer](http://getcomposer.org/):\n\n    $ composer require mekras/php-speller\n\n## Usage\n\n1. Create a text source object from string, file or something else using one of the\n   `Mekras\\Speller\\Source\\Source` implementations (see [Sources](#Sources) below).\n2. Create some speller instance (Hunspell, Ispell or any other implementation of the\n   `Mekras\\Speller\\Speller`).\n3. Execute `Speller::checkText()` method.\n\n```php\nuse Mekras\\Speller\\Hunspell\\Hunspell;\nuse Mekras\\Speller\\Source\\StringSource;\n\n$source = new StringSource('Tiger, tigr, burning bright');\n$speller = new Hunspell();\n$issues = $speller-\u003echeckText($source, ['en_GB', 'en']);\n\necho $issues[0]-\u003eword; // -\u003e \"tigr\"\necho $issues[0]-\u003eline; // -\u003e 1\necho $issues[0]-\u003eoffset; // -\u003e 7\necho implode(',', $issues[0]-\u003esuggestions); // -\u003e tiger, trig, tier, tigris, tigress\n```\n\nYou can list languages supported by backend:\n\n```php\n/** @var Mekras\\Speller\\Speller $speller */\nprint_r($speller-\u003egetSupportedLanguages());\n```\n\nSee [examples](examples/) for more info. \n\n### Source encoding\n\nFor aspell, hunspell and ispell source text encoding should be equal to dictionary encoding. You can\nuse [IconvSource](#IconvSource) to convert source.\n\n## Aspell\n\nThis backend uses aspell program, so it should be installed in the system.\n\n```php\nuse Mekras\\Speller\\Aspell\\Aspell;\n\n$speller = new Aspell();\n```\n\nPath to binary can be set in constructor:\n\n```php\nuse Mekras\\Speller\\Aspell\\Aspell;\n\n$speller = new Aspell('/usr/local/bin/aspell');\n```\n\n### Custom Dictionary\n\nYou can use a custom dictionary for aspell. The dictionary needs to be in the following format:\n\n```\npersonal_ws-1.1 [lang] [words]\n```\n\nWhere `[lang]` shout be the shorthand for the language you are using (e.g. `en`) and `[words]` is the count\nof words inside the dictionary. **Beware** that there should no spaces at the end of words. Each word should be listed\nin a new line.\n\n```php\n$aspell = new Aspell();\n$aspell-\u003esetPersonalDictionary(new Dictionary('/path/to/custom.pws'));\n```\n\n### Important\n\n- aspell allow to specify only one language at once, so only first item taken from\n$languages argument in ``Ispell::checkText()``.\n\n\n## Hunspell\n\nThis backend uses hunspell program, so it should be installed in the system.\n\n```php\nuse Mekras\\Speller\\Hunspell\\Hunspell;\n\n$speller = new Hunspell();\n```\n\nPath to binary can be set in constructor:\n\n```php\nuse Mekras\\Speller\\Hunspell\\Hunspell;\n\n$speller = new Hunspell('/usr/local/bin/hunspell');\n```\n\nYou can set additional dictionary path:\n\n```php\nuse Mekras\\Speller\\Hunspell\\Hunspell;\n\n$speller = new Hunspell();\n$speller-\u003esetDictionaryPath('/var/spelling/custom');\n```\n\nYou can specify custom dictionaries to use:\n\n```php\nuse Mekras\\Speller\\Hunspell\\Hunspell;\n\n$speller = new Hunspell();\n$speller-\u003esetDictionaryPath('/my_app/spelling');\n$speller-\u003esetCustomDictionaries(['tech', 'titles']);\n```\n\n## Ispell\n\nThis backend uses ispell program, so it should be installed in the system.\n\n```php\nuse Mekras\\Speller\\Ispell\\Ispell;\n\n$speller = new Ispell();\n```\n\nPath to binary can be set in constructor:\n\n```php\nuse Mekras\\Speller\\Ispell\\Ispell;\n\n$speller = new Ispell('/usr/local/bin/ispell');\n```\n\n### Important\n\n- ispell allow to use only one dictionary at once, so only first item taken from\n$languages argument in ``Ispell::checkText()``.\n\n\n## Sources\n\nSources — is an abstraction layer allowing spellers receive text from different sources like strings\nor files.\n\n### FileSource\n\nReads text from file.\n\n```php\nuse Mekras\\Speller\\Source\\FileSource;\n\n$source = new FileSource('/path/to/file.txt');\n```\n\nYou can specify file encoding:\n\n```php\nuse Mekras\\Speller\\Source\\FileSource;\n\n$source = new FileSource('/path/to/file.txt', 'windows-1251');\n```\n\n### StringSource\n\nUse string as text source.\n\n```php\nuse Mekras\\Speller\\Source\\StringSource;\n\n$source = new StringSource('foo', 'koi8-r');\n```\n\n## Meta sources \n\nAdditionally there is a set of meta sources, which wraps other sources to perform extra tasks.\n\n### HtmlSource\n\nReturn user visible text from HTML.\n\n```php\nuse Mekras\\Speller\\Source\\HtmlSource;\n\n$source = new HtmlSource(\n    new StringSource('\u003ca href=\"#\" title=\"Foo\"\u003eBar\u003c/a\u003e Baz')\n);\necho $source-\u003egetAsString(); // Foo Bar Baz\n```\n\nEncoding detected via\n[DOMDocument::$encoding](http://php.net/manual/en/class.domdocument.php#domdocument.props.encoding).\n\n### IconvSource\n\nThis is a meta-source which converts encoding of other given source:\n\n```php\nuse Mekras\\Speller\\Source\\IconvSource;\nuse Mekras\\Speller\\Source\\StringSource;\n\n// Convert file contents from windows-1251 to koi8-r.\n$source = new IconvSource(\n    new FileSource('/path/to/file.txt', 'windows-1251'),\n    'koi8-r'\n);\n```\n\n### XliffSource\n  \nLoads text from [XLIFF](http://docs.oasis-open.org/xliff/xliff-core/v2.0/xliff-core-v2.0.html)\nfiles.\n\n```php\nuse Mekras\\Speller\\Source\\XliffSource;\n\n$source = new XliffSource(__DIR__ . '/fixtures/test.xliff');\n```\n\n## Source filters\n\nFilters used internally to filter out all non text contents received from source. In order to save\noriginal word location (line and column numbers) all filters replaces non text content with spaces.\n\nAvailable filters:\n\n* [StripAllFilter](src/Source/Filter/StripAllFilter.php) — strips all input text;\n* [HtmlFilter](src/Source/Filter/HtmlFilter.php) — strips HTML tags.\n","funding_links":[],"categories":["Programming Languages"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmekras%2Fphp-speller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmekras%2Fphp-speller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmekras%2Fphp-speller/lists"}