Jump to content

Extension:语义钻探

本頁使用了標題或全文手工轉換
From mediawiki.org
This page is a translated version of the page Extension:Semantic Drilldown and the translation is 30% complete.
MediaWiki扩展手册
Semantic Drilldown
发行状态: 测试版
实现 特殊页面
描述 一款基於Semantic MediaWiki 的擴充功能,提供一個頁面讓使用者透過簡易建立的過濾器、深入鑽探網站的基於分類且是語義型的資料。
作者 Yaron Koren
维护者 gesinn.it
最新版本 4.0.0-beta3 (2022年11月)
MediaWiki 1.35+
PHP 7,4+
数据库更改
  • $wgShowCategoriesAsTabs
  • $wgNumRangesForNumberFilters
  • $wgDisableFilterCollapsible
  • $wgFiltersLargestFontSize
  • $wgMinValuesForComboBox
  • $wgFiltersSmallestFontSize
  • $wgHideFiltersWithoutValues
  • $wgHideCategoriesByDefault
  • $wgNumResultsPerPage
  • $wgResultFormatTypes
许可协议 GNU通用公眾授權條款2.0或更新版本
下載
示例 Verwaltungskooperation
警告 警告: 4.0.0版本之後將停止支援頁面語義(PageSchemas)。

Semantic Drilldown擴充功能提供一個頁面,可透過語義屬性的分類與過濾器,對網站資料進行資料鑽探。 它與MediaWiki語義擴充功能緊密結合,該擴充功能添加語義註解,可使維基能如同協作式的資料庫般地運作。

安裝

  • 您必須安裝Semantic MediaWiki 才能使此擴充功能運作。
  • 下載文件,并将其放置在您extensions/文件夹中的SemanticDrilldown目录内。
  • 請新增下列代码到您的LocalSettings.php 文件的底部:
    wfLoadExtension( 'SemanticDrilldown' );
    
  • 請运行更新脚本,它将自动创建此扩展所必须的数据库表。
  • Yes 完成 – 請导航至您的wiki上的Special:Version,以验证此扩展已成功安装。

作者

語義鑽探功能主要由Yaron Koren所編寫。 顯示鑽探結果的程式碼是由David Loomer所編寫。 The 'combo box' jQuery input was created by Sanyam Goyal as part of the 2010 Google Summer of Code. 與此Page Schemas 擴充功能介接的程式碼,是由Ankit Garg於2011年Google暑期程式碼計畫期間所開發。 目前處理日期過濾器的多數程式碼是由Edward Chernenko所撰寫。 MWJames、Joel Natividad等人亦提供了寶貴的貢獻。

版本历史

入门

你在設定語義鑽探功能之前,應先完成網站上所有資料結構的建置——包含屬性、分類、模板,以及若您正在使用表單的話,也需一併設定。 請參閱頁面表單的「入門指南」 部份,以瞭解如何設定這些項目。

請確保某些頁面確實存在,這些頁面包含註釋,且這些頁面隸屬於某個分類。

完成上述所有步驟後,您應先前往頁面Special:BrowseData,檢視網站上的分類結構所呈現的方式。

此時,您有兩種選擇,具體取決於您是否安裝了Page Schemas 的擴充功能。 (簡而言之,它提供了一個統一的介面來生成模板、表單、和過濾器。) 若您正在使用頁面輪廓,則可返回你已建立的頁面輪廓(若尚未建立,則可新建架構),並透過介面為每個相關屬性新增過濾器。

若您尚未擁有此功能,建議善用#drilldowninfo解析器函式。

用法

Special:BrowseData

某個語義鑽探的頁面

