Extension:Semantic Drilldown/zh

說明
Semantic Drilldown is an extension to MediaWiki that provides a page for drilling down through a site's data, using categories and filters on semantic properties. It is heavily tied in with the Semantic MediaWiki extension, and is meant to be used for structured data that has semantic markup. Having Semantic MediaWiki installed is a precondition for the Semantic Drilldown extension; the code will not work without it.

查看資料頁面即為此一外掛的核心，在該頁面中的上方，顯示著所有該wiki系統的頂層分類(category，即意所顯示的分類不為其他分類項下的子分類)，以及該分類所擁有的頁面數量，每個分類項目亦是用來鑽取(drilldown)該分類項下頁面的超連結. 其讓使用者選取參數條件以篩選出您所要的結果，而此參數條件可分為兩種類型：(The "View data" page is the heart of the extension. It shows, at the top, all the top-level categories in the wiki; i.e., the categories that are not subcategories of another category, and the number of pages within that category. Each category name is a link to a drilldown for the pages in that category. It lets the user select additional constraints to limit the number of results. These constraints come in two types:)


 * 子分類(Subcategories) - 如果某分類項下有子分類，則會被顯示在「子分類」行. 每個項下的超連結都會帶領使用者去查看該子分類項下的頁面. 那些所顯示的頁面皆符合在頂層分類頁面中所設定好的篩選器的篩選值. 如此一來您則可利用查看資料頁面去盡情的暢遊在wiki系統的分類樹中. (如果該分類有子分類，將會顯示在 "Subcategory" 欄中. Each one will be a link that will let the user only view the pages that belong to that subcategory. The resulting drilldown page will include links for all the filters for the top-level category, and links for any subcategories of that subcategory. You can thus use the "View data" page to navigate through an entire category tree.)


 * 篩選器(Filters) - 您能在最頂層的分類頁面中，以手工的方式新增那些建基於語義性質(semantic properties)上的篩選器(filters)，每個篩選器含有著參數條件區而單獨成一行，讓使用設定特定的語意性質的篩選值，以限制篩選結果頁面. 有四種方式可為篩選器設定篩選值：( based on semantic properties can be manually added for any top-level category. Each such filter gets its own row within the constraints area, to let the user limit the results to only those pages that have that value for this semantic property. There are four ways to set the possible values for a filter:)
 * 從列舉(enumeration)項目中取得篩選值 - 如果某篩選器所針對的性質是個列舉項目，則此篩選器可輕易的由其「允許值」中獲得其所需的篩選值. if the property for the filter is an enumeration, the filter can simply use that property's allowed values as its possible values.
 * 在某分類項下的頁面 - 篩選器的值可以是所有(直接於該分類或間接於其子分類項下的)頁面. the filter's values can be all the pages that belong, either directly or through a subcategory, to a category.
 * 依時間期限(By date range) - 篩選結果將依照某特定的時期的時間期限予以區分出來. results are grouped into date ranges, based on a specified time period.
 * 手工設定 - 篩選器的值可以手工的方式予以設定，若是該性質係為數字型態的話，您亦可設定一個數字範圍做為篩選值，而非單一的數字.

那些不符合篩選值條件以致於未能顯示任何探取結果的項目，將會顯示「其他」和「無」. 顯示「其他」的頁面係因那些頁面某性質項目雖無符合所指篩選值，卻至少還有其他的值. 而顯示「無」的頁面項目其性質連值都沒有. (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.)

在經過一些子分類或篩選器的選取動作之後，使用者可在該頁的上方看到一組所選取的篩選條件為何，您可以用點選"x"符號的方式，去除該篩選條件.

參見下方的說明，以了解如何定義篩選器以及如何增設它們於某分類中.

程式碼及下載
You can download the Semantic Drilldown code, in .zip format, here.

You can also download the code directly via Git from the MediaWiki source code repository. From a command line, you can call the following:

To view the code online, including version history for each file, go.

安裝
After you've obtained a 'SemanticDrilldown' directory (either by extracting a compressed file or downloading via Git), place this directory within the main MediaWiki 'extensions' directory. Then, in the file 'LocalSettings.php' in the main MediaWiki directory, add the following line somewhere below the calls for the Semantic MediaWiki extension (both the main 'include_once' line and the 'enableSemantics' line):

You may also wish to change the number value for the new "Filter" namespace, defined in SD_Settings.php; by default it is set to 170.

