Ekstensi:TextExtracts
| Untuk memperoleh ringkasan dalam lingkungan produksi, Page Content Service direkomendasikan dan digunakan oleh produk Wikimedia. |
Status keluaran: stabil |
|
|---|---|
| Penerapan | API |
| Deskripsi | Menyediakan API dengan teks biasa atau ekstrak HTML terbatas dari konten halaman |
| Perancang | Max Semenik (MaxSembicara) |
| Kebijakan kompatibilitas | Cuplikan dikeluarkan bersamaan dengan MediaWiki. Induk tidak kompatibel dengan versi sebelumnya. |
| Perubahan pangkalan data | Tidak |
|
|
| Lisensi | Lisensi Publik Umum GNU 2.0 atau lebih baru |
| Unduh | |
| Terjemahkan pengaya TextExtracts jika tersedia di translatewiki.net | |
| 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.
Instalasi
- Unduh dan pindahkan folder
TextExtractsyang diekstrak ke direktoriextensions/Anda.
Pengembang dan penyumbangsih kode sebaiknya memasang pengaya dari Git sebagai gantinya, menggunakan:cd extensions/ git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/TextExtracts
- Tambahkan kode berikut di bawah berkas LocalSettings.php Anda:
wfLoadExtension( 'TextExtracts' );
Selesai – Telusuri ke Special:Version di wiki Anda untuk memastikan pengayanya berhasil dipasang.
Pengaturan konfigurasi
$wgExtractsRemoveClassesis an array of <tag>, <tag>.class, .<class>, #<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.
- For example,
- extension.json defines the defaults, of which the class "noexcerpt" is one - this may be added to any template to exclude it.
$wgExtractsExtendOpenSearchXmldefines whether TextExtracts should provide its extracts to the Opensearch API module. The default isfalse.
API
| extracts | |
|---|---|
| Returns plain-text or limited HTML extracts of the given pages Modul ini tidak bisa digunakan sebagai sebuah generator. | |
| Prefiks | ex |
| Hak yang dibutuhkan | tidak satupun |
| Pos saja? | Tidak |
| Bantuan yang dihasilkan | Sekarang |
| Dokumentasi berikut merupakan keluaran dari Special: |
prop=extracts (ex)
- This module requires read rights.
- Source: TextExtracts
- License: GPL-2.0-or-later
Returns plain-text or limited HTML extracts of the given pages.
- 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. More detailed information on how to continue queries can be found on mediawiki.org.
- Type: integer
- Get a 175-character extract
- api.php?action=query&prop=extracts&exchars=175&titles=Therion [open in sandbox]
| Result |
|---|
{
"query": {
"pages": {
"9228": {
"pageid": 9228,
"ns": 0,
"title": "Earth",
"extract": "Earth, also called the world and, less frequently, Gaia, (or Terra in some works of science fiction)..."
}
}
}
}
|
Caveats
There are various things to be aware of when using the API or software that uses the API e.g. Extension:Popups.
- 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
- Articles must begin with the lead paragraph for an extract to be generated. The use of any template, and/or unclosed or empty HTML element may result in no preview for the article. E.g. "<div></div>hello" will give an empty extract.
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 $wgExtractsRemoveClasses configuration variable (which also defines some other excluded elements).
See also
| Pengaya ini sedang digunakan di salah satu atau lebih proyek Wikimedia. Ini kemungkinan berarti pengaya ini stabil dan bekerja cukup baik untuk digunakan oleh situs web berlalu lintas tinggi. Cari nama pengaya ini di berkas konfigurasi CommonSettings.php dan InitialiseSettings.php Wikimedia untuk melihat di mana ia dipasang. Daftar lengkap pengayakulit yang dipasang di suatu wiki bisa dilihat di halaman Special:Version wiki. |
| Pengaya ini disertakan di wiki farm/hos dan/atau paket berikut: |
- Stable extensions/id
- API extensions/id
- ApiOpenSearchSuggest extensions/id
- SearchResultProvideDescription extensions/id
- GPL licensed extensions/id
- Extensions in Wikimedia version control/id
- All extensions/id
- Extensions bundled with MediaWiki 1.34/id
- Extensions used on Wikimedia/id
- Extensions included in BlueSpice/id
- Extensions included in Canasta/id
- Extensions available as Debian packages/id
- Extensions included in Fandom/id
- Extensions included in Miraheze/id
- Extensions included in MyWikis/id
- Extensions included in ProWiki/id
- Extensions included in wiki.gg/id
