Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

Preview:

DESCRIPTION

Part 2 of our semantic wiki tutorial for ASWC 2009. This part is from Yaron Koren.

Citation preview

We have the following statement:

Barcelona is a city in Spain, with population 1,600,0000.

In MediaWiki:

Barcelona is a city in [[Spain]], with population 1,600,0000.

In Semantic MediaWiki:

Barcelona is a city in [[Has country::Spain]], with population [[Has population::1,600,0000]].

This adds to the database the two triples:

Barcelona Has country SpainBarcelona Has population 1,600,0000

On the page is displayed:

Barcelona is a city in Spain, with population 1,600,0000.

In the page "Property:Has country":

[[Has type::Page]]

In the page "Property:Has population":

[[Has type::Number]]

"Has type" is a "special property", i.e. a pre-defined property for meta-data. There are several other special properties.

In a page called "Property:Has priority":

[[Has type::String]]

[[Allows value::Low]], [[Allows value::Medium]], [[Allows value::High]]

Page, String, Text, Number, Date, URL, Email, Geographic coordinate,

Temperature

Shows the set of data defined on a single page

Possible solution:

Barcelona is a [[Is a::city]] in [[Has country::Spain]], with population [[Has population::1,600,0000]].

...this is not done. Instead, category is used:

Barcelona is a city in [[Has country::Spain]], with population [[Has population::1,600,000]].

[[Category::Cities]]

Categories are used for defining class because they allow for inheritance.

Example - a member of category "Cities" would also be a member of category "Locations", if "Cities" is a subcategory of "Locations".

Once the data is stored, we can query it!

Querying is done using the #ask parser function.

To display all the places in Spain:

{{#ask:[[Has country::Spain]]}}

All cities in Spain:

{{#ask:[[Category:Cities]][[Has country::Spain]]}}

Get all cities in Spain with population greater than 1,000,000:

{{#ask: [[Category:Cities]] [[Has country::Spain]] [[Has population::>1,000,000]] }}

A table of cities in Spain with population greater than 1,000,000, that shows both city names and their population:

{{#ask: [[Category:Cities]] [[Has country::Spain]] [[Has population::>1,000,000]] |? Has population}}

Has population Madrid 3200000 Barcelona 1600000

Wikipedia has thousands of category and list pages, that could be replaced by queries

{{#ask:[[Category:Cities]][[Has country::Spain]][[Has population::>1,000,000]]|format=ol}}

This displays a numbered list, i.e. the <ol> tag:

1. Madrid2. Barcelona

list, table, ol, ul, template

Timeline format:

Another extension, "Semantic Maps", exists just for maps

Each page queried must have a property of type "Geographic coordinates".

Another extension, "Semantic Compound Queries" lets you display more than one query at the same time

This is especially useful for maps - each query can get its own icon.

Query formats exist for exporting data in the following formats:

CSV JSON RSS iCalendar vCard BibTeX

Data can also be exported via RDF, RDFa and XML using various extensions.

What if we want to have a page for every city?

Instead of repeating the same text and semantic tags in each page, we can use MediaWiki templates to make the process easier.

In page "Template:City":

{{PAGENAME}} is a city in [[Has country::{{{Country}}}]], with population [[Has population::{{{Population}}}]].

[[Category:Cities]]

In page "Barcelona":

{{City|Country=Spain|Population=1,000,000}}

From “Shanghai” Wikipedia page:

Hide semantic markup from users Allow for a consistent data structure for pages of the same type Pre-define the display

But even editing of template calls might be too hard for most users!

Another extension, Semantic Forms, lets you create forms to edit those template calls

Allow for entering a table of data in a form.

In the page "Category:Cities":

[[Has default form::City]]

(There are other ways, but this is the standard one)

Semantic Forms supports different input types, depending on the type of the property associated with the field.

String, Page, Number – text entry Text – textarea Boolean – checkbox Date – date input or Javascript datepicker “Enumeration” (Page or String with “allowed values”) - dropdown or radiobutton list of "Enumerations" - listbox or checkboxes

Used for properties of type "Geographic coordinates".

support for autocompletion on both single-value and multiple-value fields makes standardizing on names easier, prevents spelling mistakes

Semantic Forms also provides “helper forms”

Certain pieces of information can't be stored using simple semantic triples.

Example: "This cake recipe requires 2 cups of flour".

This data can't be stored as a triple... instead, it requires an "anonymous object":

Cake recipe Requires XX Has quantity 2X Has unit CupX Has ingredient Flour

Defines a function, #set_internal, that creates an “anonymous object”.

In a page called "Cake recipe":

{{#set_internal: Is part of recipe |Has quantity=2 |Has unit=Cup |Has ingredient=Flour }}

{{#ask:[[Is part of recipe::Cake recipe]] |? Has quantity |? Has unit |? Has ingredient}}

Provides a drill-down, “slice-and-dice” interface to semantic data.

Provides a similar slice-and-dice interface, using Javascript

Two ways to use data from the outside:

Import data Query data, keeping it in its original location

“Data Transfer” extension

Allows importing of XML and CSV - will soon support Excel as well

Usually: each row of data is saved as a template call in a separate page

"External Data" extension

Can query the following:

- web pages with data in XML, CSV or JSON format- databases- LDAP servers

Data can be queried and then displayed on the page, or even stored semantically.

Because SMW can export data in CSV and JSON formats, the External Data extension can be used by one SMW wiki to get the data from another one.

semantic-mediawiki.org – Semantic MediaWiki homepage smwforum.ontoprise.com – Ontoprise SMW+ user forum referata.com – Referata – SMW wiki hosting wikiworks.com – (shameless plug!) WikiWorks, an SMW-focused consulting company

Recommended