Also, if you have any custom namespaces declared, you should add the following declaration before the 'include_once' call in the file 'LocalSettings.php':

(Or, instead of 170, whatever number you want the "Filter" namespace set to.)

NOTE: The definition of $sdgNamespaceIndex and the call to SD_Settings.php must be placed after the initialization of any custom namespace definitions in LocalSettings.php. Otherwise, the Filter namespace will not initialize.

NOTE: This extension requires the database account used by MediaWiki to be able to create and drop temporary tables, as well as to create table indexes.

作者
Semantic Drilldown was written by Yaron Koren, reachable at yaron57 -at- gmail.com.

Language files have been contributed by Roc Michael and Ghassem Tofighi.

版本
Semantic Drilldown is currently at version 1.2.5. See the entire version history.

特殊頁面
此外掛定義了3個特殊(special)頁面


 * 查看資料 - 顯示一個鑽取介面用以查看在網站內的資料. (示範頁面)
 * 建立篩選器 - 用以讓使用者建立新的篩選器. (See example of page)
 * 篩選器 - 列出所有在網站內的篩選器. (示範頁面)

程式碼結構
以下是 Semantic Drilldown 插件的目錄及檔案結構：

/includes


 * SD_AppliedFilter.php - 定義 SDAppliedFilter 類別，which represents a filter in conjunction with a value.
 * SD_Filter.inc - defines the class SDFilter, which represents a filter on a single property.
 * SD_GlobalFunctions.php - functions and constants used by the rest of the Semantic Drilldown code.
 * SD_Settings.php - various settings for Semantic Drilldown.

/languages


 * SD_Language.php - 所有語言檔的父類別
 * SD_LanguageDe.php - 德文語言包
 * SD_LanguageEn.php - 英文語言包
 * SD_LanguageFa.php - Persian-language text
 * SD_LanguageZh_cn.php - Mainland-Chinese-language text
 * SD_LanguageZh_tw.php - 台灣正體中文語言包

/skins


 * SD_main.css - Semantic Drilldown 主要的 CSS 檔案

/specials


 * SD_CreateFilter.php - 定義 'CreateFilter' 特殊頁面
 * SD_ViewData.php - 定義 'ViewData' 特殊頁面
 * SD_Filters.php - 定義 'Filters' 特殊頁面

開始使用
Before you set up Semantic Drilldown, you should have all the data structures on your site set up - properties/attributes/relations, categories, templates, and, if you're using them, forms. See the Semantic Forms "Getting started" section for more on how to set these up.

安裝好後，且您的網站內也已有資料，您可採取如下的步驟：


 * 鑽取資料(Drill down through the data) 當您安裝好本外掛後，請前往「查看資料」特殊頁面，查看在您的站台內有那些分類及其結構，這樣便於您了解該如何針對某些分類設定所需之篩選器. (As soon as you've installed Semantic Drilldown, you can go to the "ViewData" special page and see what the category structure looks like on your site. There you can see what filters are needed or would be helpful for each category.)


 * 建立篩選器(Create filters.)目前，在「篩選器」名字空間內，您可以手工的方式，個別的去設定每個鑽取資料所用的篩選器. 而建立篩選器最簡最的方式便是利用建立篩選器此一特殊頁面(請參考上面的章節). ( Every filter you want to be able to drill down with has to be defined separately, on a page in the "Filter:" namespace. The easiest way to create filters is using the 'CreateFilter' special page (see above).


 * 增加某些分類使用的篩選器(Add filters to categories) 增加某些分類使用的篩選器，只要在該分類頁面中加入 設置篩選器::篩選器 :篩選器名稱，篩選器必須只能設於頂層的分類(To add a filter to a category, simply add the tag Has filter::Filter :filter-name to the category's page. Filters should only be added to top-level categories.)

篩選器設定
您可使用的語意標記( semantic tags)如下：(Within the page for each filter, you should place semantic tags that define the filter. The allowed tags are:)


 *   - 唯一的強制性標記，其指定此篩選器可應用於何種的關聯(relation)、屬性(attribute)或性質(property). (The only mandatory tag. Specifies which relation, attribute or property this filter applies to.)
 *   - 指定使用某些分類項下的頁面作為此一篩選器的設定值. States that the possible values for this filter are all the pages that are members of a certain category.
 *   - 為此一分類增加特定的值，您可盡情的設置您所想要的數量的標記. (Adds a specific value allowed for this category. You can add as many such tags as you want to a filter.)
 *   - 用於日期篩選器，(依「月」及「年」選項)指定某時間期限. Used for date filters; indicates the period of time that values are divided into (options are "Month" and "Year").
 *   - 設置此一篩選器的顯示名稱. (Specifies the name of the filter which will be displayed on the screen (optional).)
 * - 當某一篩選器指定了一個「基礎篩選器」時，只有當「基礎篩選器」先行作用完畢後，該篩選器才會作用. States that a filter should only be displayed for users if they have already selected a value from the specified filter.

如果不是非以如下的方式來定義篩選器
 * 1) 以設定「從分類取得篩選值」的方式.
 * 2) 以設定「篩選值」的方式.
 * 3) 以設定「時間期限」的方式.

