Extensão:TextExtracts

This page is a translated version of the page Extension:TextExtracts and the translation is 37% complete.
Outdated translations are marked like this.
Esta extensão acompanha o MediaWiki 1.34 ou superior. Logo, não é necessário baixá-la novamente. No entanto, ainda é necessário seguir as outras instruções fornecidas.
This extension is under code stewardship review and not actively maintained (tarefa T256505). No new feature requests will be considered during this period.
Manual de extensões do MediaWiki
TextExtracts
Estado da versão: estável
Implementação API
Descrição Fornece uma Interface de programação de aplicações (API) para extrações de texto-simples, ou extrações de HTML limitado, do conteúdo da página
Autor(es) Max Semenik (MaxSemdiscussão)
Política de
compatibilidade
Snapshots releases along with MediaWiki. Master is not backward compatible.
MediaWiki >= 1.42
Modifica o banco
de dados
Não
Licença GNU GPL (Licença Pública Geral) 2.0 ou superior
Download
  • $wgExtractsExtendOpenSearchXml
  • $wgExtractsRemoveClasses
Quarterly downloads 165 (Ranked 42nd)
Public wikis using 2,046 (Ranked 189th)
Para traduzir a extensão TextExtracts, verifique sua disponibilidade no translatewiki.net
Problemas Tarefas em aberto · Relatar um bug

A extensão 'TextExtracts' fornece uma API que permite extrações de texto-simples, ou extrações de HTML limitado (HTML com conteúdo e algumas classes CSS removidas), do conteúdo da página.

Instalação

  • Baixe e coloque o(s) arquivo(s) num diretório chamado TextExtracts na sua pasta extensions/.
    Developers and code contributors should install the extension from Git instead, using:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/TextExtracts
  • Adicione o seguinte código ao final do seu arquivo LocalSettings.php :
    wfLoadExtension( 'TextExtracts' );
    
  •   Concluído – Navegue à página Special:Version em sua wiki para verificar se a instalação da extensão foi bem sucedida.

Parâmetros de configuração

  • $wgExtractsRemoveClasses é um array de <tag>, <tag>.class, .<class>, #<id> que será excluído da extração.
    Por exemplo, $wgExtractsRemoveClasses[] = 'dl'; remove o texto indentado, normalmente utilizado para notas de cabeçalho de não modelos que não desejados nos resumos.
  • extension.json define os padrões, das quais a classe "noexcerpt" pertence - isto pode ser adicionado a qualquer modelo para excluí-lo.
  • $wgExtractsExtendOpenSearchXml defines se "TextExtracts" deverá fornecer os seus extratos para o módulo da API Opensearch. O padrão é "false".

API



prop=extracts (ex)

(main | query | extracts)

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

Specific parameters:
Other general parameters are available.
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

Outro exemplo

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. Extensão: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