「瀏覽資料」頁面是此擴充功能的中心。 它列出此維基內所有「頂層」的分類,亦即,列出並不是其他分類的子分類的分類、以及在那些分類內所含的頁面數量。 每個分類名稱皆為該分類內頁面的「深入鑽探」的連結。 它讓使用者選擇額外的限制條件來限制結果的數量。 這些限制分為兩種類型:

  • 子分類--若該分類有任何子分類,這些子分類將顯示於「子分類」行中。 每個連結都將讓使用者僅能檢視屬於該子分類的頁面。 生成的鑽探頁面將包含頂層類別的所有過濾器的連結,以及所選子分類的所有子分類的連結。 因此,您可以使用「瀏覽資料」頁面來瀏覽整個類別樹狀結構。
  • 過濾器--基於語義屬性的過濾器可針對任何頂層分類來設定。 每個此類的過濾器在限制區域內皆佔有一行,讓使用者能將結果限定為僅包含語義屬性具有特定值的頁面。 針對日期型別或數字型別屬性的過濾器有特殊處理機制:對於日期過濾器,值的分組時間範圍(年、月或日)取決於當前值的集合的分佈情況;而對於數字過濾器,數值會被分組為若干個大致等大的範圍區間,此分組方式同樣取決於當前值的集合的特性。

In the display of the filter in the drilldown, values that do not have any results for them will not be displayed. The filter will also show two additional values: "Other" and "None". Pages that show up for "Other" are those that have a value for that filter's property other than one of the pre-specified values. Pages that show up for "None" are those that have no value for that property. "Other" and "None", like other filter values, will not show up if there are no results for them.

After any amount of clicking on different subcategories and filters, the user will be able to see, in the page header near the top of the page, the set of subcategories and filters they have clicked on, that currently set constraints on the result. The user can get rid of any constraint by clicking on the "x" next to its name in the header.

The drilldown 'results', i.e. the set of pages displayed at any given time during the drilling-down, are by default displayed in the same manner as in MediaWiki's category page; this display, however, can be customized, to show additional values for each page, or to show results in other formats such as tables, maps and timelines.


#drilldowninfo

The #drilldowninfo parser function should only be added to either top-level categories, or categories whose page contains __SHOWINDRILLDOWN__ - see Excluding and including categories from the list .

#drilldowninfo takes in the following parameters:

  • filterstakes in the set of filters for this category. In most cases, this will be the only parameter set. Filters should be separated by commas, and after each filter's name, in parentheses, should be a clause listing any of the following:
    • propertythe Semantic MediaWiki property that this filter applies to (mandatory)
    • categorya MediaWiki category from which to get values
    • requiresany number of previously-listed filters, that the user must select a value for before they can see this filter.
Example
{{#drilldowninfo:filters=Author (property=Was written by),
Second author (property=Was written by),
Date (property=Was published on),
Source (property=Was published by,category=Sources),
Topic (property=Addresses topic,category=Topics),
For (property=Is for, category=Positions,requires=Topic),
Against (property=Is against,category=Positions,requires=Topic),
Mixed (property=Is mixed on,category=Positions,requires=Topic)}}
Filters are displayed in Special:BrowseData in the order in which they are listed in #drilldowninfo.
  • titlesets the title for the drilldown page for this category (optional).
  • headersets the name of a page (e.g. Template:SD Header) to be displayed before the filters.
  • footersets the name of a page to be displayed after the drilldown output.
  • display parametersthis parameter lets you set the display of results as you would the display of Semantic MediaWiki's inline queries: that includes both additional properties that you would want to see displayed, and the format (such as a map or calendar) in which results will be displayed. "display parameters=" takes in a set of parameters like that of an inline query, although separated by semicolons instead of pipes. So, for instance, to display the drilldown results of a category on a Google Maps map, you could have the following in the call: "|display parameters=? Has coordinates;format=googlemaps3".
You can see an example of a simple use of this functionality here; every event gets its city shown as well. The relevant #drilldowninfo call is here.
There are several issues relating to the use of "display parameters=":
  • Unfortunately, currently one format is allowed for any one category.
  • The sort= and order= parameters for inline queries will not work - pages will always be sorted by their name.
  • As of Semantic MediaWiki version 1.8 and later wiki markup and html in properties of type text is displayed as plain text in various table result formats (table, broadtable, datatables), a workaround would be using result format template to create tabular output

Display options

A Semantic Drilldown page with map. (see the result of drilling down)

Tag-cloud-style display of filter values

You can set the drilldown page to show the values for each filter and each subcategory in "tag-cloud" style, where the size of each value's name is dependent on the number of results it has. To do this, you need to add two values to your LocalSettings.php file, $sdgFiltersSmallestFontSize and $sdgFiltersLargestFontSize; these represent the font size of the names of the least-popular and most-popular filter values, respectively, in pixels. Here is an example:

