Skip to content

Commit d909018

Browse files
committed
Updated readme
1 parent dc90f21 commit d909018

File tree

1 file changed

+37
-12
lines changed

1 file changed

+37
-12
lines changed

README.md

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
phpMorphy is a morphological analyzer library for Russian, Ukrainian, English and German languages.
1212

13-
**Make sure you have appropriate dictionaries for languages you wish to use. PhpMorphy library may not contain all neeed dictionaries!**
14-
1513
## Installation
1614

1715
Run the following command from your terminal:
@@ -25,7 +23,7 @@ Or add this to require section in your `composer.json` file:
2523
```json
2624
{
2725
"require": {
28-
"seoservice2020/laravel-phpmorphy": "~1.0"
26+
"seoservice2020/laravel-phpmorphy": "~2.0"
2927
}
3028
}
3129
```
@@ -44,37 +42,64 @@ This is the contents of the published file:
4442

4543
```php
4644
return [
47-
// phpMorphy language
48-
'language' => SEOService2020\Morphy\Morphy::russianLang,
49-
// phpMorphy options
50-
'options' => [
45+
'common_options' => [
5146
'storage' => phpMorphy::STORAGE_FILE,
5247
'predict_by_suffix' => true,
5348
'predict_by_db' => true,
5449
'graminfo_as_text' => true,
5550
],
56-
// when null, default dicts wil be loaded
57-
'dicts_path' => null,
51+
52+
'morphies' => [
53+
[
54+
// by this name specific morphy can be accessed through Morphy::morphy method
55+
// it may be any string
56+
'name' => SEOService2020\Morphy\Morphy::russianLang,
57+
'language' => SEOService2020\Morphy\Morphy::russianLang,
58+
// if no options key or null value specified, default options will be used
59+
// to use common options from this config, specify []
60+
'options' => [],
61+
// when null specified, default morphy dicts path will be used
62+
'dicts_path' => null,
63+
],
64+
],
5865
];
5966
```
6067

6168
## Usage
6269

70+
Wrapper automatically prepares input word for phpMorphy: it applies `trim` to word and converts it to uppercase or lowercase, depending on the dictionary options.
71+
6372
Using the wrapper directly:
6473

6574
``` php
6675
use SEOService2020\Morphy\Morphy;
6776
$morphy = new Morphy(Morphy::englishLang);
68-
echo $morphy->getPseudoRoot('FIGHTY');
77+
echo $morphy->getPseudoRoot('fighty');
6978
```
7079

7180
Or via Laravel Facade:
7281

7382
``` php
74-
use SEOService2020\Morphy\Facade\Morphy;
75-
Morphy::getPseudoRoot('БОЙЦОВЫЙ');
83+
use SEOService2020\Morphy\Facade\Morphy as Morphies;
84+
// first parameter is the name of morphy in config
85+
Morphies::getPseudoRoot('ru', 'Бойцовый');
86+
87+
// get morphy and call methods in regular manner
88+
Morphies::morphy('ru')->lemmatize(' бойцовый'); // word will be trimmed
89+
90+
// get all morphies, returns array like ['name' => Morphy]
91+
Morphies::morphies();
92+
93+
// get all morphies with pecific locale, returns array like ['name' => Morphy]
94+
Morphies::morphies(Morphy::russianLang);
95+
96+
// you can call phpMorphy static methods as well
97+
Morphies::getDefaultDictsDir();
7698
```
7799

100+
Note:
101+
> You can access morphy properties only directly from morphy object, not facade.
102+
78103
### Add facade support
79104

80105
This package allows Laravel to support facade out of the box, but you may explicitly add facade support to config/app.php:

0 commit comments

Comments
 (0)