Extensão:TextExtracts
![]() | This extension is maintained by the Reading Web team. |
![]() | For obtaining summaries in production environments, the Page Content Service is recommended and used by Wikimedia products. |
TextExtracts Estado da versão: estável |
|
---|---|
Implementação | API |
Descrição | Provides API with plain-text or limited HTML extracts of page content |
Autor(es) | Max Semenik (MaxSemdiscussão) |
MediaWiki | 1.23+ |
PHP | 5.4+ |
Modifica o banco de dados |
Não |
Licença | GNU GPL (Licença Pública Geral) 2.0 ou superior |
Download | |
|
|
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 a extração de textos simples ou HTML do conteúdo de uma página.
Download
A extensão pode ser recuperada diretamente a partir do Git [?]:
- Navegar pelo código
- Algumas extensões possuem tags para versões estáveis.
- Navegar pelas tags
- Selecione a tag
- Clique "snapshot"
- Cada pacote está associado com uma versão antiga do MediaWiki. Existe também um pacote "master" que contém a versão alfa mais recente (pode exigir uma versão alfa do MediaWiki).
- Navegar pelos pacotes
- Selecione um nome de pacote
- Clique "Continuar"
Extraia o snapshot e coloque-o no diretório extensions/TextExtracts/ de sua instalação do MediaWiki.
Se você estiver familiarizado com o Git e tem acesso shell para seu servidor, você pode obter a extensão, como se segue:
cd extensions/
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/TextExtracts.git
Instalação
- Baixe e coloque o(s) arquivo(s) num diretório chamado
TextExtracts
na sua pastaextensions/
. - 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.
Para usuários executando o MediaWiki 1.26 ou anteriores:
As instruções acima descrevem a nova forma de instalar essa extensão utilizando wfLoadExtension()
.
Se precisar instalar essa extensão em versões antigas (MediaWiki 1.26 e anteriores), em vez de wfLoadExtension( 'TextExtracts' );
, você precisa usar:
require_once "$IP/extensions/TextExtracts/TextExtracts.php";
Parâmetros de configuração
$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.
- 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 não possui a função de gerador. |
|
Prefixo | ex |
Permissões | nenhuma |
Apenas post? | Não |
Ajuda gerada | Atual |
![]() | The following documentation is the output of Special:ApiHelp/query+extracts, automatically generated by the pre-release version of MediaWiki that is running on this site (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.
- Type: integer
- Get a 175-character extract
- api.php?action=query&prop=extracts&exchars=175&titles=Therion [open in sandbox]
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
- 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
![]() | Esta extensão está sendo usado por um ou mais projetos da Wikimedia. Isto significa que, provavelmente, a extensão é estável e funciona bem o suficiente para ser utilizada em sites de alto tráfego. Procure pelo nome dessa extensão nos arquivos de configuração CommonSettings.php e InitialiseSettings.php da Wikimedia para verificar onde ela foi instalada. Uma lista completa das extensões instaladas numa wiki em particular podem ser visualizadas na página Special:Version da wiki. |