This shows you the differences between two versions of the page.
docs:plwiki2 [2017/09/19 14:31] |
docs:plwiki2 [2022/03/23 16:59] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== PlWiki 2.0 functionality ====== | ||
+ | |||
+ | Functionalities added in the extended version of PlWiki can be divided into four parts: | ||
+ | - Support for Semantic MediaWiki syntax and functionality | ||
+ | - Debugging functions | ||
+ | - Exporting pages to RDF | ||
+ | - Support for SPARQL queries | ||
+ | |||
+ | Each of these functionalities are described in details below. | ||
+ | |||
+ | |||
+ | ===== Support for SMW functionality ===== | ||
+ | |||
+ | ==== Special pages ==== | ||
+ | |||
+ | Special pages are pages containing metadata informations, | ||
+ | * [[special: | ||
+ | * [[special: | ||
+ | * [[special: | ||
+ | |||
+ | Apart from those, PlWiki also supports special pages describing properties, eg. '' | ||
+ | |||
+ | Each property (including categories) can be a subproperty of another property of the same type (eg. a relation cannot be a subproperty of an attribute). This is set on the subproperty' | ||
+ | * for categories: | ||
+ | <code smw> | ||
+ | Category is a subcategory of [[category: | ||
+ | </ | ||
+ | * for relations: | ||
+ | <code smw> | ||
+ | Relation is a subrelation of [[subrelation of:: | ||
+ | </ | ||
+ | * for attributes: | ||
+ | <code smw> | ||
+ | Attribute is a subattribute of [[subattribute of: | ||
+ | </ | ||
+ | * for compatibility with SMW syntax, relations and attributes can use the construction '' | ||
+ | <code smw> | ||
+ | Property is a [[subproperty of:: | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== Defining semantic data ==== | ||
+ | |||
+ | The second version of PlWiki contains improved processing of semantic annotations on wiki pages. | ||
+ | Firstly, it is now possible to assign one value to multiple relations or attributes in one annotation, thus: | ||
+ | <code smw> | ||
+ | Warsaw is the capital city of [[capital of::located in:: | ||
+ | | ||
+ | </ | ||
+ | |||
+ | The other new functionality allows users to decide, how an annotation should be displayed on the page. It is done by defining an alternative text for the annotation using the pipe symbol ('' | ||
+ | If no alternative text is specified, the annotation value (default text) is displayed. If the alternative text is a single space, no value is displayed. For example, code: | ||
+ | <code smw> | ||
+ | Warsaw is located in [[located in:: | ||
+ | It's inhabited by about [[population: | ||
+ | [[page created: | ||
+ | </ | ||
+ | will be displayed as: | ||
+ | < | ||
+ | Warsaw is located in Poland. It's inhabited by about 1.8 mln people. | ||
+ | </ | ||
+ | |||
+ | All attributes are displayed as plain text, relations as links to the related page and categories as links to the selected category' | ||
+ | |||
+ | ==== Ask queries ==== | ||
+ | |||
+ | In the earlier versions of PlWiki a very limited support for Ask queries was available. Now the PlWiki supports almost full functionality of SMW Ask queries. | ||
+ | |||
+ | Each query consists of two main parts: conditions for selecting pages and display options. | ||
+ | |||
+ | The ' | ||
+ | |||
+ | * Wildcards | ||
+ | A wildcard constitutes any value of a property. For example, query: | ||
+ | <code smw> | ||
+ | {{#ask: [[located in::+]] }} | ||
+ | </ | ||
+ | will return all pages which have any value of the relation '' | ||
+ | * comparators | ||
+ | Comparators are supported in relations and attributes. | ||
+ | There are three comparators defined in PlWiki: "''>''", | ||
+ | Comparators are used directly before the annotation value: | ||
+ | <code smw> | ||
+ | {{#ask: [[population: | ||
+ | </ | ||
+ | NOTE: all comparisons in PlWiki are done alphabetically, | ||
+ | * disjunction of search conditions | ||
+ | Disjunction in a query can be used on two levels: as a disjuntion of conditions (keyword '' | ||
+ | <code smw> | ||
+ | {{#ask:: [[category: | ||
+ | </ | ||
+ | * subqueries | ||
+ | Subqueries are used to find the values of a search conditions. It is most useful if the value is not known or if a set of values is needed. Subqueries' | ||
+ | <code smw> | ||
+ | {{#ask: [[located in::< | ||
+ | </ | ||
+ | * property chains | ||
+ | Property chains are a kind of simple subqueries. They are defined using "'' | ||
+ | <code smw> | ||
+ | {{#ask: [[capital of.located in.located in:: | ||
+ | </ | ||
+ | * support for property hierarchy | ||
+ | Setting a property value in a condition will also cause all the pages which has it's subproperty set to the same value to be displayed. For example, a query searching for all four-limbed animals will return all four-legged cats as well as all four-armed apes - assuming, that the attributes '' | ||
+ | |||
+ | |||
+ | The second part of a query are the display options. Options are defined in the second, third and following arguments of the query (first argument being the conditions for selecting pages). Query arguments are separated by the pipe sign ('' | ||
+ | Optional arguments can consist of two types of data: columns to be displayed and additional options. | ||
+ | |||
+ | Users can specify which columns (which properties' | ||
+ | <code smw> | ||
+ | {{#ask: [[category: | ||
+ | | ?located in }} | ||
+ | </ | ||
+ | Column names can also be specified: | ||
+ | <code smw> | ||
+ | {{#ask: [[category: | ||
+ | | ?located in=Localisation }} | ||
+ | </ | ||
+ | For categories, a specific category name can be selected to single out pages belonging to the given category. If the page belongs to the selected category, an "'' | ||
+ | <code smw> | ||
+ | {{#ask: [[located in: | ||
+ | | ? | ||
+ | | ? | ||
+ | </ | ||
+ | |||
+ | The other kind of optional arguments of Ask queries are additional options. PlWiki supports most of the options used in Semantic MediaWiki. Those options are: | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | All these options and functionalities can be mixed. Here is an example of an ASK query in PlWiki: | ||
+ | <code smw> | ||
+ | {{#ask: [[category: | ||
+ | [[located in.member of:: | ||
+ | [[localisation of::< | ||
+ | | ? | ||
+ | | intro=Top five most populated university towns in the EU: | ||
+ | | sort=population | ||
+ | | order=descending | ||
+ | | limit=5 | ||
+ | | format=ol | ||
+ | }} | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Debug functions ===== | ||
+ | |||
+ | ==== STDERR redirection ==== | ||
+ | |||
+ | Redirection of the standard error stream in PlWiki allows to display or save error messages generated by the SWI-Prolog engine. This is set in the "'' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | Example use: | ||
+ | <code plwiki> | ||
+ | <pl goal=" | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== Tracing predicates ==== | ||
+ | |||
+ | PlWiki uses the non-interactive version of Prolog '' | ||
+ | <code plwiki> | ||
+ | <pl scope=" | ||
+ | trace=" | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== RDF export ===== | ||
+ | |||
+ | Every PlWiki page can be exported to an RDF/XML file. This is done by opening the page in the "'' | ||
+ | |||
+ | The generated RDF/XML file consists of three main parts. The first part contains description of the exported page. The second part contains optional related pages' data. This data includes descriptions of pages related to the exported page (determined by the wiki_relation predicate). The number of levels of related pagesto be exported (default one - only the selected page is exported) is set by the PlWiki "'' | ||
+ | |||
+ | |||
+ | ===== SPARQL queries ===== | ||
+ | |||
+ | PlWiki supports a limited version of SPARQL. SELECT, ASK and DESCRIBE queries are supported. Full wiki semantic data is always used as datasource. Datatypes are not supported - every literal is a string. Only normal wiki pages can be queried, special pages and ontology data (including ontology hierarchy) aren't included in the query. | ||
+ | |||
+ | SPARQL queries are written between PlWiki prolog tags, with the tag's "'' | ||
+ | |||
+ | ==== SELECT queries ==== | ||
+ | |||
+ | SELECT queries consost of the following elements: | ||
+ | * PREFIX declarations - a prefix can be ser to an empty URI. | ||
+ | * selection of columns to be displayed in the result table | ||
+ | * optional WHERE statement. it can include the OPTIONAL block and the FILTER element. | ||
+ | * additional options: ORDER BY, LIMIT, OFFSET. | ||
+ | The result of a SELECT query is displayed as an HTML table. | ||
+ | |||
+ | The following functions and operators can be used in the FILTER element: | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | Example query: | ||
+ | < | ||
+ | <pl format=" | ||
+ | PREFIX wiki: <> | ||
+ | SELECT ?city ?population ?area ?location | ||
+ | WHERE { | ||
+ | ?city a " | ||
+ | wiki: | ||
+ | wiki:area ?area ; | ||
+ | wiki: | ||
+ | OPTIONAL { | ||
+ | ?city wiki: | ||
+ | ? | ||
+ | } . | ||
+ | FILTER ( ?area <= "001 000 km^2" && isLiteral(? | ||
+ | } | ||
+ | ORDER BY DESC(? | ||
+ | LIMIT 10 | ||
+ | </pl> | ||
+ | </ | ||
+ | |||
+ | This query will return the names, population, area and location countries of 10 most populated cities twinned with Warsaw, which area is at most 1 000 km^2. | ||
+ | |||
+ | |||
+ | ==== ASK queries ==== | ||
+ | |||
+ | ASK queries determine whether a result exists. It returns either "'' | ||
+ | |||
+ | <code plwiki> | ||
+ | <pl format=" | ||
+ | PREFIX wiki: <> | ||
+ | ASK { | ||
+ | ?city a " | ||
+ | wiki: | ||
+ | wiki: | ||
+ | FILTER ( ?population > "001 000 000 km^2" ) | ||
+ | } | ||
+ | </pl> | ||
+ | </ | ||
+ | |||
+ | This query will return the answer to the question: "Are there any cities twinned with Warsaw and populated by over one million citizens?" | ||
+ | |||
+ | ==== DESCRIBE queries ==== | ||
+ | |||
+ | DESCRIBE queries return all semantic informations about pages complying with the query criteria, written in TURTLE format. ORDER BY, LIMIT and OFFSET do not apply. Example query: | ||
+ | |||
+ | < | ||
+ | <pl format=" | ||
+ | PREFIX wiki: <> | ||
+ | DESCRIBE ?city | ||
+ | WHERE { | ||
+ | ?city a " | ||
+ | wiki: | ||
+ | } | ||
+ | </pl> | ||
+ | </ | ||