MediaWiki master
Wikimedia\Leximorph\Handler\Grammar Class Reference

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.
 

Detailed Description

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' );

Since
1.45
Author
Doğu Abaris (abari.nosp@m.s@nu.nosp@m.ll.ne.nosp@m.t)
Note
https://www.gnu.org/copyleft/gpl.html GPL-2.0-or-later

Definition at line 29 of file Grammar.php.

Constructor & Destructor Documentation

◆ __construct()

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.

Parameters
Provider$providerProvider instance.
GrammarFallbackRegistry$postProcessorThe post processor registry.
LoggerInterface$loggerThe logger instance to use.
Since
1.45

Definition at line 40 of file Grammar.php.

Member Function Documentation

◆ process()

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.

Parameters
string$wordThe word to transform.
string$caseThe target grammatical case.
?array<string,array<string,array<string,string>>>$overrideForms Override rules: $overrideForms[langCode][case][word] = result
Since
1.45
Returns
string The transformed word in the specified case.

Definition at line 62 of file Grammar.php.


The documentation for this class was generated from the following file: