Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
MediaWiki\Extension\Translate\TtmServer\ElasticSearchTtmServer Class Reference

TtmServer backend based on ElasticSearch. More...

Inheritance diagram for MediaWiki\Extension\Translate\TtmServer\ElasticSearchTtmServer:
MediaWiki\Extension\Translate\TtmServer\TtmServer MediaWiki\Extension\Translate\TtmServer\ReadableTtmServer MediaWiki\Extension\Translate\TtmServer\WritableTtmServer MediaWiki\Extension\Translate\TtmServer\SearchableTtmServer

Public Member Functions

 isLocalSuggestion (array $suggestion)
 Determines if the suggestion returned by this TtmServer comes from this wiki or any other wiki.
 
 expandLocation (array $suggestion)
 Given suggestion returned by this TtmServer, constructs fully qualified URL to the location of the translation.
 
 query (string $sourceLanguage, string $targetLanguage, string $text)
 Fetches all relevant suggestions for given text.
 
 update (MessageHandle $handle, ?string $targetText)
 Shovels the new translation into translation memory.
 
 beginBootstrap ()
 Begin the bootstrap process.
 
 beginBatch ()
 Called before every batch (MessageGroup).
 
 batchInsertDefinitions (array $batch)
 
 batchInsertTranslations (array $batch)
 Called multiple times per batch if necessary.
 
 endBatch ()
 Called after every batch (MessageGroup).
 
 endBootstrap ()
 Do any cleanup, optimizing etc.
 
 getClient ()
 
 useWikimediaExtraPlugin ()
 
 getIndex ()
 
 setLogger (TTMServerBootstrap $logger)
 
 setDoReIndex ()
 Instruct the service to fully wipe the index and start from scratch.
 
 createSearch (string $queryString, array $opts, array $highlight)
 Search interface.
 
 search (string $queryString, array $opts, array $highlight)
 Search interface.
 
 getFacets ( $resultset)
 @inheritDoc
 
 getTotalHits ( $resultset)
 @inheritDoc
 
 getDocuments ( $resultset)
 @inheritDoc
 
- Public Member Functions inherited from MediaWiki\Extension\Translate\TtmServer\TtmServer
 __construct (array $config)
 

Additional Inherited Members

- Static Public Member Functions inherited from MediaWiki\Extension\Translate\TtmServer\TtmServer
static sortSuggestions (array $suggestions)
 
static onDelete (WikiPage $wikipage)
 Hook: ArticleDeleteComplete.
 
static onChange (MessageHandle $handle)
 Called from TranslateEditAddons::onSave.
 
static onGroupChange (MessageHandle $handle, array $old)
 
- Protected Attributes inherited from MediaWiki\Extension\Translate\TtmServer\TtmServer
array $config
 

Detailed Description

TtmServer backend based on ElasticSearch.

Depends on Elastica.

Author
Niklas Laxström @license GPL-2.0-or-later
Since
2014.04

Definition at line 38 of file ElasticSearchTtmServer.php.

Member Function Documentation

◆ batchInsertDefinitions()

MediaWiki\Extension\Translate\TtmServer\ElasticSearchTtmServer::batchInsertDefinitions ( array $batch)
Parameters
array[]$batch@phan-param array<int,array{0:MessageHandle,1:string,2:string}> $batch

Implements MediaWiki\Extension\Translate\TtmServer\WritableTtmServer.

Definition at line 402 of file ElasticSearchTtmServer.php.

◆ batchInsertTranslations()

MediaWiki\Extension\Translate\TtmServer\ElasticSearchTtmServer::batchInsertTranslations ( array $batch)

Called multiple times per batch if necessary.

Implements MediaWiki\Extension\Translate\TtmServer\WritableTtmServer.

Definition at line 412 of file ElasticSearchTtmServer.php.

◆ beginBatch()

MediaWiki\Extension\Translate\TtmServer\ElasticSearchTtmServer::beginBatch ( )

Called before every batch (MessageGroup).

Implements MediaWiki\Extension\Translate\TtmServer\WritableTtmServer.

Definition at line 395 of file ElasticSearchTtmServer.php.

◆ beginBootstrap()

MediaWiki\Extension\Translate\TtmServer\ElasticSearchTtmServer::beginBootstrap ( )

Begin the bootstrap process.

Exceptions
RuntimeException

Implements MediaWiki\Extension\Translate\TtmServer\WritableTtmServer.

Definition at line 345 of file ElasticSearchTtmServer.php.

◆ createSearch()

MediaWiki\Extension\Translate\TtmServer\ElasticSearchTtmServer::createSearch ( string $queryString,
array $opts,
array $highlight )

Search interface.

Definition at line 573 of file ElasticSearchTtmServer.php.

◆ endBatch()

