---
# System prepended metadata

title: Milestone 04/01-05/01

---

# Milestone 04/01-05/01


* Which are the goals of this milestone? __Gonçalo__
* What is the semantic web, and where does the “semantics” reside? __Gonçalo__
* __FEITO__ Which ontologies have you found for your domain? __Fábio__
    * What ontology have you adopted and why? (Advantages and drawbacks)
*  __FEITO__ Describe the steps taken to build your ontology: __Susana__
    * relevant classes;
    * object properties and data properties;
    * restrictions based on properties.
* __FEITO__ How have you populated your ontology? (Strategy, tools used…) - __Ana__
* What queries have you implemented? - __Todos__
    * include SPARQL code and results.
* __FEITO__ Evaluate the semantic web tools used. __Susana__
    * which tasks were easier to do? Which where more difficult?
* Discuss the quality of the results. __Subentendido__
* **FEITO** Discuss the advantages and limitations of semantic web tools compared to the previous information retrieval tools, using examples/scenarios considering your domain. __Ana__
* Anticipate applications of the ontology in your domain . __Fábio__



---


1. __FEITO__ Separar Size em Width + Height, atualizar as regras e o .owl __Fábio__
2. __FEITO__ Search  a  painting  for  its  name,  date,  artist,  size,  type,school,  description.  -  Return  a  list  of  paintings  filtered with the desired parameters. __Fábio__
3. __FEITO__ Search  an  artist  for  its  name,  date  and  place  of  birthand death, paintings, biography. - Return a list of artists filtered with the desired parameters. __Fábio__
4. __FEITO?__  Check  the  evolution  of  an  artist’s  paintings’  thematics over time. - Return a list of paintings that belong to an artist  ordered  by  years  when  the  paintings  were  made. This  allows  to  see  the  diversificat ion  in  thematics  over the years of an artist. __Ana__
5. __FEITO?__ Given  an  artist  show  others  related  to  them  by  country,style and/or time.- Return all artists who have somethingin common with a given artist. __Susana__
6. __FEITO__ Given a school show the artists with the most paintings.-Return a list of artists who did more paintings over timeat a given school __Gonçalo__




### Deadline: 28/12
---- 
* Pensar em + queries __TODOS__
* Fazer relatório __TODOS__


### Queries

* 1
```=sparql
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX : <http://www.semanticweb.org/susana/ontologies/2020/11/untitled-ontology-17#>

SELECT ?title
WHERE { 
	?artwork a 	:Artwork ;
		:Title ?title ;
		:Date ?date ;
		:createdBy ?artist ;
		:has ?height, ?width ;
		:isOfType ?type ;
		:isFrom ?school ;
		:Description ?description .
		 ?artist2  a 	:Artist ;
			:Name ?artistName .
		 ?height2 a	:Height ;
			:Size ?heightSize .
		 ?width2 a	:Width ;
			:Size ?widthSize .
		 ?type2 a	:Type ;
			:Name ?typeName .
		 ?school2 a	:School ;
			:Name ?schoolName .
	FILTER (
		(?title = "Adoration of the Magi") &&
		(?date = "1481") &&
		(?artist = ?artist2) && 
		(?artistName = "Leonardo da Vinci") &&
		(?height = ?height2) && 
		(?heightSize = "246") && 
		(?width = ?width2) && 
		(?widthSize = "243") && 
		(?type = ?type2) &&
		(?typeName = "religious") && 
		(?school = ?school2) && 
		(?schoolName = "Italian") &&
		regex(?description, "Early")
	)
}
```

* 2
```=sparql
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX : <http://www.semanticweb.org/susana/ontologies/2020/11/untitled-ontology-17#>

SELECT ?name
WHERE { 
	?artist a 	:Artist ;
		:Name ?name ;
		:Biography ?biography ;
		:wasBornOn ?birthPlace ;
		:diedOn ?deathPlace ;
		:DateOfBirth ?birthDate ;
		:DateOfDeath ?deathDate .
		 ?location2 a	:Location ;
				:Name ?birthLocationName .
		 ?location3 a	:Location ;
				:Name ?deathLocationName .
	{
	    	SELECT ?artist2 ?paintingTitle (group_concat(?paintingTitle;separator="|") as ?paintingTitles)
	    	WHERE {
		 	?paintings a 	:Artwork ;
					:Title ?paintingTitle ;
					:createdBy ?artist2
	  	}
		GROUP BY ?artist2 ?paintingTitle
	}
	FILTER (
		(?name = "Giovanni Bilivert") &&
		(?birthPlace = ?location2) &&
		(?birthLocationName= "Florence") &&
		(?deathPlace = ?location3) &&
		(?deathLocationName= "Florence") &&
		(?birthDate= "1585-08-25") &&
		(?deathDate= "1644-07-16") &&
		regex(?biography, "Italian painter") &&
		(?artist = ?artist2) &&
		regex(?paintingTitles, "The Temptation")
	)
}
```

Check  the  evolution  of  an  artist’s  paintings’  thematics over time. - Return a list of paintings that belong to an artist  ordered  by  years  when  the  paintings  were  made. This  allows  to  see  the  diversification  in  thematics  over the years of an artist.

```=sparql
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX : <http://www.semanticweb.org/susana/ontologies/2020/11/untitled-ontology-17#>

SELECT ?artist ?artwork_title ?type ?date 
WHERE { 
   ?artwork a :Artwork ;
              :Title ?artwork_title ;
              :createdBy ?artist ;
              :isOfType ?type ;
              :Date ?date .
   ?artist a :Artist ;
             :Name ?artist_name .

   FILTER (?artist_name = "Leonardo Da Vinci")
}
ORDER BY ?date 

```
Given  an  artist  show  others  related  to  them  by  country,style and/or time.- Return all artists who have somethingin common with a given artist. 

* related by birth date
```=sparql
SELECT  ?nameRA ?dateOfBirthRA
WHERE
{
	 ?relatedArtist  a :Artist ;
	:DateOfBirth ?dateOfBirthRA;
	:Name ?nameRA;
	{
	    SELECT ?dateOfBirth ?name
	    wHERE {
		 ?art  a :Artist ;
		:DateOfBirth ?dateOfBirth;
		:Name ?name ;
		FILTER (?name = "Maso di Banco")
	  }
	}
	FILTER( ?nameRA != ?name && ?dateOfBirthRA = ?dateOfBirth)
}
```
* related by death date
```=sparql
SELECT  ?nameRA ?dateOfDeathRA
WHERE
{
	 ?relatedArtist  a :Artist ;
	:DateOfDeath ?dateOfDeathRA;
	:Name ?nameRA;
	{
	    SELECT ?dateOfDeath ?name
	    wHERE {
		 ?art  a :Artist ;
		:DateOfDeath ?dateOfDeath;
		:Name ?name ;
		FILTER (?name = "Maso di Banco")
	  }
	}
	FILTER( ?nameRA != ?name && ?dateOfDeathRA = ?dateOfDeath)
}
```
* related by birth place
```=sparql
SELECT  ?nameRA ?birthPlaceRA
WHERE
{
	 ?relatedArtist  a :Artist ;
	:wasBornOn ?birthPlaceRA;
	:Name ?nameRA;
	{
	    SELECT ?birthPlace ?name
	    wHERE {
		 ?art  a :Artist ;
		:wasBornOn ?birthPlace;
		:Name ?name ;
		FILTER (?name = "Maso di Banco")
	  }
	}
	FILTER( ?nameRA != ?name && ?birthPlaceRA = ?birthPlace)
}
```
* related by death place
```=sparql
SELECT  ?nameRA ?deathPlaceRA
WHERE
{
	 ?relatedArtist  a :Artist ;
	:diedOn ?deathPlaceRA;
	:Name ?nameRA;
	{
	    SELECT ?deathPlace ?name
	    wHERE {
		 ?art  a :Artist ;
		:diedOn ?deathPlace;
		:Name ?name ;
		FILTER (?name = "Maso di Banco")

	  }
	}
	FILTER( ?nameRA != ?name && ?deathPlaceRA = ?deathPlace)
}
```
* all
```=sparql
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX : <http://www.semanticweb.org/susana/ontologies/2020/11/untitled-ontology-17#>
SELECT  ?nameRA
WHERE
{
	 ?relatedArtist  a :Artist ;
	:DateOfDeath ?dateOfDeathRA ;
	:DateOfBirth ?dateOfBirthRA;
	:Name ?nameRA;
	:diedOn ?deathPlaceRA;
	:wasBornOn ?birthPlaceRA.
	{
	    SELECT ?name ?dateOfDeath ?dateOfBirth ?deathPlace ?birthPlace
	    wHERE {
		 ?art  a :Artist ;
		:DateOfDeath ?dateOfDeath;
		:DateOfBirth ?dateOfBirth;
		:Name ?name ;
	                  :diedOn ?deathPlace ;
		:wasBornOn ?birthPlace.
		FILTER (?name = "Maso di Banco")
	  }
	}
	FILTER( (?nameRA != ?name) && (?deathPlaceRA = ?deathPlace || ?birthPlaceRA = ?birthPlace ||  ?dateOfBirthRA = ?dateOfBirth || ?dateOfDeathRA = ?dateOfDeath ) )
}
```

Number of artpieces of each type, each year

```=sparql
SELECT ?type ?date (COUNT(?artwork) AS ?nr_artworks)
WHERE { 
   ?artwork a :Artwork . 
   ?artwork :isOfType ?type . 
   ?artwork :Date ?date .
}
GROUP BY ?date ?type
ORDER BY ?date
```


The most common type of artwork each year

```=sparql
SELECT ?type ?date ?max_artworks (COUNT(?artwork) AS ?nr_artworks)
WHERE {
	?artwork a :Artwork . 
	?artwork :isOfType ?type .
   	?artwork :Date ?date .
	{
		SELECT ?date (MAX(?nr_artworks) AS ?max_artworks)
		WHERE { 
			SELECT ?type ?date (COUNT(?art) AS ?nr_artworks)
			WHERE { 
   				?art a :Artwork . 
				?art :isOfType ?type .
   				?art :Date ?date .
			}
			GROUP BY ?date ?type
		}
		GROUP BY ?date 
	} . 
}
GROUP BY ?type ?date ?max_artworks
HAVING (COUNT(?artwork) = ?max_artworks)
ORDER BY ?date
```



The artists with the most paintings each year
```=sparql
SELECT ?artist ?date (COUNT(?artwork) AS ?nr_artworks)
WHERE {
	?artwork a :Artwork . 
	?artist a :Artist .
	?artwork :createdBy ?artist .
   	?artwork :Date ?date .
	{
		SELECT ?date (MAX(?nr_artworks) AS ?max_artworks)
		WHERE { 
			SELECT ?author ?date (COUNT(?art) AS ?nr_artworks)
			WHERE { 
   				?art a :Artwork . 
				?author a :Artist .
				?art :createdBy ?author .
   				?art :Date ?date .
			}
			GROUP BY ?date ?author
		}
		GROUP BY ?date 
	} . 
}
GROUP BY ?artist ?date ?max_artworks
HAVING (COUNT(?artwork) = ?max_artworks)
ORDER BY ?date
```

__5__ Given a school show the artists with the most paintings.-Return a list of artists who did more paintings over time at a given school

```=sparql
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX : <http://www.semanticweb.org/susana/ontologies/2020/11/untitled-ontology-17#>

SELECT ?year ( str(?max_artworks1) as ?max_artworks) ?artist WHERE {

{
    SELECT ?year ?artist  (MAX(?nr_artworks1) as ?max_artworks1) WHERE {
    SELECT ?artist (COUNT(?artwork1) as ?nr_artworks1) ?year
        WHERE {
            ?artwork1 a :Artwork;
            :Date ?year;
            :isFrom ?school1;
            :createdBy ?artist .
            ?school1 a :School; 
            :Name ?schoolName1
            FILTER (
                ?schoolName1 = "Italian"
            )
        }
    GROUP BY ?year ?artist
    ORDER BY DESC(?nr_artworks1)
    }

    GROUP BY ?year ?artist
    ORDER BY DESC(?year)
}

{
    SELECT ?date2  (MAX(?nr_artworks2) as ?max_artworks2) WHERE {
    SELECT ?artist2 (COUNT(?artwork2) as ?nr_artworks2) ?date2
    WHERE {
        ?artwork2 a :Artwork;
        :Date ?date2;
        :isFrom ?school2;
        :createdBy ?artist2 .
        ?school2 a :School; 
        :Name ?schoolName2
        FILTER (
            ?schoolName2 = "Italian"
        )
    }
    GROUP BY ?date2 ?artist2
    ORDER BY DESC(?nr_artworks2)
    }

    GROUP BY ?date2
    ORDER BY DESC(?date2)
}

    FILTER (
        (?year = ?date2) &&
        (?max_artworks1 = ?max_artworks2)
    )

}
    ORDER BY DESC(?year)
	
```

### Data imports

In order to efficiently import data from excel the"Create axioms from Excel workbook" tool was used and several rules were created following the [MappingMasterDSL](https://github.com/protegeproject/mapping-master/wiki/MappingMasterDSL) rules.

* **Artists**
    Individual: @D*
    Types: Artist
    Facts: Name @D*

* **Type**
    Individual: @L*
    Types: Type
    Facts: Name @L*
    
* **Materials**
    Individual: @G*
    Types: Material
    Facts: Name @G*
    
* **Tecnhiques**
    Individual: @F*
    Types: Technique
    Facts: Name @F*
    
* **School**
    Individual: @M*
    Types: School
    Facts: Name @M*
    
* **Artwork**:
    Individual: @E*
    Types: Artwork
    Facts: Title @E*, Description @B*, Timeframe @I*, createdBy @D*, createdWith @F*, isA @L*, isFrom @M*, uses @gregueiras *



## Entrega 11/12/2020

### Task 1

After some research some web ontologies related to art were found.

The one that most relates to our is *Towards an Ontology for Art and Colours* [1] in which an ontology was made for a subset of art. It built a repository of knowledge and information about artists, their works, the movements they were a part of, their works and materials used in artistic creations. 

The image below shows the main classes taken into account and how they're correlated. All the classes except one, Colour, are very similar to the ones defined in task 2. 

![](https://i.imgur.com/inx5bm4.jpg)

Other related ontologies were found like _Multilingual Online Generation from Semantic Web
Ontologies_ [3] which focus on how artistic creations are defined in different languages and _Evaluation of Semantic Web Ontologies for Modelling
Art Collections_ [2] which evaluates the most common Cultural Heritage ontologies.

[1] Luciana Bordoni and Tiziana Mazzoli, _Towards an Ontology for Art and Colours_, http://www.lrec-conf.org/proceedings/lrec2006/pdf/151_pdf.pdf
[2] Danfeng Liu, Antonis Bikakis and Andreas Vlachidis, _Evaluation of Semantic Web Ontologies for Modelling Art Collections_, https://discovery.ucl.ac.uk/id/eprint/1574307/1/SW4CH(paper3_cr).pdf
[3] Dana Dannélls, Mariana Damova, Ramona Enache and Milen Chechev, _Multilingual Online Generation from Semantic Web Ontologies_, https://www.molto-project.eu/sites/default/files/wwweu2012_submission_16-final.pdf



### Task 2
* Classes hierarchy
![](https://i.imgur.com/LcWwrT6.png)

* Object property hierarchy
![](https://i.imgur.com/pti2pik.png)

* Data property hierarchy
![](https://i.imgur.com/FFqEMS8.png)

* Individual 'Mona Lisa'
* ![](https://i.imgur.com/45TIccr.png)


* Visualize ontology: http://owlgred.lumii.lv/online_visualization/1ezn

* Ontology file: 




## Melhorias Milestone 2

* 1 Influenced by Peter Rubens' work -AUTHOR:"Peter Paul Rubens"
* 2 A (sacred monument | Church | Mosque | Chapel | Cathedral) in the forefront
* 3 virgin mary's portraits
    * retratos, 
* 4 horses racing | a horse race
* 5 dancing in a ball
    * main focus: gente dançando


* 1 None
* 2 Stopwords
* 3 English possessive and lower case
* 4 Stem

| Indexing | Time (s) | Size     | Query | Time |
| -------- | -------- | -------- | ----- | ---- |
| 1        | 9.502    | 46.01 MB | 1     | 19   |
|          | 9.115    |          | 2     | 17   |
|          | 8.865    |          | 3     | 5    |
|          | 9.913    |          | 4     | 11   |
|          | 9.911    |          | 5     | 8    |
| 2        | 10.457   | 40.88 MB | 1     | 8    |
|          | 10.010   |          | 2     | 3    |
|          | 10.594   |          | 3     | 2    |
|          | 9.443    |          | 4     | 2    |
|          | 9.816    |          | 5     | 4    |
| 3        | 9.703    | 40.44 MB | 1     | 40   |
|          | 9.443    |          | 2     | 25   |
|          | 10.353   |          | 3     | 12   |
|          | 10.022   |          | 4     | 12   |
|          | 9.396    |          | 5     | 5    |
| 4        | 11.041   | 39.72 MB | 1     | 11   |
|          | 10.352   |          | 2     | 1    |
|          | 10.912   |          | 3     | 5    |
|          | 9.881    |          | 4     | 4    |
|          | 10.589   |          | 5     | 4    |
