---
# System prepended metadata

title: Tugas 2 - Jejaring Semantik

---

# Tugas 2 - Jejaring Semantik

**Nama   : Rd Pradipta Gitaya S
NPM    : 170604361**

Berikut ini adalah hasil pekerjaan saya untuk Tugas 2 Jejaring Semantik. Apabila terdapat umpan balik, saya akan merasa sangat senang.

**Tersedia versi online di HackMD:**
https://hackmd.io/@radipz/S1xGZf-qP

**Berkolaborasi dengan:**
- Aziz Fikri Hudaya (1706979184)
- Gregorius Aprisunnea (1706039710)

**Prefix Digunakan**

```
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbp: <http://dbpedia.org/property/>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
```

## **Jawaban Nomor 1**

> The DBPedia SPARQL endpoint hosts more than one named graphs. Find all those named graphs.

Persoalan berikut dapat diselesaikan dengan mengambil semua named graph yang ada pada DBPedia dengan query berikut dengan asumsi *named graph* disini bukanlah *vocabulary* yang termasuk pada spesifik terhadap Entity maupun Class.

```
SELECT DISTINCT ?graph WHERE { 
    GRAPH ?graph {?subject ?predicate ?object} 
} 
```

Berikut adalah keluaran dari kode yang dijalankan (20 baris pertama).

| graph                                       |
|---------------------------------------------|
| http://www.openlinksw.com/schemas/virtrdf#  |
| http://www.w3.org/ns/ldp#                   |
| http://dbpedia.org/sparql                   |
| http://dbpedia.org/DAV/                     |
| http://www.w3.org/2002/07/owl#              |
| file:wikidata_to_schema_mappings.ttl        |
| http://dbpedia.org/schema/property_rules#   |
| dbprdf-label                                |
| http://dbpedia.org/resource/classes#        |
| http://www.ontologyportal.org/SUMO#         |
| http://www.ontologyportal.org/WordNet#      |
| b3sonto                                     |
| b3sifp                                      |
| urn:rules.skos                              |
| http://www.openlinksw.com/schemas/oplweb#   |
| virtrdf-label                               |
| facets                                      |
| urn:virtuoso:val:acl:schema                 |
| http://www.openlinksw.com/virtpivot/icons   |
| http://www.openlinksw.com/schemas/virtpivot |


## **Jawaban Nomor 2**
>DBpedia contains RDFS triples that specify a class hierarchy (those triples whose predicate is rdfs:subClassOf orowl:equivalentClass). Find all classes whose IRI is in the http://dbpedia.org/ontology/ namespace such that these classes appear in at least one triple whose predicate is rdfs:subClassOf or owl:equivalentClass.

Permasalahan ini dapat diselesai dengan menggabungkan query antara rdfs:subClassOf dengan owl:equivalentClass.

```
SELECT ?class WHERE {
    {?class rdfs:subClassOf ?o1 .}
    UNION
    {?class owl:equivalentClass ?o2 .}
}
```

Berikut adalah keluaran dari kode yang dijalankan (20 baris pertama).

| class                                           |
|-------------------------------------------------|
| http://dbpedia.org/ontology/Activity            |
| http://dbpedia.org/ontology/Name                |
| http://dbpedia.org/ontology/Place               |
| http://dbpedia.org/ontology/Language            |
| http://dbpedia.org/ontology/Agent               |
| http://dbpedia.org/ontology/Altitude            |
| http://dbpedia.org/ontology/AnatomicalStructure |
| http://dbpedia.org/ontology/Area                |
| http://dbpedia.org/ontology/Award               |
| http://dbpedia.org/ontology/Biomolecule         |
| http://dbpedia.org/ontology/Blazon              |
| http://dbpedia.org/ontology/ChartsPlacements    |
| http://dbpedia.org/ontology/ChemicalSubstance   |
| http://dbpedia.org/ontology/Colour              |
| http://dbpedia.org/ontology/Currency            |
| http://dbpedia.org/ontology/Demographics        |
| http://dbpedia.org/ontology/Depth               |
| http://dbpedia.org/ontology/Device              |
| http://dbpedia.org/ontology/Diploma             |
| http://dbpedia.org/ontology/Disease             |


## **Jawaban Nomor 3**
> List the name of all airlines which are from Orlando International Airport. If any, also find its destination in English label.


Pada permasalahan ini, saya menggunakan hubungan "airport hubAirport of airline", jadi harus dibalik querynya menjadi :airline :hubAirport :airport . Selain itu, saya **hanya** menemukan daftar tujuan airline dalam bentuk angka, sehingga tidak memungkinkan mengambil dalam tujuan dalam bentuk bahasa inggris.Ini disebabkan karena destinationnya di DBPedia berupa literal, bukan URI.