則此外掛將會列出該性質的所有已存在的值以作為鑽取之依據. (If neither "Gets values from category", "Has value" or "Uses time period" are defined for a filter, the extension will simply list all current values of the property for the given set of pages.)

範例

 * 在Discourse DB網站內有如下相關的原始碼：(Here is the relevant part of the source code for the 'Sources' category page at Discourse DB:)
 * 譯者註：
 * 以下的範例原始碼以中英對照：
 * Discourse DB採用的Semantic mediawiki 不是最新的版本，故有「屬性」(Attribute)，而非最新版所使用的「性質」(property)

此分類使用了這些篩選器 設置篩選器::篩選器:Type, 設置篩選器::篩選器:Circulation 和 設置篩選器::篩選器:Country.

This category uses the filters Has filter::Filter:Type, Has filter::Filter:Circulation and Has filter::Filter:Country.

而以下為此三項相關的篩選器 - Type:

此篩選器涵蓋了性質涵蓋性質::屬性:Publication type.

This filter covers the property Covers property::Attribute:Publication type.

Circulation:

此篩選器涵蓋了性質涵蓋性質::屬性:Has circulation. 它的篩選值為 篩選值:=< 100,000, 篩選值:=100,001 - 250,000, 篩選值:=250,001 - 500,000, 篩選值:=500,001 - 1,000,000 和 篩選值:=> 1,000,000.

This filter covers the property Covers property::Attribute:Has circulation. It has the values Has value:=< 100,000, Has value:=100,001 - 250,000, Has value:=250,001 - 500,000, Has value:=500,001 - 1,000,000 and Has value:=> 1,000,000.

再來看 Country:

此篩選器涵蓋了性質 涵蓋性質::屬性:Is published in country.它的篩選值為 篩選值:=Australia, 篩選值:=Great Britain 和 篩選值:=United States. This filter covers the property Covers property::Attribute:Is published in country. It has the values Has value:=Australia, Has value:=Great Britain and Has value:=United States.

說明：無需去指定「型態」(Type)篩選器的值，是因為其所涵蓋的性質"Publication type"的內容已是由列舉項目組成的. (Note that the "Type" filter doesn't need to specify its own values, because the property it covers, "Publication type", is an enumeration.)

排除某些分類使之不列入鑽取範圍
您也許不想讓某些分類顯示在最頂層的(鑽取條件)分類清單之中，你能以新增一個名為「其他」(或某分類的名稱)的分類頁面，然後將上述不想顯示的分類列為該分類項下的子分類. 如此那些不想顯示的分類就只會在「其他」分類(或某分類的名稱)項目中呈現，而非在最頂層的(鑽取條件)分類清單中呈現.

使用語意鑽取(Semantic Drilldown)的網站
Here are some sites that use Semantic Drilldown in conjunction with Semantic MediaWiki:


 * Discourse DB
 * Verwaltungskooperation - Cooperation in Public Administration

缺陷及需求回報(Bugs and feature requests)
You can submit bug reports and requests for new features at MediaWiki's Bugzilla, here.

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

Contributing patches to the project
If you found some bug and fixed it, or if you wrote code for a new feature, please create a patch by going to the main "SemanticDrilldown" directory, and typing:

svn diff >descriptivename.patch

Then go to the relevant bug report in Bugzilla, or create one if one doesn't exist (note, again, that Bugzilla is used for both bugs and feature requests), and attach this patch file to it.

資助
語意鑽取係由志願性的開發者進行開發，無任何經費，我們歡迎任何的捐款. 您可在此資助此一計畫. (Semantic Drilldown was created and is developed on a strictly volunteer basis, with no funding whatsoever; all donations are welcome. You can donate to the project here.)