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系統的分類樹中. (if the category has any subcategories, those will show up in a "Subcategory" row. 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 either one of these two compressed files:


 * 這裡下載

You can also download the code directly via SVN from the MediaWiki source code repository, at http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/SemanticDrilldown/. From a command line, you can call the following:

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

安裝
After you've obtained a 'SemanticDrilldown' directory (either by extracting a compressed file or downloading via SVN), 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):

如果您想更改「篩選器」(Filter)的名字空間(其內定值為170). 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.

如果您的wiki已有許多自訂的名字空間請先在'LocalSettings.php'內，設定'include_once'本外掛的該行之前，使用如下的設定.

您也可指定其他的名字空間，而非 170.

注意：此設定須設於自訂名字空間設定之後.

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.

作者
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 0.2.1.

The version history is:
 * 0.1 - December 10, 2007 - Initial version
 * 0.2 - December 17, 2007 - 'CreateFilter' page added; improved property lookup for SMW 1.0; Persian-language support added; small bug fixes.
 * 0.2.1 - December 20, 2007 - Added "Uses time period" and "Requires filter" properties; header includes link to category; German-language support added

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


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

程式碼結構
The following are the directories and files in the Semantic Drilldown extension:

/includes


 * SD_AppliedFilter.php - defines the class 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 - parent class for all language files
 * SD_LanguageDe.php - German-language text
 * SD_LanguageEn.php - English-language text
 * SD_LanguageFa.php - Persian-language text
 * SD_LanguageZh_cn.php - Mainland-Chinese-language text
 * SD_LanguageZh_tw.php - Taiwanese-Chinese-language text

/skins


 * SD_main.css - main CSS file for Semantic Drilldown

/specials


 * SD_CreateFilter.php - defines the 'CreateFilter' special page
 * SD_ViewData.php - defines the 'ViewData' special page
 * SD_Filters.php - defines the 'Filters' special page

開始使用
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.

如果不是以「從分類取得篩選值」，也不是以「篩選值」的方式來定義「篩選器」，此外掛將會假設該性質為一列舉型態的性質，從而使用該性質的「允許值」. (If neither "Gets values from category" nor "Has value" are defined for a filter, the extension will assume that the property for this filter is an enumeration, and get its values from that property's "allowed values".)

範例

 * 在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.)