Extension:Cognate/hu

From Linux Web Expert

MediaWiki-kiterjesztések kézikönyve
Cognate
Kiadási állapot: stabil
Megvalósítás Adatbázis
Leírás Link different language versions of a page by using the page title.
Szerző(k) Gabriel Birke, Addshore
Legfrissebb verzió Continuous updates
Kompatibilitási irányelv Snapshots releases along with MediaWiki. Master is not backward compatible.
MediaWiki 1.29+
Táblák cognate_sites
cognate_pages
cognate_titles
Licenc Nincs licenc megadva
Letöltés
Quarterly downloads Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin').
Public wikis using Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin').
Fordítsd le a(z) Cognate kiterjesztést, ha elérhető a translatewiki.net oldalon
Problémák Nyitott feladatok · Hibajelentés

A Cognate kiterjesztés létrehoz egy központi tárat, ahol egy wikicsoport lapcímeit tárolja, ezáltal képes nyelvközi hivatkozásokat létrehozni a wikiprojektek között, ha azonosak a lapcímek. A kiterjesztés a „nyelvközi hivatkozások centralizálása a Wikiszótárban” feladat megoldására jött létre.

"Cognate" is a linguistic concept, referring to words in different languages developed from the same origin. This means that this extension is misnamed—since this extension links pages with the same title across wikis, a proper name would be “Homograph”.

  • Page titles are the same across languages (with some simple normalization applied).
  • Pages should not contain inter language links in wikitext as these will override the link provided by Cognate.
  • Unexpected hash conflicts are unlikely but could occur, and would result in unexpected language links.

How it works

Title Normalization

Very simple title normalization (reduction to ASCII) occurs within the extension. This can be seen in the StringNormalizer class.

Initially the amount of normalization is very small. Requests can be made to expand this and will be added on a case by case basis.

String Normalized Notes
Hello… Hello... The raw string contains an ellipsis character. This is normalized to three . characters
lepelle’ lepelle' The normalized string has a normalized apostrophe.

Title Hashing

Titles are hashed using sha256. This can be seen in the StringHasher class.

Part of the hash is then stored in the database in a BIG_INT field for efficient lookups.

There are roughly 18,446,744,073,709,551,615 possible values.

String Hash Int
A 559AEAD08264D5795D3909718CDD05ABD49572E84FE55590EEF31A88A08FDFFD 6168500820899059065
Foo 1CBEC737F863E4922CEE63CC2EBBFAAFCD1CFF8B790D8CFD2E6A5D550B648AFA 2071311921841431698
1234567890 C775E7B757EDE630CD0AA1113BD102661AB38829CA52A6422AB782862F268646 -4074095513246505424

Matching Hashes

As titles that require links are assumed to be the same post normalization, they will result in the same hash and thus the same Int stored in the database.

Some sample data might look as follows when loading the "Foo..." page on enwiktionary.

Wiki Title Hash Int Normalized Hash Int Notes
enwiktionary Foo... 395730596998145766 395730596998145766 Matched row
frwiktionary Foo… -7435652355441782233 395730596998145766 Matched row, even though the pre normalized title includes the ellipsis character.
dewiktionary Foo... 395730596998145766 395730596998145766 Matched row
arwiktionary Foo 2071311921841431698 2071311921841431698

Overwriting

It is possible to overwrite the automatic links provided by Cognate, simply by adding one or more interwiki links in the page.

That also means that to make Cognate work when the extension is deployed, the pages should not contain inter language links in their wikitext.

Testing

The extension can be tested on beta wiktionary sites:

These sites are linked together using the Cognate extension with added interwiki sorting provided by the InterwikiSorting extension.

Installation

  • <translate> [[<tvar name=2>Special:ExtensionDistributor/Cognate/hu</tvar>|Download]] and move the extracted <tvar name=name>Cognate/hu</tvar> folder to your <tvar name=ext>extensions/</tvar> directory.</translate>
    <translate> Developers and code contributors should install the extension [[<tvar name=git>Special:MyLanguage/Download from Git</tvar>|from Git]] instead, using:</translate>cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Cognate%2Fhu
  • <translate> Add the following code at the bottom of your <tvar name=1>LocalSettings.php </tvar> file:</translate>
    wfLoadExtension( 'Cognate/hu' );
    # Settings used in WMF production
    # Use the external cluster 'extension1' and dbname 'cognate_wiktionary'
    $wgCognateDb = 'cognate_wiktionary';
    $wgCognateCluster = 'extension1';
    # Only work on the main namespace
    $wgCognateNamespaces = [ 0 ];
    
  • <translate> Run the [[<tvar name=update>Special:MyLanguage/Manual:Update.php</tvar>|update script]] which will automatically create the necessary database tables that this extension needs.</translate>
  • File:OOjs UI icon check-constructive.svg <translate> Done</translate> – <translate> Navigate to <tvar name=special>Special:Version</tvar> on your wiki to verify that the extension is successfully installed.</translate>
  • Populate the sites table by running the populateCognateSites.php maintenance script. Sites must already exist in the MediaWiki sites table with the correct groupings.
php ./maintenance/populateCognateSites.php --site-group=wiktionary
  • Populate the page and title tables by running the populateCognatePages.php maintenance script.
php ./maintenance/populateCognatePages.php