MediaWiki\Extension\Translate\TtmServer\ElasticSearchTtmServer::endBatch ( )

Called after every batch (MessageGroup).

Implements MediaWiki\Extension\Translate\TtmServer\WritableTtmServer.

Definition at line 433 of file ElasticSearchTtmServer.php.

◆ endBootstrap()

MediaWiki\Extension\Translate\TtmServer\ElasticSearchTtmServer::endBootstrap ( )

Do any cleanup, optimizing etc.

Implements MediaWiki\Extension\Translate\TtmServer\WritableTtmServer.

Definition at line 436 of file ElasticSearchTtmServer.php.

◆ expandLocation()

MediaWiki\Extension\Translate\TtmServer\ElasticSearchTtmServer::expandLocation ( array $suggestion)

Given suggestion returned by this TtmServer, constructs fully qualified URL to the location of the translation.

Returns
string URL

Implements MediaWiki\Extension\Translate\TtmServer\ReadableTtmServer.

Definition at line 66 of file ElasticSearchTtmServer.php.

◆ getClient()

MediaWiki\Extension\Translate\TtmServer\ElasticSearchTtmServer::getClient ( )

Definition at line 443 of file ElasticSearchTtmServer.php.

◆ getDocuments()

MediaWiki\Extension\Translate\TtmServer\ElasticSearchTtmServer::getDocuments ( $resultset)

◆ getFacets()

MediaWiki\Extension\Translate\TtmServer\ElasticSearchTtmServer::getFacets ( $resultset)

◆ getIndex()

MediaWiki\Extension\Translate\TtmServer\ElasticSearchTtmServer::getIndex ( )

Definition at line 463 of file ElasticSearchTtmServer.php.

◆ getTotalHits()

MediaWiki\Extension\Translate\TtmServer\ElasticSearchTtmServer::getTotalHits ( $resultset)

◆ isLocalSuggestion()

MediaWiki\Extension\Translate\TtmServer\ElasticSearchTtmServer::isLocalSuggestion ( array $suggestion)

Determines if the suggestion returned by this TtmServer comes from this wiki or any other wiki.

Implements MediaWiki\Extension\Translate\TtmServer\ReadableTtmServer.

Definition at line 62 of file ElasticSearchTtmServer.php.

◆ query()

MediaWiki\Extension\Translate\TtmServer\ElasticSearchTtmServer::query ( string $sourceLanguage,
string $targetLanguage,
string $text )

Fetches all relevant suggestions for given text.

Parameters
string$sourceLanguagelanguage code for the provide text
string$targetLanguagelanguage code for the suggestions
string$textthe text for which to search suggestions
Returns
array List: unordered suggestions, which each has fields:
  • source: String: the original text of the suggestion
  • target: String: the suggestion
  • context: String: title of the page where the suggestion comes from
  • quality: Float: the quality of suggestion, 1 is perfect match

Implements MediaWiki\Extension\Translate\TtmServer\ReadableTtmServer.

Definition at line 70 of file ElasticSearchTtmServer.php.

◆ search()

MediaWiki\Extension\Translate\TtmServer\ElasticSearchTtmServer::search ( string $queryString,
array $opts,
array $highlight )

Search interface.

Exceptions
TtmServerException

Implements MediaWiki\Extension\Translate\TtmServer\SearchableTtmServer.

Definition at line 637 of file ElasticSearchTtmServer.php.

◆ setDoReIndex()

MediaWiki\Extension\Translate\TtmServer\ElasticSearchTtmServer::setDoReIndex ( )

Instruct the service to fully wipe the index and start from scratch.

Implements MediaWiki\Extension\Translate\TtmServer\WritableTtmServer.

Definition at line 502 of file ElasticSearchTtmServer.php.

◆ setLogger()

MediaWiki\Extension\Translate\TtmServer\ElasticSearchTtmServer::setLogger ( TTMServerBootstrap $logger)

Definition at line 491 of file ElasticSearchTtmServer.php.

◆ update()

MediaWiki\Extension\Translate\TtmServer\ElasticSearchTtmServer::update ( MessageHandle $handle,
?string $targetText )

Shovels the new translation into translation memory.

Use this for single updates (=after message edit). If no text is provided, entry will be removed from the translation memory.

Parameters
MessageHandle$handle
string | null$targetTextUse null to only delete.

Implements MediaWiki\Extension\Translate\TtmServer\WritableTtmServer.

Definition at line 231 of file ElasticSearchTtmServer.php.

◆ useWikimediaExtraPlugin()

MediaWiki\Extension\Translate\TtmServer\ElasticSearchTtmServer::useWikimediaExtraPlugin ( )
Returns
true if the backend is configured with the wikimedia extra plugin

Definition at line 455 of file ElasticSearchTtmServer.php.


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