===== Semantic wikis ===== * Last verification: **20220909** * Tools required for this lab: * [[https://loki.re/smw/|Demo instance of the Semantic MediaWiki]] ==== Prepare yourself for the lab ==== * [[https://www.semantic-mediawiki.org/wiki/SMWCon_Fall_2017/Introduction_to_Semantic_MediaWiki|Introduction to Semantic MediaWiki]] (slides) ==== Lab instructions ==== Today we will be developing a simple semantic wiki called "Media Base" that will contain information about books, movies or music CDs. \\ A semantic wiki is a [[wp>wiki|wiki]] with the ability to model knowledge in the form of (RDF-like) triples. \\ We will be using the popular Semantic MediaWiki system. Note: :!: Your tasks start with the exclamation mark. - :!: To begin, create an account in a dedicated instance of the wiki: https://loki.re/smw/ - Use the "Request account" link in top right corner. Provide a valid e-mail. - The teacher will confirm your account and you will get an e-mail with a password. - Media Base is primarily a wiki, so it allows you to create pages using simple markup: * :!: Open the page [[https://loki.re/smw/User:[login] ]] (place your login instead of the ''[login]'' placeholder) -- you can also click your name in top right corner of the wiki page * :!: To start, write a short piece of information about yourself: together with whom you have done previous Semantic Internet projects (link her/his wiki page), what is your favourite book, movie and CD, do you expect the Spanish Inquisition, etc. * Useful documentation about markup used in the MediaWiki: [[https://www.mediawiki.org/wiki/Help:Formatting|Formatting]] (you can take a look at "Other formatting" section for more details about links, pictures, etc) - It is a **semantic** wiki, i.e., it is possible to enter subject-predicate-object triples using dedicated markup: * In wikis: **the subject is always the page you are on**. * We can create three types of annotations: * **Categories** -- to create a hierarchy, grouping wiki pages together, e.g., by entering ''[[Category:Person]]'' on your page, you create the ''[user] -> Category -> Person'' triple. * **Object properties** -- relationships to other wiki pages: to the user viewing the page they look like ordinary links, but carry additional information about the meaning of the link, e.g.: ''[[User:kkutt]]'' vs ''[[Works with::User:kkutt]]'' -- both look the same (they are links to the ''User:kkutt'' page), but the latter additionally stores information about the name of this relation which forms a triple: [user] -> ''Works with'' -> ''User:kkutt'' * **Data properties** -- relationships to literals (strings, numbers, etc.), compare: ''I am Wojtek and I am 12 years old'' and ''I am [[Name::Wojtek]] and I am [[Age::12]] years old'' * Note: yes, your confusion is correct -- creating Object properties and Data properties looks exactly the same. How does the system distinguish that one is a page and the other is a literal? In the wiki, we have the ability to define types -- we can define, for example, the fact that Age is a number, which is then used when processing annotations (displaying, sorting results, etc.).: * See the source of the [[https://loki.re/smw/Property:Age|Property:Age]] -- we have created another triple here! ''Property:Age -> Has type -> Number''! * Types are also used to validate the correctness of the data entered, e.g., inserting the ''[[Age::years]]'' into a page will result in a yellow exclamation mark (when the page is saved) and a corresponding warning. * To show a nice box with all semantic information, write ''__SHOWFACTBOX__'' somewhere at your page. * You can read more about annotations in [[https://www.semantic-mediawiki.org/wiki/Help:In-text_annotation|In-text annotation]]. \\ There is also a dedicated documentation for [[https://www.semantic-mediawiki.org/wiki/Help:Property_declaration|Property declaration]]. * :!: Now add annotations of each of the three types to your page! * :!: You can also create new properties and define their types if you need. * :!: You can add new pages, by simply entering specific URLs, e.g., open the page [[https://loki.re/smw/Book:XYZ]] to create a page about XYZ book. - The existing knowledge base **can be processed**: * To begin with: we can create lists that are always up-to-date (updated when the page is refreshed) - which solves the problem with Wikipedia that we saw in the first class. * :!: Using the examples in the [[https://www.semantic-mediawiki.org/wiki/Help:Inline_queries|Inline queries]], create a simple ''#ask'' query on your page that will display all people (instances of ''Person'' category) and their ''Age''. * We can put each piece of information only ONE time, and refer to it later (because we can easily pull it out). This can even be invisible to a user reading the wiki (until they glance at the page source). * :!: On your page, add the sentence ''I remind you that that I am {{#show: [FIXME]}} years old!'' - replace ''[FIXME]'' with the appropriate code to display the Age value that is entered somewhere else on your page. Use the [[https://www.semantic-mediawiki.org/wiki/Help:Inline_queries#Parser_function_.23show|documentation]]. * This allows you to easily extract more complex information, combine data from different sources (whether incorporating external data into pages in the wiki, or making the knowledge contained in the wiki available to the outside world via the SPARQL Endpoint), or exporting the knowledge base to CSV/JSON/etc. - :!: If you have time, add more wiki pages (with annotations!) and define more properties to execute more complex queries! * You can also get some inspiration from [[https://www.semantic-mediawiki.org/wiki/Category:Sample_pages|sample pages]] provided by Semantic MediaWiki. * You can also do some experiments with the [[https://www.semantic-mediawiki.org/wiki/Help:Concepts|Concepts]] (defined by the specific ''#ask'' queries) === Learn more! ==== General readings: * Systematic review of Semantic Wikis: [[https://doi.org/10.1007/978-3-642-33158-9_9|Semantic Wikis: Approaches, Applications, and Perspectives (2012)]] Existing systems: * [[https://www.semantic-mediawiki.org/|Semantic MediaWiki]] * [[https://www.d3web.de/|KnowWE]] * [[https://ontowiki.net/|OntoWiki]] * [[https://loki.re|Loki]]