aswc2009 smw tutorial part 2 froms etc from yaron

68

Upload: jesse-wang

Post on 07-Dec-2014

1.502 views

Category:

Documents


3 download

DESCRIPTION

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

TRANSCRIPT

Page 1: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron
Page 2: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

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.

Page 3: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

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.

Page 4: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

In the page "Property:Has country":

[[Has type::Page]]

In the page "Property:Has population":

[[Has type::Number]]

Page 5: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

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

Page 6: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

In a page called "Property:Has priority":

[[Has type::String]]

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

Page 7: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

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

Temperature

Page 8: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

Shows the set of data defined on a single page

Page 9: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

Possible solution:

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

Page 10: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

...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".

Page 11: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

Once the data is stored, we can query it!

Querying is done using the #ask parser function.

Page 12: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

To display all the places in Spain:

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

All cities in Spain:

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

Page 13: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

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

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

Page 14: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

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}}

Page 15: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

Has population Madrid 3200000 Barcelona 1600000

Page 16: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

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

Page 17: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron
Page 18: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron
Page 19: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

{{#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

Page 20: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

list, table, ol, ul, template

Page 21: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

Timeline format:

Page 22: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron
Page 23: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron
Page 24: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron
Page 25: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

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

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

Page 26: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron
Page 27: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron
Page 28: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

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.

Page 29: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron
Page 30: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

Query formats exist for exporting data in the following formats:

CSV JSON RSS iCalendar vCard BibTeX

Page 31: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

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

Page 32: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

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.

Page 33: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

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}}

Page 34: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

From “Shanghai” Wikipedia page:

Page 35: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron
Page 36: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

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

Page 37: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

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

Page 38: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron
Page 39: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron
Page 40: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron
Page 41: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

Allow for entering a table of data in a form.

Page 42: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

In the page "Category:Cities":

[[Has default form::City]]

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

Page 43: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron
Page 44: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

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

Page 45: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

Used for properties of type "Geographic coordinates".

Page 46: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

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

Page 47: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron
Page 48: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron
Page 49: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

Semantic Forms also provides “helper forms”

Page 50: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron
Page 51: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron
Page 52: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron
Page 53: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron
Page 54: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron
Page 55: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

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

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

Page 56: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

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

Page 57: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

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 }}

Page 58: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

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

Page 59: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

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

Page 60: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron
Page 61: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

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

Page 62: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron
Page 63: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

Two ways to use data from the outside:

Import data Query data, keeping it in its original location

Page 64: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

“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

Page 65: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

"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.

Page 66: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron
Page 67: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

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.

Page 68: Aswc2009 Smw Tutorial Part 2 Froms Etc From Yaron

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