tigitz / php-spellchecker Goto Github PK
View Code? Open in Web Editor NEW๐๐๐ PHP Library providing an easy way to spellcheck multiple sources of text by many spellcheckers
License: MIT License
๐๐๐ PHP Library providing an easy way to spellcheck multiple sources of text by many spellcheckers
License: MIT License
It does not work outside of CLI.
In cli hunspell someword and laravel artisan command with Hunspell::create() works fine, but in controller (http layer) it always returns empty array. Why?
Ubuntu 20.04
PHP 8.0.6
Laravel 8.50
###Code sample
use PhpSpellcheck\Spellchecker\Hunspell;
$spell = Hunspell::create();
$misspellings = $spell->check($this->argument('phrase'), ['ru'], ['from_example']);
$arr = [];
foreach ($misspellings as $misspelling) {
$arr[$misspelling->getWord()] = $misspelling->getSuggestions();
}
How to fix that? Thanks!
Upon trying the first example in the docs "Using the spellchecker directly" I get the following error
Process with command "'hunspell' '-a' '-d' 'en_US'" has failed running with exit code 1(General error)
$hunspell = Hunspell::create();
// en_US hunspell dictionary is available
$misspellings = $hunspell->check('mispell', ['en_US'], ['from_example']);
foreach ($misspellings as $misspelling) {
$misspelling->getWord(); // 'mispell'
$misspelling->getLineNumber(); // '1'
$misspelling->getOffset(); // '0'
$misspelling->getSuggestions(); // ['misspell', ...]
$misspelling->getContext(); // ['from_example']
}
Upon checking installed dictionaries from Laravel I get the following error which is strange because from command line it works(see last code block for hunspell -D
Process with command "'hunspell' '-D'" has failed running with exit code 1(General error)
$hunspell = Hunspell::create();
$hunspell->getSupportedLanguages();
I tried first with Aspell and got the same error.
Do you have any pointers as to where the issue might be coming from?
Linux Mint 20
PHP 7.4
Laravel 6.20.16
I found that both Aspell and Hunspell were already installed on Linux mint.
$ aspell -v
@(#) International Ispell Version 3.1.20 (but really Aspell 0.60.8)
$ hunspell -v
@(#) International Ispell Version 3.2.06 (but really Hunspell 1.7.0)
$ hunspell -D
SEARCH PATH:
.::/usr/share/hunspell:/usr/share/myspell:/usr/share/myspell/dicts:/Library/Spelling:/home/USERNAME/.openoffice.org/3/user/wordbook:/home/USERNAME/.openoffice.org2/user/wordbook:/home/USERNAME/.openoffice.org2.0/user/wordbook:/home/USERNAME/Library/Spelling:/opt/openoffice.org/basis3.0/share/dict/ooo:/usr/lib/openoffice.org/basis3.0/share/dict/ooo:/opt/openoffice.org2.4/share/dict/ooo:/usr/lib/openoffice.org2.4/share/dict/ooo:/opt/openoffice.org2.3/share/dict/ooo:/usr/lib/openoffice.org2.3/share/dict/ooo:/opt/openoffice.org2.2/share/dict/ooo:/usr/lib/openoffice.org2.2/share/dict/ooo:/opt/openoffice.org2.1/share/dict/ooo:/usr/lib/openoffice.org2.1/share/dict/ooo:/opt/openoffice.org2.0/share/dict/ooo:/usr/lib/openoffice.org2.0/share/dict/ooo
AVAILABLE DICTIONARIES (path is not mandatory for -d option):
/usr/share/hunspell/en_CA
/usr/share/hunspell/en_ZA
/usr/share/hunspell/es_US
/usr/share/hunspell/es_SV
/usr/share/hunspell/en_AU
/usr/share/hunspell/es_VE
/usr/share/hunspell/es_NI
/usr/share/hunspell/pt_PT
/usr/share/hunspell/pt_BR
/usr/share/hunspell/es_BO
/usr/share/hunspell/es_PA
/usr/share/hunspell/es_PY
/usr/share/hunspell/es_HN
/usr/share/hunspell/en_GB
/usr/share/hunspell/es_CU
/usr/share/hunspell/de_DE
/usr/share/hunspell/de_CH_frami
/usr/share/hunspell/es_CO
/usr/share/hunspell/fr_CH
/usr/share/hunspell/fr
/usr/share/hunspell/de_DE_frami
/usr/share/hunspell/de_AT_frami
/usr/share/hunspell/es_PR
/usr/share/hunspell/es_AR
/usr/share/hunspell/de_AT
/usr/share/hunspell/es_UY
/usr/share/hunspell/en_US
/usr/share/hunspell/fr_FR
/usr/share/hunspell/fr_CA
/usr/share/hunspell/it_CH
/usr/share/hunspell/de_CH
/usr/share/hunspell/ru_RU
/usr/share/hunspell/es_ES
/usr/share/hunspell/es_DO
/usr/share/hunspell/fr_LU
/usr/share/hunspell/es_GT
/usr/share/hunspell/es_CL
/usr/share/hunspell/es_MX
/usr/share/hunspell/fr_BE
/usr/share/hunspell/fr_MC
/usr/share/hunspell/es_CR
/usr/share/hunspell/it_IT
/usr/share/hunspell/es_EC
/usr/share/hunspell/es_PE
/usr/share/myspell/dicts/fr_CH
/usr/share/myspell/dicts/hyph_ru_RU
/usr/share/myspell/dicts/fr_FR
/usr/share/myspell/dicts/fr_CA
/usr/share/myspell/dicts/fr_LU
/usr/share/myspell/dicts/fr_BE
/usr/share/myspell/dicts/fr_MC
I am having issues with Aspell incorrectly reading UTF-8 strings.
You fixed this with this commit
Unfortunately, composer is not pulling this commit into the main package.
Is there any way I can pull this working fix into my project?
Hello, i think that you have an error in hunspell.php line 68, we need to get the error output, but we have an exception, i've modified the code, to:
public function getSupportedLanguages(): iterable
{
$languages = [];
$cmd = $this->binaryPath->addArg('-D');
$process = new Process($cmd->getArgs());
$process->run();
$output = explode(PHP_EOL, $process->getErrorOutput());
The error is when you use the multiple spell checker with hunspell and language tools.
when I create object of aspell its throw an exception
$query = request()->input('term');
$misspellings = $aspell->check($query, ['en_US']);
return response()->json($misspellings);
Hello, i'm having an error when i try to process a text in Portuguese and Deutch.
ErrorException
file_get_contents(http://localhost:8011/v2/check): Failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error
That's my code, and it's working with Spanish, English, etc.
if ( $from == 'pt' ) {
$from = 'pt-PT';
}
if ( $from == 'de' ) {
$from = 'de-DE';
}
// LanguageTools expects language formatted with a dash `en-US`
$misspellings = $spellchecker->check($text, [$from], ['from_example']);
Drupal has a default built-in function t(). As soon as I composer require tigitz/php-spellchecker
, the site stops working because we have two definitions of the function t().
It looks like this is just a shortcut for new Text()
and is used only a few times, and only in examples and tests.
Why is this change important to you? How would you use it?
I would like to use this library in a Drupal project.
How can it benefit other users?
Others could too...
Drop it - its only purpose is to save 7 key strokes. Or namespace it.
This issue provides visibility into Renovate updates and their statuses. Learn more
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
symfony/filesystem
, symfony/finder
, symfony/http-client
)Hi, I just started testing this library for Kurdish language. but when started testing I found out that it's not supporting RTL languages. I did even test "PHP pspell" alone without this library. it was not working too. I know there's no dictionary files for Kurdish language, but I tried using custom dictionaries but it looks like none of them accept abjad characters in the first place. is there's any explanation to that please?
Thanks
There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.
Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.