Extensión:TextExtracts
For obtaining summaries in production environments, the Page Content Service is recommended and used by Wikimedia products. |
![]() Estado de lanzamiento: estable |
|
---|---|
Implementación | API |
Descripción | Provides API with plain-text or limited HTML extracts of page content |
Autor(es) | Max Semenik (MaxSemdiscusión) |
Política de compatibilidad | Lanzamientos de screenshots junto con MediaWiki. Master is not backward compatible. |
MediaWiki | >= 1.40.0 |
Cambios de la base de datos | No |
Licencia | GNU Licencia Pública general 2.0 o posterior |
Descarga | |
|
|
Quarterly downloads | 142 (Ranked 71st) |
Public wikis using | 2,046 (Ranked 189th) |
Traduce la extensión TextExtracts si está disponible en translatewiki.net | |
Asuntos | Tareas abiertas · Reportar un bug |
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.
Descarga
The extension can be retrieved directly from Git [?]:
- Browse code
- Some extensions have tags for stable releases.
- Browse tags
- Select the tag
- Click "snapshot"
- Each branch is associated with a past MediaWiki release. There is also a "master" branch containing the latest alpha version (might require an alpha version of MediaWiki).
- Browse branches
- Select a branch name
- Click "Continuar"
Extract the snapshot and place it in the extensions/TextExtracts/ directory of your MediaWiki installation.
If you are familiar with Git and have shell access to your server, you can also obtain the extension as follows:
cd extensions/
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/TextExtracts.git
Instalación
- Descarga y extrae los archivos en un directorio denominado «
TextExtracts
» dentro de la carpetaextensions/
. - Añade el siguiente código en la parte final de tu
LocalSettings.php
:wfLoadExtension( 'TextExtracts' );
- Hecho – Navega a Special:Version en el wiki para verificar que la extensión se haya instalado correctamente.
Para quienes usan MediaWiki 1.26 o versiones anteriores:
Estas instrucciones describen la nueva forma de instalar extensiones usando wfLoadExtension()
.
Si necesitas instalar esta extensión en versiones anteriores (MediaWiki 1.26 y anteriores), debes usar lo siguiente en lugar de wfLoadExtension( 'TextExtracts' );
:
require_once "$IP/extensions/TextExtracts/TextExtracts.php";
Preferencias de configuración
$wgExtractsRemoveClasses
is 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.
$wgExtractsExtendOpenSearchXml
defines 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 Este módulo no puede ser utilizado como de generador. | |
Prefijo | ex |
Derechos requeridos | Ninguno |
¿Correo sólo? | No |
Ayuda generada | Actual |
La siguiente documentación es la producción de $especial, generado automáticamente por la pre-versión de liberación de MediaWiki que se ejecuta en este sitio (MediaWiki.org). |
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]
Otro ejemplo
Resultado |
---|
{
"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. Extensión: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).
Véase también
Esta extensión está siendo usada en uno o más proyectos de Wikimedia. Esto significa probablemente que la extensión es estable y funciona lo suficientemente bien como para ser usada en sitios con gran cantidad de visitas. Puedes buscar el nombre de esta extensión en los archivos CommonSettings.php e InitialiseSettings.php de Wikimedia para ver dónde se instala. Encontrarás la lista completa de extensiones instaladas en un wiki en particular en la página Special:Version del wiki. |
Esta extensión está incluida en los siguientes paquetes y/o granjas wiki: This is not an authoritative list. Some wiki farms/hosts may contain this extension even if they are not listed here. Always check with your wiki farms/hosts or bundle to confirm. |