확장기능:TextExtracts

From MediaWiki.org
Jump to navigation Jump to search
This page is a translated version of the page Extension:TextExtracts and the translation is 64% complete.

Other languages:
English • ‎dansk • ‎español • ‎occitan • ‎polski • ‎português do Brasil • ‎中文 • ‎日本語 • ‎한국어
미디어위키 확장 기능 매뉴얼
OOjs UI icon advanced.svg
TextExtracts
출시 상태: 안정
구현 API
설명 Provides API with plain-text or limited HTML extracts of page content
만든이 Max Semenik (MaxSemtalk)
MediaWiki 1.23+
PHP 5.4+
데이터베이스 변경 아니오
라이선스 GNU General Public License 2.0 or later
다운로드
  • $wgExtractsRemoveClasses
  • $wgExtractsExtendOpenSearchXml
TextExtracts 확장 기능 번역 (translatewiki.net에서 가능한 경우)
사용법과 버전 매트릭스를 확인합니다.
이슈 미해결 작업 · 버그 보고

The TextExtracts extension provides an API which allows to retrieve plain-text or limited HTML (HTML with content for some CSS classes removed) extracts of page content.

다운로드

The extension can be retrieved directly from Git [?]:

  • Browse code
  • Some extensions have tags for stable releases.
  • 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).

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

설치

  • 파일을 다운로드해서, extensions/ 폴더 내의 TextExtracts 이라는 이름의 디렉터리 내에 설치합니다.
  • 아래의 코드를 LocalSettings.php의 말미에 추가합니다:
    wfLoadExtension( 'TextExtracts' );
    
  • Yes 완료 – 위키의 ‘Special:Version’에 이동해서, 확장기능이 올바르게 설치된 것을 확인합니다.

미디어위키 1.26 이하를 실행 중인 사용자에게:

위의 지시사항은 wfLoadExtension()을 사용하여 이 확장기능을 설치하는 새로운 방법을 기술한 것으로, wfLoadExtension( 'TextExtracts' ); 대신 초기 버전(미디어위키 1.26 이하)에 이 확장기능을 설치하려면 다음을 사용해야 합니다:

require_once "$IP/extensions/TextExtracts/TextExtracts.php";


구성 설정

  • $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.
    TextExtracts.php 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 is "false".

API


prop=extracts (ex)

(main | query | extracts)

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

Parameters:
exchars

How many characters to return. Actual text returned might be slightly longer.

The value must be between 1 and 1,200.
Type: integer
exsentences

How many sentences to return.

The value must be between 1 and 10.
Type: integer
exlimit

How many extracts to return. (Multiple extracts can only be returned if exintro is set to true.)

No more than 20 (20 for bots) allowed.
Type: integer or max
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, wiki, raw
Default: wiki
excontinue

When more results are available, use this to continue.

Type: integer

다른 예시

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.


같이 보기