$sdgFiltersSmallestFontSize=9;
$sdgFiltersLargestFontSize=25;

Make sure to add these below the inclusion of Semantic Drilldown itself.

Setting the number of results per page

By default, the list of results, or pages that match the current set of filters, is displayed in the style of a category page, with a maximum of 100 results per page. You can change the number of results per page in your LocalSettings.php file, by setting the variable $sdgNumResultsPerPage. To set the page to show 250 results per page, add the following:

$sdgNumResultsPerPage=250;

Setting the display of filter values

For filters that have above a certain number of values, values are shown in a combo box, instead of individually. By default, that number is 40. To change the number, add something like this to LocalSettings.php:

$sdgMinValuesForComboBox=50;

...or you can set it to 0 or 1 if you want filter values to always show up within a combo box, in order to boost performance; values shown individually require an additional database query in order to get the number of instances of that value.

For filters that correspond to Number properties, the values are automatically grouped into ranges, with an attempt to create ranges of roughly equal size while still having "nice" numbers for the boundaries (e.g., 1200 instead of 1234). By default, values are grouped into 6 ranges. To change this number, add something like this to LocalSettings.php:

$sdgNumRangesForNumberFilters=4;

Hiding filters without values

By default, filters without values are showing the message "(There are no values for this filter)". If you want to hide filters without values, set

$sdgHideFiltersWithoutValues=false;

Display of categories

By default, a list of all top-level categories on the wiki shows up on one side of the "Browse data" page, to let users navigate to the drilldown interface for each such category. However, this display can be modified in a number of ways.

Removing the list of categories

You may want to have the drilldown page show the data only for one category, and not display the list of other categories. To do that, just add the string ?_single to anywhere in the URL query string; this will remove the list of categories.

Showing category names as tabs

If you add the following line to LocalSettings.php:

$sdgShowCategoriesAsTabs = true;

...it will display categories as tabs at the top of the page, instead of in a vertical list on the side of the page. This option makes more sense for sites with a smaller number of categories (less than seven or so).

Excluding and including categories from the list

You may want certain categories to not show up in the top-level list of categories. You can easily remove a category by adding the following anywhere within the category's page:

__HIDEFROMDRILLDOWN__

Conversely, there are some categories that you may want to show up in the main BrowseData list, even though they are not top-level categories. You can accomplish this as well, by adding the following to the category's page:

__SHOWINDRILLDOWN__

Conversely, you can also set for categories to only show up in the list if you specifically include them, i.e. have an opt-in instead of an opt-out approach. You can do that by adding the following to LocalSettings.php:

$sdgHideCategoriesByDefault = true;

If you do that, only categories marked with __SHOWINDRILLDOWN__ will appear. (The __HIDEFROMDRILLDOWN__ marking, on the other hand, will become irrelevant.)

Linking to a drilldown page

The best way to link to Special:BrowseData is with the #drilldownlink parser function. It has the following syntax;

{{#drilldownlink:category=|subcategory=|single|link text=|tooltip=|filters=}}

The parameters are as follows:

  • categorythe category name
  • subcategorythe subcategory, if any
  • singleif this parameter is added, the list of categories is not displayed
  • link textthe text of the link; by default, it's the category name
  • tooltipthe text that appears when the cursor hovers over the link, if any
  • filtersthe set of filters to apply, in the format a=b&c=d&...

Sites that use Semantic Drilldown

Here is a small sampling of sites that use Semantic Drilldown:

Mailing list

You should use the Semantic MediaWiki mailing list, semediawiki-user, for any questions, suggestions or bug reports about Semantic Drilldown. If possible, please add "[SD]" at the beginning of the subject line, to clarify the subject matter.

Contributing to the project

Bugs and feature requests

You can submit bug reports and requests for new features in GitHubs's bug tracker.

The current list of known bugs and requested features for Semantic Drilldown can be found here.

Translating

Translation of Semantic Drilldown is done through translatewiki.net. The translation for this extension can be found here. To add language values or change existing ones, you should create an account on translatewiki.net, then request permission from the administrators to translate a certain language or languages on this page (this is a very simple process). Once you have permission for a given language, you can log in and add or edit whatever messages you want to in that language.

See also

  • Cargo provides a similar drill-down interface, on top of a different storage system