Difference between revisions of "Help:SMWAddExtensions"
(Extensions -> MediaWiki Extensions) |
|||
(9 intermediate revisions by 3 users not shown) | |||
Line 33: | Line 33: | ||
===Why are Internal Objects needed?=== | ===Why are Internal Objects needed?=== | ||
− | In most cases we assign one value to a given property per page, e.g. the population to a page on a country, or the name of a journal to a publication page. In some cases we want to assign more than one value for a given property on the same page. E.g. the publication page [[Environmental Entomology (2008) 37 (2), 391-399]] deals with different host | + | In most cases we assign one value to a given property per page, e.g. the population to a page on a country, or the name of a journal to a publication page. In some cases we want to assign more than one value for a given property on the same page. E.g. the publication page [[Environmental Entomology (2008) 37 (2), 391-399]] deals with different host plants of the whitefly ''Bemisia tabci'' (collard, cowpea, cantaloupe and watermelon). If we have the properties called [[Property:Publication on pest]] and [[Property:Pest host]] we can assign the whitefly and its host plants to these properties in order to generate on a different page a list of publications dealing with host plants of ''Bemisia tabaci''. Thus on the above publication page we would use: |
<pre> | <pre> | ||
− | [[Publication on pest::Bemisia tabaci]], [[Pest host::collard]] | + | [[Publication on pest::Bemisia tabaci]], [[Pest host::collard]], |
+ | [[Pest host::cowpea]], [[Pest host::cantaloupe]] and [[Pest host::watermelon]] | ||
</pre> | </pre> | ||
− | However, with this method we cannot define specific relationships between different properties on the same page. E.g. | + | However, with this method we cannot define specific relationships between different properties on the same page. E.g. the publication might deal with different pests, each having different host plants, or as in this example, the study is done in several locations and we also want to define the different pest-hosts-location relationships and display them in subsequent queries. For such a task we would use the "internal objects. |
+ | ===Defining internal objects=== | ||
+ | We use the #set_internal function to define the different relationships between pest, host plants and locations. For the above example we would have 4 assignments in the page [[Environmental Entomology (2008) 37 (2), 391-399]]: | ||
+ | <pre> | ||
+ | {{#set_internal: Pest record|Publication on pest=Bemisia tabaci|Pest host=collard|Pest distribution=U.S.A. (SE)}} | ||
+ | {{#set_internal: Pest record|Publication on pest=Bemisia tabaci|Pest host=cowpea|Pest distribution=U.S.A. (SE)}} | ||
+ | {{#set_internal: Pest record|Publication on pest=Bemisia tabaci|Pest host=cantaloupe|Pest distribution=U.S.A. (SW)}} | ||
+ | {{#set_internal: Pest record|Publication on pest=Bemisia tabaci|Pest host=watermelon|Pest distribution=U.S.A. (SW)}} | ||
+ | </pre> | ||
+ | corresponding to the following 4 relationships | ||
+ | {| class="wikitable" | ||
+ | ! Pest !! Host plant !! Location | ||
+ | |- | ||
+ | | Bemisia tabaci | ||
+ | | collard | ||
+ | | U.S.A. (SE) | ||
+ | |- | ||
+ | | Bemisia tabaci | ||
+ | | cowpea | ||
+ | | U.S.A. (SE) | ||
+ | |- | ||
+ | | Bemisia tabaci | ||
+ | | cantaloupe | ||
+ | | U.S.A. (SW) | ||
+ | |- | ||
+ | | Bemisia tabaci | ||
+ | | watermelon | ||
+ | | U.S.A. (SW) | ||
+ | |} | ||
+ | Click on an "edit" or "view" tab in the page [[Environmental Entomology (2008) 37 (2), 391-399]] to see the internal object assignments at the bottom of that page. In the page itself there is no display of the internal objects. | ||
+ | ===Querying internal objects=== | ||
+ | For querying internal objects, we can use the normal #ask function. The query: | ||
+ | <pre> | ||
{{#ask:[[Pest record::+]][[Publication on pest::Bemisia tabaci]] | {{#ask:[[Pest record::+]][[Publication on pest::Bemisia tabaci]] | ||
|mainlabel=- | |mainlabel=- | ||
|?Pest host=Host plant | |?Pest host=Host plant | ||
|?Pest distribution=Distribution | |?Pest distribution=Distribution | ||
− | |?=Publication | + | |?Pest record=Publication |
+ | |sort=Pest host, Pest distribution | ||
+ | }} | ||
+ | </pre> | ||
+ | gives us the following sortable table on the host plants and locations of the whitefly ''Bemisia tabaci'': | ||
+ | {{#ask:[[Pest record::+]][[Publication on pest::Bemisia tabaci]] | ||
+ | |mainlabel=- | ||
+ | |?Pest host=Host plant | ||
+ | |?Pest distribution=Distribution | ||
+ | |?Pest record=Publication | ||
|sort=Pest host, Pest distribution | |sort=Pest host, Pest distribution | ||
}} | }} | ||
+ | ==SemanticMediaWiki Writer (SMWWRiter) extension== | ||
+ | |||
+ | This extension should perform two actions: | ||
+ | #Return the semantic properties from a wiki page | ||
+ | #Allows to modify (insert/remove) a semantic property from wiki pages. | ||
+ | For details, see: [http://semantic-mediawiki.org/wiki/Help:SMWWriter SMWWriter]. | ||
+ | The extension requires a pre-installed [http://semantic-mediawiki.org/wiki/Help:PageObjectModel PageObjectModel] extension. | ||
+ | In order to enable it in wiki, the following steps will be follow: | ||
+ | * check the accompanying README file for any new information | ||
+ | * add the following line to your MediaWiki's '''LocalSettings.php''' (after you included SMW): | ||
+ | |||
+ | include_once("$IP/extensions/PageObjectModel/PageObjectModel.php"); | ||
+ | include_once("$IP/extensions/SMWWriter/SMWWriter.php"); | ||
+ | |||
+ | The extension can be used internally and externally as well, exposing an API as web service. | ||
+ | * smwwriter - requires a POST action (since you ask the wiki to change resources). It takes the following parameters: | ||
+ | <pre style="white-space:pre-wrap;"> | ||
+ | title: Title of the page to modify | ||
+ | token: Edit token. You can get one of these through prop=info | ||
+ | add: Annotations to add. The format is like simple wiki annotations, i.e. <nowiki>[[property::value]]</nowiki> | ||
+ | remove: Annotations to remove. The format is like simple wiki annotations, i.e. <nowiki>[[property::value]]</nowiki>. If value is '*' then all values of that property will be removed. If remove is '*', then all annotations will be removed. If remove is empty, then content simply gets added and no metadata is removed | ||
+ | flags: Flags for the edit process. The following flags exist: ATOMIC_CHANGE, CHANGE_TEXT, EDIT_MINOR, IGNORE_CONSTANT. The flags are described below. The flags are connected with the | symbol | ||
+ | summary: Edit summary for the change history | ||
+ | </pre> | ||
+ | * smwwritable | ||
+ | offers a list of all metadata on a page that SMWWriter can change. smwwritable only has a single parameter: | ||
+ | title: Title of the page | ||
+ | Testing the last action '''smwwritable''', several mentions would be worth to be pointed out: | ||
+ | * the extension doesn't return semantic properties inside the templates. Instead of this, the normal MediaWiki API should be used with: | ||
+ | action=raw&templates=expand, to parse the content of the page and retrieve the semantic properties. | ||
+ | * the extension returns all the semantic properties normal used on the page and even the silant ones (#set parser function). | ||
[[Category:Help]] | [[Category:Help]] | ||
− | [[Category:Extensions]] | + | [[Category: MediaWiki Extensions]] |
+ | [[Category:Semantic Mediawiki]] |
Latest revision as of 21:25, 13 November 2017
Help sections |
---|
Contents · Semantic MediaWiki · Semantic Forms |
Add Ontology · Semantic links and import/export features · Import external vocabulary |
Other SemanticMW extensions · Other extensions |
This section gives some guidance on, and provides examples for using other Semantic Mediawiki (Semantic MW) extensions. Basic features of the Semantic MW and the Semantic Forms extension are explained separately (see the box on help sections above). All SemanticMW extensions described here require prior installation of the basic Semantic Mediawiki components.
Contents
Semantic Drilldown extension
For more detailed descriptions of this extension see the Semantic Drilldown website. For installation notes see Semantic Drilldown.
Introduction
Semantic Drilldown is very useful for browsing and filtering the semantic data entered into a wiki. As with other SemanticMW features, Semantic Drilldown is closely linked to the category system of a wiki and Semantic Drilldown can only work through a specific category. As an example we explain here the different steps for modifying the Category:Publications to enable specific filter options.
Defining filters
- Create the page Filter:Journal by typing this name into the search box.
- The filter page basically needs only a statement on which property the filter is based in the form "[[Covers property::Property:Publication journal]]". However, you might want to add also some explanationary text.
- Create another filter for the property Publication year.
Adding filter definitions to a category
We now add these 2 filters to the page Category:Publications. For this we need statements like "[[Has filter::Filter:Journal]]".
Using Semantic Drilldown
Got to the "Semantic Drilldown" section of the Special:SpecialPages and select Browse data. In the top right of this page you find a box with the different categories of this wiki, sorted alphabetically. The first category on this list has been selected. Since most categories do not contain any filters, most "browse pages" do not look differently from the normal category pages. Select the category Publications. On the top of this page you can now click on different journals and publication years. The Drilldown system then filters out the category pages according to your selections. Of course, the Drilldown system is especially useful if many data have been entered into system.
Semantic Result Formats
The Semantic Result Formats extension adds several features for displaying query results with semantic data in different formats, e.g. a graphical format. For a detailed description of this extension see the Semantic Result Formats website. For installation notes see Semantic Result Formats.
The use of these features is very simple, just use the line "format=<format type>" together with the #ask function. The following examples demonstrate some of the format types:
- Displaying data in a graph (Google bar).
- Displaying sums or averages of a data set.
- Ordering data according to semantic properties.
Semantic Internal Objects
For more detailed descriptions of this extension see the Semantic Internal Objects website. For installation notes see Semantic Internal Objects.
Why are Internal Objects needed?
In most cases we assign one value to a given property per page, e.g. the population to a page on a country, or the name of a journal to a publication page. In some cases we want to assign more than one value for a given property on the same page. E.g. the publication page Environmental Entomology (2008) 37 (2), 391-399 deals with different host plants of the whitefly Bemisia tabci (collard, cowpea, cantaloupe and watermelon). If we have the properties called Property:Publication on pest and Property:Pest host we can assign the whitefly and its host plants to these properties in order to generate on a different page a list of publications dealing with host plants of Bemisia tabaci. Thus on the above publication page we would use:
[[Publication on pest::Bemisia tabaci]], [[Pest host::collard]], [[Pest host::cowpea]], [[Pest host::cantaloupe]] and [[Pest host::watermelon]]
However, with this method we cannot define specific relationships between different properties on the same page. E.g. the publication might deal with different pests, each having different host plants, or as in this example, the study is done in several locations and we also want to define the different pest-hosts-location relationships and display them in subsequent queries. For such a task we would use the "internal objects.
Defining internal objects
We use the #set_internal function to define the different relationships between pest, host plants and locations. For the above example we would have 4 assignments in the page Environmental Entomology (2008) 37 (2), 391-399:
{{#set_internal: Pest record|Publication on pest=Bemisia tabaci|Pest host=collard|Pest distribution=U.S.A. (SE)}} {{#set_internal: Pest record|Publication on pest=Bemisia tabaci|Pest host=cowpea|Pest distribution=U.S.A. (SE)}} {{#set_internal: Pest record|Publication on pest=Bemisia tabaci|Pest host=cantaloupe|Pest distribution=U.S.A. (SW)}} {{#set_internal: Pest record|Publication on pest=Bemisia tabaci|Pest host=watermelon|Pest distribution=U.S.A. (SW)}}
corresponding to the following 4 relationships
Pest | Host plant | Location |
---|---|---|
Bemisia tabaci | collard | U.S.A. (SE) |
Bemisia tabaci | cowpea | U.S.A. (SE) |
Bemisia tabaci | cantaloupe | U.S.A. (SW) |
Bemisia tabaci | watermelon | U.S.A. (SW) |
Click on an "edit" or "view" tab in the page Environmental Entomology (2008) 37 (2), 391-399 to see the internal object assignments at the bottom of that page. In the page itself there is no display of the internal objects.
Querying internal objects
For querying internal objects, we can use the normal #ask function. The query:
{{#ask:[[Pest record::+]][[Publication on pest::Bemisia tabaci]] |mainlabel=- |?Pest host=Host plant |?Pest distribution=Distribution |?Pest record=Publication |sort=Pest host, Pest distribution }}
gives us the following sortable table on the host plants and locations of the whitefly Bemisia tabaci:
Host plant | Distribution | Publication |
---|---|---|
cantaloupe | U.S.A. (SW) | Environmental Entomology (2008) 37 (2), 391-399 |
collard | U.S.A. (SE) | Environmental Entomology (2008) 37 (2), 391-399 |
cotton | U.S.A. (SW) | Environmental Entomology (2008) 37 (6), 1514-1524 |
cowpea | U.S.A. (SE) | Environmental Entomology (2008) 37 (2), 391-399 |
squash | U.S.A. (Hawaii) | Environmental Entomology (2009) 38 (2), 442-449 |
watermelon | U.S.A. (SW) | Environmental Entomology (2008) 37 (2), 391-399 |
SemanticMediaWiki Writer (SMWWRiter) extension
This extension should perform two actions:
- Return the semantic properties from a wiki page
- Allows to modify (insert/remove) a semantic property from wiki pages.
For details, see: SMWWriter. The extension requires a pre-installed PageObjectModel extension. In order to enable it in wiki, the following steps will be follow:
- check the accompanying README file for any new information
- add the following line to your MediaWiki's LocalSettings.php (after you included SMW):
include_once("$IP/extensions/PageObjectModel/PageObjectModel.php"); include_once("$IP/extensions/SMWWriter/SMWWriter.php");
The extension can be used internally and externally as well, exposing an API as web service.
- smwwriter - requires a POST action (since you ask the wiki to change resources). It takes the following parameters:
title: Title of the page to modify token: Edit token. You can get one of these through prop=info add: Annotations to add. The format is like simple wiki annotations, i.e. [[property::value]] remove: Annotations to remove. The format is like simple wiki annotations, i.e. [[property::value]]. If value is '*' then all values of that property will be removed. If remove is '*', then all annotations will be removed. If remove is empty, then content simply gets added and no metadata is removed flags: Flags for the edit process. The following flags exist: ATOMIC_CHANGE, CHANGE_TEXT, EDIT_MINOR, IGNORE_CONSTANT. The flags are described below. The flags are connected with the | symbol summary: Edit summary for the change history
- smwwritable
offers a list of all metadata on a page that SMWWriter can change. smwwritable only has a single parameter:
title: Title of the page
Testing the last action smwwritable, several mentions would be worth to be pointed out:
- the extension doesn't return semantic properties inside the templates. Instead of this, the normal MediaWiki API should be used with:
action=raw&templates=expand, to parse the content of the page and retrieve the semantic properties.
- the extension returns all the semantic properties normal used on the page and even the silant ones (#set parser function).