Download the PHP package tigitz/php-spellchecker without Composer
On this page you can find all versions of the php package tigitz/php-spellchecker. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tigitz/php-spellchecker
More information about tigitz/php-spellchecker
Files in tigitz/php-spellchecker
Package php-spellchecker
Short Description Provides an easy way to spellcheck multiple text source by many spellcheckers, directly from PHP
License MIT
Homepage https://github.com/tigitz/php-spellchecker
Informations about the package php-spellchecker
PHP-Spellchecker
Check misspellings from any text source with the most popular PHP spellchecker.
About
PHP-Spellchecker is a spellchecker abstraction library for PHP. By providing a unified interface for many different spellcheckers, youβre able to swap out spellcheckers without extensive rewrites.
Using PHP-Spellchecker can eliminate vendor lock-in, reduce technical debt, and improve the testability of your code.
Features
- π§ Supports many popular spellcheckers out of the box: Aspell, Hunspell, Ispell, PHP Pspell, LanguageTools, JamSpell and MultiSpellchecker (add yours!)
- π Supports different text sources: file system file/directory, string, and multi-source (add yours!)
- π Supports text processors: MarkdownRemover (add yours!)
- π Supports misspelling handlers: EchoHandler (add yours!)
- β° Makes use of generators to reduce memory footprint
- β Flexible and straightforward design
- π‘ Makes it a breeze to implement your own spellcheckers, text processors and misspellings handlers
- πͺ Runs tests against real spellcheckers to ensure full compatibility
PHP-Spellchecker is a welcoming project for new contributors.
Want to make your first open source contribution? Check the open an issue and we'll help you go through it π€π
Install
Via Composer
Usage
Check out the documentation and examples
Using the spellchecker directly
You can check misspellings directly from a PhpSpellcheck\Spellchecker
class and process them on your own.
Using the MisspellingFinder
orchestrator
You can also use an opinionated MisspellingFinder
class to orchestrate your spellchecking flow:
Following the well-known Unix philosophy:
Write programs that do one thing and do it well. Write programs to work together. Write programs to handle text streams, because that is a universal interface.
Roadmap
The project is still in its initial phase, requiring more real-life usage to stabilize its final 1.0.0 API.
Global
- [ ] Add a CLI that could do something like
vendor/bin/php-spellchecker "misspell" Languagetools EchoHandler --lang=en_US
- [ ] Add asynchronous mechanism to spellcheckers.
- [ ] Make some computed misspelling properties optional to improve performance for certain use cases (e.g., lines and offset in
LanguageTools
). - [ ] Add a language mapper to manage different representations across spellcheckers.
- [ ] Evaluate
strtok
instead ofexplode
to parse lines of text, for performance. - [ ] Evaluate
MutableMisspelling
for performance comparison. - [ ] Wrap
Webmozart/Assert
library exceptions to throw PHP-Spellchecker custom exceptions instead. - [ ] Improve the
Makefile
.
Sources
- [ ] Make a
SourceInterface
class that's able to have an effect on the used spellchecker configuration. - [ ]
League/Flysystem
source. - [ ]
Symfony/Finder
source.
Text processors
- [ ] Markdown - Find a way to keep the original offset and line of words after stripping.
- [ ] Add PHPDoc processor.
- [ ] Add HTML Processor (inspiration).
- [ ] Add XLIFF Processor (inspiration).
Spell checkers
- [ ] Cache suggestions of already spellchecked words (PSR-6/PSR-16?).
- [ ] Pspell - Find way to compute word offset.
- [ ] LanguageTools - Evaluate HTTPlug library to make API requests.
- [x] Pspell - find way to list available dictionaries.
- [x] Add JamSpell spellchecker.
- [ ] Add NuSpell spellchecker.
- [ ] Add SymSpell spellchecker.
- [ ] Add Yandex.Speller API spellchecker.
- [ ] Add Bing Spell Check API spellchecker.
Handlers
- [ ] MonologHandler
- [ ] ChainedHandler
- [ ] HTMLReportHandler
- [ ] XmlReportHandler
- [ ] JSONReportHandler
- [ ] ConsoleTableHandler
Tests
- [ ] Add or improve tests with different text encoding.
- [ ] Refactor duplicate Dockerfile content between PHP images.
Versioning
We follow SemVer v2.0.0.
There still are many design decisions that should be confronted with real-world usage before thinking about a v1.0.0 stable release:
- Are
TextInterface
andMisspellingInterface
really useful? - Is using generators the right way to go?
- Should all the contributed spellcheckers be maintained by the package itself?
- How to design an intuitive CLI given the needed flexibility of usage?
- Is the "context" array passed through all the layers the right design to handle data sharing?
Testing
Spell checkers come in many different forms, from HTTP API to command line tools. PHP-Spellchecker wants to ensure real-world usage is OK, so it contains integration tests. To run these, spellcheckers need to all be available during tests execution.
The most convenient way to do it is by using Docker and avoid polluting your local machine.
Docker
Requires docker
and docker-compose
to be installed (tested on Linux).
You can also specify PHP version, dependency version target and if you want coverage.
Run make help
to list all available tasks.
Environment variables
If spellcheckers execution paths are different than their default values (e.g., docker exec -ti myispell
instead of ispell
) you can override the path used in tests by redefining environment variables in the PHPUnit config file.
Contributing
Please see CONTRIBUTING.
Credits
- Inspired by php-speller, monolog and flysystem
- Philippe Segatori
- All Contributors
License
The MIT License (MIT). Please see license file for more information.
Logo: Elements taken for the final rendering are Designed by rawpixel.com / Freepik.
All versions of php-spellchecker with dependencies
nyholm/psr7 Version ^1.3
psr/http-client Version ^1.0
symfony/process Version ^4.4.30 | ^5.0 |^6.0 | ^7.0
thecodingmachine/safe Version ^1.0 | ^2.0
webmozart/assert Version ^1.11