|
MediaWiki master
|
Grammar. More...
Public Member Functions | |
| __construct (protected readonly Provider $provider, private readonly GrammarFallbackRegistry $postProcessor, private readonly LoggerInterface $logger,) | |
| Initializes the Grammar handler with the given transformations provider and a logger. | |
| process (string $word, string $case, ?array $overrideForms=[]) | |
| Transforms the given word into the specified grammatical case. | |
Grammar.
The Grammar class performs language-specific grammatical transformations on a given word. It uses transformation rules (loaded from JSON files) to convert the input word into the specified grammatical case.
Usage Example: echo $grammar->process( 'Википедия', 'genitive' );
Definition at line 29 of file Grammar.php.
| Wikimedia\Leximorph\Handler\Grammar::__construct | ( | protected readonly Provider | $provider, |
| private readonly GrammarFallbackRegistry | $postProcessor, | ||
| private readonly LoggerInterface | $logger ) |
Initializes the Grammar handler with the given transformations provider and a logger.
| Provider | $provider | Provider instance. |
| GrammarFallbackRegistry | $postProcessor | The post processor registry. |
| LoggerInterface | $logger | The logger instance to use. |
Definition at line 40 of file Grammar.php.
| Wikimedia\Leximorph\Handler\Grammar::process | ( | string | $word, |
| string | $case, | ||
| ?array | $overrideForms = [] ) |
Transforms the given word into the specified grammatical case.
This method applies language-specific grammatical transformations by using transformation rules loaded from JSON configuration files. The input word is modified according to the first matching rule for the target grammatical case.
| string | $word | The word to transform. |
| string | $case | The target grammatical case. |
| ?array<string,array<string,array<string,string>>> | $overrideForms Override rules: $overrideForms[langCode][case][word] = result |
Definition at line 62 of file Grammar.php.