Ekstensi:TextExtracts

This page is a translated version of the page Extension:TextExtracts and the translation is 19% complete.
Other languages:
Bahasa Indonesia • ‎English • ‎Türkçe • ‎español • ‎français • ‎occitan • ‎polski • ‎português • ‎português do Brasil • ‎中文 • ‎日本語 • ‎한국어
Ekstensi ini tersedia di MediaWiki 1.34 dan selanjutnya. Jadi Anda tidak perlu mengunduhnya lagi. Akan tetapi, Anda masih perlu mengikuti instruksi lain yang diberikan.
Manual ekstensi MediaWiki
OOjs UI icon advanced.svg
TextExtracts
Status rilis: stabil
Implementasi API
Deskripsi Menyediakan API dengan teks biasa atau ekstrak HTML terbatas dari konten halaman
Perancang awal Max Semenik (MaxSembicara)
MediaWiki 1.23+
PHP 5.4+
Perubahan basis data Tidak
Lisensi Lisensi Publik Umum GNU 2.0 atau lebih baru
Unduh
  • $wgExtractsExtendOpenSearchXml
  • $wgExtractsRemoveClasses
Terjemahkan ekstensi TextExtracts jika tersedia di translatewiki.net

Periksa matriks penggunaan dan versi.

Masalah Tugas terbuka · Laporkan kekutu

The TextExtracts extension provides an API which allows retrieval of plain-text or limited HTML (HTML with content for some CSS classes removed) extracts of page content.

Download

Ekstensi ini bisa diperoleh secara langsung dari Git. [?]:

  • Telusuri kode
  • Beberapa ekstensi memiliki tag untuk rilis stabil.
  • Setiap cabang bersesuaian dengan sebuah rilis MediaWiki. Terdapat pula cabang "master" yang berisi versi alfa terbaru (mungkin membutuhkan versi alfa MediaWiki).

Ekstrak snapshot-nya dan letakkan di direktori extensions/TextExtracts/ instalasi MediaWiki Anda.

Jika Anda mengenal git dan punya akses shell ke peladen Anda, Anda juga bisa memperoleh ekstensinya dengan cara berikut:

cd extensions/
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/TextExtracts.git


Instalasi

  • Unduh dan letakkan berkas-berkasnya di dalam sebuah direktori yang bernama TextExtracts di folder extensions/ Anda.
  • Tambahkan baris berikut di bawah LocalSettings.php Anda:
    wfLoadExtension( 'TextExtracts' );
    
  •   Selesai – Telusuri ke Special:Version di wiki Anda untuk memastikan ekstensinya berhasil dipasang.

Bagi pengguna yang menjalankan MediaWiki 1.26 atau lebih lama:

Instruksi di atas menjelaskan cara baru untuk memasang ekstensi ini menggunakan wfLoadExtension(). Jika Anda perlu memasang ekstensi ini di versi yang lebih lama (MediaWiki 1.26 dan sebelumnya), bukannya wfLoadExtension( 'TextExtracts' );, Anda perlu menggunakan:

require_once "$IP/extensions/TextExtracts/TextExtracts.php";

Pengaturan konfigurasi

  • $wgExtractsRemoveClasses is an array of <tag>, <tag>.class, .<class>, and #<id> which will be excluded from extraction.
  • For example, $wgExtractsRemoveClasses[] = 'dl'; removes indented text, often used for non-templated hatnotes that are not desired in summaries.
  • extension.json defines the defaults, of which the class "noexcerpt" is one - this may be added to any template to exclude it.
  • $wgExtractsExtendOpenSearchXml defines whether TextExtracts should provide its extracts to the Opensearch API module. The default is false.

API



prop=extracts (ex)

(main | query | extracts)

Returns plain-text or limited HTML extracts of the given pages.

Parameters:
exchars

How many characters to return. Actual text returned might be slightly longer.

Type: integer
The value must be between 1 and 1,200.
exsentences

How many sentences to return.

Type: integer
The value must be between 1 and 10.
exlimit

How many extracts to return. (Multiple extracts can only be returned if exintro is set to true.)

Type: integer or max
The value must be between 1 and 20.
Default: 20
exintro

Return only content before the first section.

Type: boolean (details)
explaintext

Return extracts as plain text instead of limited HTML.

Type: boolean (details)
exsectionformat

How to format sections in plaintext mode:

plain
No formatting.
wiki
Wikitext-style formatting (== like this ==).
raw
This module's internal representation (section titles prefixed with <ASCII 1><ASCII 2><section level><ASCII 2><ASCII 1>).
One of the following values: plain, raw, wiki
Default: wiki
excontinue

When more results are available, use this to continue.

Type: integer

Another example

Caveats

There are various things to be aware of when using the API

  • We do not recommend the usage of `exsentences`.

It does not work for HTML extracts and there are many edge cases for which it doesn't exist. For example "Arm. gen. Ing. John Smith was a soldier." will be treated as 4 sentences. We do not plan to fix this.

  • Inline images are stripped from the response (even in HTML mode). This means if you are using the Math extension and using formulae in your lead section they may not appear in the summary output.
  • In HTML mode we cannot guarantee well formed HTML. Resulting HTML may be invalid or malformed.
  • In plaintext mode:
    • citations may not be stripped (see phab:T197266)
    • if a paragraph ends with an HTML tag e.g. ref tag, new lines may be dropped (see phab:T201946),
    • new lines may be dropped after lists phab:T208132

FAQ

How can I remove content from a page preview/extract?

TextExtracts will strip any element that is marked with the class noexcerpt. This is provided by the global wgExtractsRemoveClasses.

See also