Extension:TextExtracts

This page is a translated version of the page Extension:TextExtracts and the translation is 53% complete.
この拡張機能は MediaWiki 1.34 以降に同梱されています。 そのため再度ダウンロードする必要はありません。 しかし、提供されているその他の手順に従う必要はあります。
This extension is under code stewardship review and not actively maintained (タスク T256505). No new feature requests will be considered during this period.
MediaWiki 拡張機能マニュアル
TextExtracts
リリースの状態: 安定
実装 API
説明 ページ本文を抽出したプレーンテキストまたは制限付き HTML を提供する
作者 Max Semenik (MaxSemトーク)
互換性の方針 MediaWiki とともにリリースされるスナップショット。 master には後方互換性がありません。
MediaWiki >= 1.42
データベースの変更 いいえ
ライセンス GNU 一般公衆利用許諾書 2.0 以降
ダウンロード
  • $wgExtractsExtendOpenSearchXml
  • $wgExtractsRemoveClasses
Quarterly downloads 151 (Ranked 43rd)
Public wikis using 2,046 (Ranked 189th)
translatewiki.net で翻訳を利用できる場合は、TextExtracts 拡張機能の翻訳にご協力ください
問題点 未解決のタスク · バグを報告

TextExtracts拡張機能は、プレーンテキストまたは制限付きHTML(いくつかのCSSクラスを削除したコンテンツを含むHTML)のページコンテンツの抽出を取得するAPIを提供します。

インストール

  • ダウンロードして、ファイルをextensions/フォルダー内のTextExtractsという名前のディレクトリ内に配置します。
    開発者とコード寄稿者は、上記の代わりに以下を使用して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.
  • 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 is 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

別の例

結果
{
    "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)..."
            }
        }
    }
}

注意

There are various things to be aware of when using the API or software that uses the API e.g. Extension: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. 修正する予定はありません。

  • 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.
  • プレーンテキストモードでは
    • 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.

よくある質問

ページのプレビュー/抽出からコンテンツを削除するにはどうすればよいですか?

TextExtracts は、クラス .noexcerpt でマークされた要素をすべて取り除きます。 This is provided by the $wgExtractsRemoveClasses configuration variable (which also defines some other excluded elements).

関連項目