확장기능:TextExtracts
For obtaining summaries in production environments, the Page Content Service is recommended and used by Wikimedia products. |
TextExtracts 출시 상태: 안정 |
|
---|---|
구현 | API |
설명 | Provides API with plain-text or limited HTML extracts of page content |
만든 이 | Max Semenik (MaxSem토론) |
호환성 정책 | 스냅샷은 미디어위키와 함께 릴리스됩니다. Master is not backward compatible. |
MediaWiki | >= 1.43 |
데이터베이스 변경 | 아니오 |
라이선스 | GNU General Public License 2.0 or later |
다운로드 | |
|
|
Quarterly downloads | 101 (Ranked 59th) |
Public wikis using | 2,046 (Ranked 189th) |
TextExtracts 확장 기능 번역 (translatewiki.net에서 가능한 경우) | |
이슈 | 미해결 작업 · 버그 보고 |
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.
설치
- 파일을 다운로드하고
TextExtracts
폴더를extensions/
디렉토리에 넣어 주세요.
개발자와 코딩 기여자는 Git을 이용해 확장기능을 다운받는 것이 좋습니다.cd extensions/
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/TextExtracts - 아래의 코드를 LocalSettings.php 코드의 마지막에 추가합니다.
wfLoadExtension( 'TextExtracts' );
- 완료 – 위키의 ‘Special:Version’에 이동해서, 확장기능이 올바르게 설치된 것을 확인합니다.
구성 설정
$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 이 모듈은 제너레이터 함수와 함께 사용할 수 없습니다. | |
접두어 | ex |
요구되는 권한 | 없음 |
Post only? | 아니오 |
생성된 도움말 | 현재 |
The following documentation is the output of 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. 확장기능:팝업 .
- 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).
같이 보기
이 확장 기능은 하나 이상의 위키미디어 프로젝트에서 사용 중입니다. 이것은 아마도 이 확장 기능이 안정적이고 트래픽이 많은 웹 사이트에서 사용할 수 있을 만큼 충분히 잘 작동한다는 것을 의미합니다. 설치된 위치를 확인하려면 위키미디어의 CommonSettings.php 및 InitialiseSettings.php 구성 파일에서 이 확장 기능의 이름을 찾습니다. 특정 위키에 설치된 확장 기능의 전체 목록은 위키의 Special:Version 문서에서 볼 수 있습니다. |
This extension is included in the following wiki farms/hosts and/or packages: This is not an authoritative list. Some wiki farms/hosts and/or packages may contain this extension even if they are not listed here. Always check with your wiki farms/hosts or bundle to confirm. |