Giter VIP home page Giter VIP logo

Comments (2)

tigitz avatar tigitz commented on September 14, 2024

Hello @Xoshbin

Thanks for giving a try to the library.

As the library is a wrapper around existing spellchecking engines, if the one you use supports RTL languages and Kurdish language then it should be fine.

As long as the Abjad characters are utf8 encoded the library doesn't get in your way.

If the 2 points above are not true, then it's a bug.

I'll investigate and come back to you.

from php-spellchecker.

tigitz avatar tigitz commented on September 14, 2024

I've tried persian with LanguageTools:

Start the spellchecking engine using docker:

docker run -d --rm -p 8010:8010 silviof/docker-languagetool 

languagetools_persian_example.php

<?php

use PhpSpellcheck\Spellchecker\LanguageTool;
use PhpSpellcheck\Spellchecker\LanguageTool\LanguageToolApiClient;

require_once __DIR__ . '/../vendor/autoload.php';

// *** Using spellcheckers directly ***
$spellchecker = new LanguageTool(
    new LanguageToolApiClient('http://localhost:8010')
); // Creates aspell spellchecker pointing to "aspell" as it's binary path

/** @var \PhpSpellcheck\Misspelling[]|\Generator $misspellings */
$misspellings = $spellchecker->check(<<<TEXT
لطفا متن خود را اینجا قرار دهید . یا بررسی کنید که این متن را‌ برای دیدن بعضی بعضی از اشکال هایی که ابزار زبان توانسته تشخیس هدد. درباره ی نرم افزارهای بررسی کننده های گرامر چه فکر می کنید؟ لطفا در نظر داشته باشید که آن‌ها بی نقص نمی باشند.‎
TEXT
, ['fa'], ['from' => 'languagetool spellchecker']);
foreach ($misspellings as $misspelling) {
    print_r([
        $misspelling->getWord(),
        $misspelling->getLineNumber(),
        $misspelling->getOffset(),
        $misspelling->getSuggestions(),
        $misspelling->getContext(),
    ]);
}

and it worked as expected ✔️

I've also tried with an arabic dictionary for hunspell

Install arabic hunspell dictionaries:

$ apt-get install hunspell-ar
<?php

use PhpSpellcheck\Spellchecker\Aspell;

require_once __DIR__ . '/../vendor/autoload.php';

// *** Using spellcheckers directly ***
$hunspell = \PhpSpellcheck\Spellchecker\Hunspell::create(); // Creates aspell spellchecker pointing to "aspell" as it's binary path

/** @var \PhpSpellcheck\Misspelling[]|\Generator $misspellings */
$misspellings = $hunspell->check('هدف مشروع آيسبل هو إنشاء قواميس في اللغة العربية للتطبيقات المكتبية الحرة مثل مجموعة أوبن أوفس', ['ar'], ['from' => 'aspell spellchecker']);
foreach ($misspellings as $misspelling) {
    print_r([
        $misspelling->getWord(),
        $misspelling->getLineNumber(),
        $misspelling->getOffset(),
        $misspelling->getSuggestions(),
        $misspelling->getContext(),
    ]);
}

and it worked too ✔️


I would advise to make sure the spellchecking engine you chose is working as expected by running it through the command line first.

Then if it works on the command line and not through the library please feel free to reopen the issue. Meanwhile I'll close it 🙂

from php-spellchecker.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.