```
SELECT ?name ?total_destination WHERE {
    {?airline dbo:hubAirport dbr:Orlando_International_Airport .}
    ?airline dbp:destinations ?total_destination .
    ?airline foaf:name ?name
}
```

Berikut adalah keluaran dari kode yang dijalankan.

| name             | total_destination |
|------------------|-------------|
| Delta Express    | 20          |
| AirTran Airways  | 69          |
| Song             | 17          |
| Silver Airways   | 28          |
| ValuJet Airlines | 28          |


## **Jawaban Nomor 4**
>List all companies whose field is either in the entertainment or video game industry and their address.

Pada permasalahan ini, dapat disekukan UNION antara industri yang bergerak dalam Entertainment dan Video Game, kemudian digabungkan dengan lokasinya.

```
SELECT * WHERE {
    {?company dbo:industry dbr:Entertainment .}
    UNION
    {?company dbo:industry dbr:Video_Game .}
    OPTIONAL {?company dbo:location ?location .}
}
```

Berikut adalah keluaran dari kode yang dijalankan (20 baris pertama).

| company                                             |location                                        |
|-----------------------------------------------------|------------------------------------------------|
| http://dbpedia.org/resource/MBO_Cinemas             | http://dbpedia.org/resource/Malaysia           |
| http://dbpedia.org/resource/UltraStar_Cinemas       | http://dbpedia.org/resource/Redlands,_CA       |
| http://dbpedia.org/resource/Les'_Copaque_Production | http://dbpedia.org/resource/Shah_Alam          |
| http://dbpedia.org/resource/Les'_Copaque_Production | http://dbpedia.org/resource/Selangor           |
| http://dbpedia.org/resource/Les'_Copaque_Production | http://dbpedia.org/resource/Malaysia           |
| http://dbpedia.org/resource/19_Entertainment        | http://dbpedia.org/resource/Los_Angeles        |
| http://dbpedia.org/resource/Amuse,_Inc.             | http://dbpedia.org/resource/Japan              |
| http://dbpedia.org/resource/Amuse,_Inc.             | http://dbpedia.org/resource/Shibuya,_Tokyo     |
| http://dbpedia.org/resource/Big_Cinemas             | http://dbpedia.org/resource/Maharashtra        |
| http://dbpedia.org/resource/Big_Cinemas             | http://dbpedia.org/resource/Mumbai             |
| http://dbpedia.org/resource/Cine_Animadores         | http://dbpedia.org/resource/Chile              |
| http://dbpedia.org/resource/GMA_New_Media           | http://dbpedia.org/resource/Philippines        |
| http://dbpedia.org/resource/GMA_New_Media           | http://dbpedia.org/resource/GMA_Network_Center |
| http://dbpedia.org/resource/GMA_New_Media           | http://dbpedia.org/resource/Quezon_City        |
| http://dbpedia.org/resource/Apple_Corps             | http://dbpedia.org/resource/UK                 |
| http://dbpedia.org/resource/Kerasotes_Theatres      | http://dbpedia.org/resource/Chicago,_Illinois  |
| http://dbpedia.org/resource/Van_Houtte              | http://dbpedia.org/resource/Montreal           |
| http://dbpedia.org/resource/Van_Houtte              | http://dbpedia.org/resource/Canada             |
| http://dbpedia.org/resource/Van_Houtte              | http://dbpedia.org/resource/Quebec             |
| http://dbpedia.org/resource/Bwin                    | http://dbpedia.org/resource/Vienna             |


## **Jawaban Nomor 5**
> List all companies which have subsidiaries in the video gaming industry located in Quebec.

Pada persoalan ini, saya memahaminya kasus dimana mencari sebuah perusahaan yang subsidiarynya berada di Quebec dan ia bergerak dalam jenis usaha video gaming.

```
SELECT DISTINCT ?companyname WHERE {
    ?company dbo:subsidiary ?subsidiary .
    ?company foaf:name ?companyname .
    ?subsidiary dbo:location dbr:Quebec .
    ?subsidiary dbo:industry dbr:Video_game_industry .
}
```
Berikut adalah keluaran dari kode yang dijalankan.

| companyname                 |
|-----------------------------|
| Activision Publishing, Inc. |


## **Jawaban Nomor 6**
> List all companies which have subsidiary in United State and founded after 1900

Pada persoalan ini, operasi dilakukan dengan mencari company dan subsidiary nya, kemudian memfilter berdasarkan tahun berdirinya.

```
SELECT DISTINCT ?companyname WHERE{
    ?company dbo:subsidiary ?subsidiary .
    ?company dbo:foundingYear ?company_year .
    ?company foaf:name ?companyname .
    ?subsidiary dbo:location dbr:United_States .
    FILTER (year(xsd:dateTime(?company_year)) > 1900) .
}
```

Berikut adalah keluaran dari kode yang dijalankan (20 baris pertama).

| companyname                      |
|----------------------------------|
| The 3DO Company                  |
| Daimler Trucks North America LLC |
| Columbus Nova                    |
| Perfect World Co., Ltd.          |
| SMS Holdings                     |
| Leadership Dynamics              |
| BellSouth Corporation            |
| Paramount Television             |
| Southern Company                 |
| DineEquity, Inc.                 |
| Focus Brands                     |
| Alticor, Inc.                    |
| Brinker International, Inc.      |
| Green Flash Brewing Co.          |
| Premera Blue Cross               |
| Tempur Sealy International, Inc. |
| Schneider Electric Egypt         |
| Ascena Retail Group Inc.         |
| Energy Transfer Partners         |
| American Motors Corporation      |


## **Jawaban Nomor 7**
> List all products that are developed by the subsidiary of Activision Publishing, Inc. List also the name of product developer companies.

Persoalan ini dapat diselesaikan dengan mengambil data dari subsidiary, kemudian mengambil info produk dari subsidiary, lalu mengambil data developer dari produk.

```
SELECT ?product ?developer WHERE { 
    dbr:Activision dbo:subsidiary ?subsidiary .
    ?subsidiary dbo:product ?product .
    ?product dbp:developer ?developer .
}
```

Berikut adalah keluaran dari kode yang dijalankan (20 baris pertama).

| product                                                 | developer                                      |
|---------------------------------------------------------|------------------------------------------------|
| http://dbpedia.org/resource/Call_of_Duty                | http://dbpedia.org/resource/Infinity_Ward      |
| http://dbpedia.org/resource/Call_of_Duty                | http://dbpedia.org/resource/Sledgehammer_Games |
| http://dbpedia.org/resource/Call_of_Duty                | http://dbpedia.org/resource/Treyarch           |
| http://dbpedia.org/resource/Call_of_Duty                | Primary                                        |
| http://dbpedia.org/resource/Soldier_of_Fortune_(series) | http://dbpedia.org/resource/Raven_Software     |
| http://dbpedia.org/resource/Soldier_of_Fortune_(series) | http://dbpedia.org/resource/Cauldron_HQ        |
| http://dbpedia.org/resource/Guitar_Hero                 | http://dbpedia.org/resource/Neversoft          |
| http://dbpedia.org/resource/Guitar_Hero                 | http://dbpedia.org/resource/FreeStyleGames     |
| http://dbpedia.org/resource/Guitar_Hero                 | http://dbpedia.org/resource/Harmonix           |
| http://dbpedia.org/resource/Guitar_Hero                 | http://dbpedia.org/resource/Budcat_Creations   |
| http://dbpedia.org/resource/Guitar_Hero                 | http://dbpedia.org/resource/Vicarious_Visions  |
| http://dbpedia.org/resource/Skylanders                  | Beenox                                         |
| http://dbpedia.org/resource/Skylanders                  | Toys For Bob                                   |
| http://dbpedia.org/resource/Skylanders                  | n-Space                                        |


## **Jawaban Nomor 8**
>List all multiplayer FPS (first-person shooter) games, developed by any company which is a subsidiary in the United States, that can be played in PS 2 where the games’ names are returned as one literal value (separated by ’ ; ').

```
SELECT (group_concat(?name,' ; ') as ?title) WHERE {
    ?mainCompany dct:subject dbc:Video_game_companies_of_the_United_States .
    ?mainCompany dbo:subsidiary ?subsidiary .

    ?product foaf:name ?name .
    ?product dbp:modes dbr:Multiplayer_video_game .
    ?product dbo:genre dbr:First-person_shooter .
    ?product dct:subject dbc:PlayStation_2_games .
    ?product dbo:developer ?subsidiary .
}
```

Berikut adalah keluaran dari kode yang dijalankan.

| title                                                                                                                                                                                |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Soldier of Fortune ; Turok: Evolution ; Quake III Arena ; 007: Quantum of Solace ; 007: Agent Under Fire ; Call of Duty 2: The Big Red One ; GoldenEye: Rogue Agent ; Call of Duty 3 |


## **Jawaban Nomor 9**
>List the names of all people who won IEEE awards more than once and were born in Southeast Asian countries.

Permasalahan ini dapat diselesaikan dengan menggunakan regex untuk mengambil nama award IEEE, karena nama rewardnya selalu berpola "IEEE" , setelah itu mencari daftar negara di SEA, lalu digabungkan,lalu akhirnya mencari orang yang memiliki award IEEE lebih dari satu.

```
SELECT ?name WHERE {
?winner foaf:name ?name {
SELECT ?winner WHERE { 
    ?winner a dbo:Person .
    ?winner dbo:award ?award .
    ?winner dbo:birthPlace ?country .
    FILTER(regex(?award, "IEEE")) .
    {
        SELECT ?country WHERE
        {
            ?country a dbo:Country .
            ?country dct:subject dbc:Southeast_Asian_countries
        }
    }
}
    GROUP BY ?winner ?name
    HAVING (COUNT(?award) > 1)
    }
}
```

Berikut adalah keluaran dari kode yang dijalankan.

| name           |
|----------------|
| Leon O. Chua   |
| Chai Keong Toh |
  

## **Jawaban Nomor 10**
>List all directors who directed supernatural horror films that are produced by producers who already produced more than 2 movies.

Permasalahan ini dapat diselesaikan dengan menjalankan nested query. Dengan scope luar melakukan pencarian terhadap producer dan scope dalam melakukan pencarian terhadap kriteria producer. Lalu mengembalikan director film sebagai hasil akhir query.

Meskipun begitu, sebenarnya saya **tidak menemukan** film bergenre **supernatural horror**, **melainkan hanya Horror saja**. Hal ini dikarenakan genre tersebut memang tidak ada dalam cakupan dbo:Film apabila melakukan query untuk mengambil semua genre yang termasuk pada dbo:Film. Untuk itu untuk query kali ini saya **menggunakan genre Horror**, dan **bukan Supernatural Horror**.

```
SELECT ?director WHERE {
    ?film a dbo:Film .
    ?film dbo:director ?director .
    ?film dbo:producer ?producer .
    ?film dbo:genre ?genre .
    {
        SELECT ?producer WHERE {
        ?contents dbo:producer ?producer.
    }
    GROUP BY ?producer
    HAVING (COUNT(?contents) > 2)
    }
    FILTER(regex(?genre, "Horror"))
}
```

Berikut adalah keluaran dari kode yang dijalankan.

| director                                             |
|------------------------------------------------------|
| http://dbpedia.org/resource/Martin_Campbell          |
| http://dbpedia.org/resource/Wes_Craven               |
| http://dbpedia.org/resource/E.W._Swackhamer          |
| http://dbpedia.org/resource/Frank_Darabont           |
| http://dbpedia.org/resource/Ray_Patterson_(animator) |


## **Jawaban Nomor 11**
>List all the five oldest actresses who co-starred with Tom Cruise in the movie directed by Paul Thomas Anderson where the actresses’ names are returned as one literal value (separated by ’ ; ').

Permasalahan ini dapat diselesaikan dengan menjalankan nested query, sorting, dan concatenation hasil yang didapatkan.

```
SELECT DISTINCT (group_concat(?name,' ; ') as ?names) WHERE {
    {
        SELECT ?name ?year WHERE
        {
            ?film rdf:type dbo:Film .
            ?film dbo:director dbr:Paul_Thomas_Anderson .
            ?film dbo:starring dbr:Tom_Cruise .
            ?film dbo:starring ?stars .
            ?stars foaf:gender "female"@en .
            ?stars dbo:birthYear ?year.
            ?stars foaf:name ?name .
        }
        ORDER BY ASC(year(xsd:dateTime(?year)))
    }
}
```

Berikut adalah keluaran dari kode yang dijalankan.

| names                                            |
|--------------------------------------------------|
| Melinda Dillon ; Melora Walters ; Julianne Moore |

Hasilnya memang hanya tiga saja, karena film yang directed oleh Paul dan starrring Tom Cruise hanya 1, dan terdiri dari 11 aktor dan 3 aktris.


## **Jawaban Nomor 12**
>Get the actor who co-starred with Tom Cruise in the movie directed by Paul Thomas Anderson and has the biggest age difference with Tom Cruise compared to other actors.

```
SELECT ?actor WHERE {
    ?film rdf:type dbo:Film .
    ?film dbo:director dbr:Paul_Thomas_Anderson .
    ?film dbo:starring dbr:Tom_Cruise .
    ?film dbo:starring ?actors .
    ?actors dbo:birthYear ?year.
    ?actors foaf:name ?actor .
    dbr:Tom_Cruise dbo:birthYear ?tom_bday .
    BIND(abs(?year - ?tom_bday) as ?birthday_diff) .
}
ORDER BY DESC(?birthday_diff)
LIMIT 1
```

Berikut adalah keluaran dari kode yang dijalankan.

| actor         |
|---------------|
| Jason Robards |

Karena yang diminta adalah biggest age difference, berarti saya hanya perlu mengambil satu orang aktor saja dari sekian banyak aktor yang terlibat dalam film itu.
