diff --git a/.gitignore b/.gitignore
index 9c07d4a..4980aac 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,9 @@
*.class
*.log
+target/
+bin/
+.project
+.classpath
+.settings/
+.cache-main
+.cache-tests
diff --git a/README.md b/README.md
index 27f0966..8be53e1 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,28 @@
-# daf-semantics
-Daf Semantics repository
+
+daf-semantics
+====================
+
+The Daf Semantics repository collects some different components, designed for integrating ontologies, RDF data and to provide some different "semantic" functionalities to the [DAF](https://github.com/italia/daf) platform.
+
+The [semantic_manager]() component exposes the central access point for a subset of the microservices' functionalities:
+
+
+The planned components are:
+
++ [***semantic_frontend***](https://github.com/seralf/daf-semantics/tree/master/semantic_frontend):
+the front end for the OntoPA catalog [TODO]
++ [***semantic_manager***](https://github.com/seralf/daf-semantics/tree/master/semantic_manager):
+the main interface between DAF and the daf-semantics microservices [WIP]
++ [***ontonethub***](https://github.com/seralf/teamdigitale/ontonethub):
+a component providing indexing/search capabilities for the catalog [WIP]
++ [***semantic_repository***](https://github.com/seralf/daf-semantics/tree/master/semantic_repository):
+an abstraction over different triplestores [WIP]
++ [***semantic_validator***](https://github.com/seralf/daf-semantics/tree/master/semantic_validator):
+a component for validating an ontology over DCAT-AP_IT standard [WIP]
++ [***semantic_standardization***](https://github.com/seralf/daf-semantics/tree/master/semantic_standardization):
+a component exposing vocabulary data and hierarchies, useful for simple standardization [POC]
++ [***semantic_spreadsheet***](https://github.com/seralf/daf-semantics/tree/master/semantic_spreadsheet):
+a repository collecting recipes for creating RDF data from spreadsheets, using google refine [WIP]
++ [***semantic_mapping***](#):
+a component for mapping of incoming data (typically in CSV) to RDF, using W3C standards [TODO]
+
diff --git a/docs/semantic_manager-v4.png b/docs/semantic_manager-v4.png
new file mode 100644
index 0000000..9bf5fd2
Binary files /dev/null and b/docs/semantic_manager-v4.png differ
diff --git a/docs/semantic_manager-v4.xml b/docs/semantic_manager-v4.xml
new file mode 100644
index 0000000..83e5ec4
--- /dev/null
+++ b/docs/semantic_manager-v4.xml
@@ -0,0 +1 @@
+7Vtbd6I6FP41PtolRNA+9ubMOauzZk4765zpY4SImQJxhVjt/PqzgYRbIrUWtTf7UNiEEPa3v30DeugiWn/heDH/xnwS9uyBv+6hy55tW7Y1hH+p5DGXOKdWLgg49eWgUnBL/xApHEjpkvokqQ0UjIWCLupCj8Ux8URNhjlnq/qwGQvrV13ggGiCWw+HuvQ/6ot5Lh3bo1L+ldBgrq5suaf5kSn27gPOlrG8Xs9Gs+yXH46wmkveaDLHPltVROiqhy44YyLfitYXJEx1q9SWnzfZcLRYNyex2OYEWy5DPKpbJz5oQu4yLuYsYDEOr0rpeXZ7JJ1gAHtzEYWwacEmXJM//pLybOcu3TlxYDcRmIuzFBoQxSwmSjahYVic4jdGgKRy/DcR4lEaC14KBqJyhdeMLeQ6EsHZPblgIePZPaFh9iuOKEjTsbrCpA4TtuSe1Im0ZlhuQNQoCWCqrsp5UstfCIsI3D8M4CTEgj7UDQtL+wyKcSVGsCFhMkOGPiHbDbLx0RBzOoVsTcWvAqR0764JpqWD6eNkns1mvQSV8+zPiMqMxcI0cle0kH0suORiHnC4lJPekgjHgnog/YZjcP5cA3Q1p4LcLnB2RyuIinXQcLLI49SMrlMYGvAWYWBg0rqb/TSt2+m8IQ1i2PZAu7AqgAG4Vzl15qR/bTA8EC7IulXD8qiNpM+TQd1y5f6qEiKlaF6Jjkr2DEzY9HeqLnsQ4ikJVSjNJsH5HgXtrWkcgAgMD244yOcrUHQq9yIBfnUucxoy7/7nnMY1v/kihk4mCH5GW6m5AOVF1HZ+DyPHYEJjj3jetkweG0Kl1TWT5ak/GI1FaZ+OCo3KPlHD8PJ1yrNK2wM08GNl2CIdkGy+josa1xk3cqwnxg+HTsP08xWURCh0YuIG7Ep6mN2Xq7mvjVypEAJ8gKjbOScJ/YOn2YDUbqVaYLRz3nMuTc4n9SUUsugzeSCivp+RKaPxeZEbV60rz45N1uVscFBF2i8XV0udTY6rD4ZtIWmZLzSyUQ3K/mn9fDabJUT0mo6tFU8NwNE+soU6z22nxZHZmier+qmqO7P27s5emgaa3BE6VmIx1pj5HegYE/F1OT1oQtGiVY3THSQOyG04THtviYOm89NWMskQ/Uz2tJFHy7XfdBWlqtwaf45WR6nVmDPzG7JgCRUsndMN02A2hTTdDURxsx+DXYWaDsAuldpVEWGhXh2Bwhbppo8FTgCi1MSfgOAVa3zUSDSHBo2PDBofdaHx9o7dtg6tpXlQ8W93hcLfsg9DBh/WeUmyNX5IZ4zA8ZSF79lHjVTQOEIGoJ5FfITq/8VccXSuDI9GFVUAllS5ZlBd6uH9e17VUpLokUdTRAVMFZaidZA+xzqZhWzlzQGwk2gZCtr3mbeMMn0Zo1UL4TQSbYaqA3qNm40PR2fXWGeX2wW73CPEo/edYNudF6gb+mVO3WxQ0WOVU+SL0vplO7Q0rG57Gm+i9mrpxG5nGgfpXezWAR01Sg7niQ5oY7x6crBjB1Q3L72zMiM+4aACFh+5GmwxAy1I1Iy3g7gwbOJ0yNLwVE90f5zd/HOtaX+n1jMwMclJWc1ZQzJLp2r2oUXK0vMEAKZx8DOjbL+j0Os0VYx0FbsGFdsdqLh4iaQTr/r2s9fiVaHXkL3aemvkhkRMkM/09Yn01R4cLn1VKU8FpQfKxZIlTMfi9TSxug8U9focGerzfXW0bL0jcnM5Gf6t84TG/QgoxPWnl68Img7QQO4R0WjvlnzWc89P2pWP2Xs9N2jUc4Pt3n/QJhqOG/bX9LTdFYao2+acsr6K7TUe1725V+NsQ0vueO/G2XpPrvII7l/whuCCGf/YT+BMz4P2VWYZXir4jJ41NJwDPp1D7RXZZ/R8vq/r/rXtDUHPakRPa7ug9+REGs03hOFdome33wI8+2WX7E2xQ0bM7eqeqkkhQ0/geB8C6D2BCeORKVrmEp8+KNFfcUCSaj8TLlY5/J7jqyp/irz2YNFVJVrmdGfCwUzBdX4g3e8xtYHd8ru33BmWHxeiq/8B
\ No newline at end of file
diff --git a/semantic_manager/app/generated_controllers/semantic_manager.yaml.scala b/semantic_manager/app/generated_controllers/semantic_manager.yaml.scala
index 0f10f2d..375ab4f 100644
--- a/semantic_manager/app/generated_controllers/semantic_manager.yaml.scala
+++ b/semantic_manager/app/generated_controllers/semantic_manager.yaml.scala
@@ -17,6 +17,15 @@ import scala.util._
import javax.inject._
+import play.api.mvc.{Action,Controller}
+import play.api.data.validation.Constraint
+import play.api.i18n.MessagesApi
+import play.api.inject.{ApplicationLifecycle,ConfigurationProvider}
+import de.zalando.play.controllers._
+import PlayBodyParsing._
+import PlayValidations._
+import scala.util._
+import javax.inject._
import play.api.libs.ws.WSClient
import utilities.JSONHelper
import scala.concurrent.ExecutionContext.Implicits._
@@ -40,6 +49,9 @@ import OntonetHubClient.models._
import OntonetHubClient.models._
import OntonetHubClient.models._
import OntonetHubClient.models._
+import OntonetHubClient.models._
+import OntonetHubClient.models._
+import OntonetHubClient.models._
/**
* This controller is re-generated after each change in the specification.
@@ -48,7 +60,7 @@ import OntonetHubClient.models._
package semantic_manager.yaml {
// ----- Start of unmanaged code area for package Semantic_managerYaml
-
+
// ----- End of unmanaged code area for package Semantic_managerYaml
class Semantic_managerYaml @Inject() (
// ----- Start of unmanaged code area for injections Semantic_managerYaml
diff --git a/semantic_repository/app/generated_controllers/semantic_repository.yaml.scala b/semantic_repository/app/generated_controllers/semantic_repository.yaml.scala
index 5045d0a..4127242 100644
--- a/semantic_repository/app/generated_controllers/semantic_repository.yaml.scala
+++ b/semantic_repository/app/generated_controllers/semantic_repository.yaml.scala
@@ -317,7 +317,7 @@ import java.net.URI
package semantic_repository.yaml {
// ----- Start of unmanaged code area for package Semantic_repositoryYaml
-
+
// ----- End of unmanaged code area for package Semantic_repositoryYaml
class Semantic_repositoryYaml @Inject() (
// ----- Start of unmanaged code area for injections Semantic_repositoryYaml
diff --git a/semantic_standardization/README.md b/semantic_standardization/README.md
index 02abab1..0eb6c00 100644
--- a/semantic_standardization/README.md
+++ b/semantic_standardization/README.md
@@ -12,10 +12,111 @@ Two endpoints are provided:
The idea is that each endpoint (and its configured queries) acts for a very specific domain, so the next versions could introduce new vocabularies and ontologies, but needs to create ad-hoc SPARQL queries for retrieving the informations needed.
+## semantic annotation in DAF ingestion
-## example: retrieving a vocabulary dataset
+The [DAF](https://github.com/italia/daf) `semantic_annotation` has currently the following structure: `{ontology}.{concept}.{property}`.
+During the ingestion phase of datasets in DAF platform a `semantic_annotation` is used, in order to relate some column of a dataset to the most appropriate property of a given existing concept, from the controlled vocabularies.
+
+**Note** that while the annotation is used to relate cells with vocabularies, it does not save explicitly a reference to the vocabularies used. A reference to concept from an ontology is used instead.
+
+
+## examples
+
+
+### example: sequence of calls
+
+1. retrieves (vocabulary,ontology) reference from semantic_annotation tag
+```
+curl -X GET http://localhost:9000/kb/v1/daf/annotation/lookup?semantic_annotation=POI-AP_IT.PointOfInterestCategory.POIcategoryIdentifier -H "accept: application/json" -H "content-type: application/json"
+```
+
+2. retrieves the hierarchies for a given property
+```
+curl -X GET http://localhost:9000/kb/v1/hierarchies/properties?vocabulary_name=POICategoryClassification&ontology_name=poiapit&lang=it -H "accept: application/json" -H "content-type: application/json"
+```
+
+3. retrieves the dataset values for a certain vocaulary
+```
+curl -X GET http://localhost:9000/kb/v1/vocabularies/POICategoryClassification?lang=it -H "accept: application/json" -H "content-type: application/json"
+```
+
+----
+
+### example: retrieves informations from the semantic_annotation tag
+With this endpoint we can retrieve informations about the vocabulary/ontology pair related to a given `semantic_annotation` tag:
+
+```
+curl -X GET http://localhost:9000/kb/v1/daf/annotation/lookup?semantic_annotation={semantic_annotation} \
+-H "accept: application/json" -H "content-type: application/json"
+```
+
+for example, for the Point Of Interest vocabulary:
+
+```
+curl -X GET 'http://localhost:9000/kb/v1/daf/annotation/lookup?semantic_annotation=POI-AP_IT.PointOfInterestCategory.POIcategoryIdentifier' \
+-H "accept: application/json" -H "content-type: application/json"
+```
+
+This will return a datastructure similar to the following one for each tag:
+
+```
+[
+ {
+ "vocabulary_id": "POICategoryClassification",
+ "vocabulary": "http://dati.gov.it/onto/controlledvocabulary/POICategoryClassification",
+ "ontology": "http://dati.gov.it/onto/poiapit",
+ "semantic_annotation": "POI-AP_IT.PointOfInterestCategory.POIcategoryIdentifier",
+ "property_id": "POIcategoryIdentifier",
+ "concept_id": "PointOfInterestCategory",
+ "ontology_prefix": "poiapit",
+ "ontology_id": "POI-AP_IT",
+ "concept": "http://dati.gov.it/onto/poiapit#PointOfInterestCategory",
+ "property": "http://dati.gov.it/onto/poiapit#POIcategoryIdentifier"
+ }
+]
+```
+
+the idea is to be able to have as much informations as possible to eventually relate the annotation to ontologies and vocabularies.
+
+
+### example: retrieving a vocabulary dataset
We can obtain a de-normalized, tabular version of the vocabulary `Istat-Classificazione-08-Territorio` using the curl call:
+
+```
+curl -X GET http://localhost:9000/kb/v1/hierarchies/properties?vocabulary_name={vocabulary_name}&ontology_name={ontology_prefix}&lang={lang} \
+-H "accept: application/json" -H "content-type: application/json"
+```
+
+A `SPARQL` query is used to create a proper tabular representation of the data.
+
+#### example: PontOfInterest / POI_AP-IT
+
+```
+curl -X GET http://localhost:9000/kb/v1/hierarchies/properties?vocabulary_name=POICategoryClassification&ontology_name=poiapit&lang=it -H "accept: application/json" -H "content-type: application/json"
+```
+
+this will return a data structure:
+
+```
+[
+ {
+ "vocabulary": "POI-AP_IT",
+ "path": "POI-AP_IT.PointOfInterestCategory.definition",
+ "hierarchy_flat": "PointOfInterestCategory",
+ "hierarchy": [
+ {
+ "class": "PointOfInterestCategory",
+ "level": 0
+ }
+ ]
+ },
+ ...
+]
+```
+
+
+#### example: Luoghi Istat / CLV_AP-IT
```
$ curl -X GET "http://localhost:9000/kb/v1/vocabularies/Istat-Classificazione-08-Territorio?lang=it" -H "accept: application/json" -H "content-type: application/json"
```
@@ -39,12 +140,52 @@ this will return a result structure similar to the following one:
]
```
-## example: retrieve th hierarchies for the properties used
+For technical reason, currently a value of `CLV-AP_IT_Region_name` is used in place of `CLV-AP_IT.Region.name`.
+
+### example: retrieve the hierarchies for the properties used
If we have the example vocabulary `Istat-Classificazione-08-Territorio`, which uses terms from the ontology `clvapit`, we can retrieve the local hierarchy associated to each property with the curl command:
```
-$ curl -X GET http://localhost:9000/kb/v1/hierarchies/properties?vocabulary_name=Istat-Classificazione-08-Territorio&ontology_name=clvapit&lang=it -H "accept: application/json" -H "content-type: application/json"
+$ curl -X GET http://localhost:9000/kb/v1/hierarchies/properties?vocabulary_name={vocabulary_name}&ontology_name={ontology_prefix}&lang={lang} \
+-H "accept: application/json" -H "content-type: application/json"
+```
+
+#### example: POI / POI_AP-IT
+
+```
+curl -X GET http://localhost:9000/kb/v1/vocabularies/POICategoryClassification?lang=it \
+-H "accept: application/json" -H "content-type: application/json"
+```
+
+which will return results:
+
+```
+[
+ [
+ {
+ "key": "POI-AP_IT_PointOfInterestCategory_definition",
+ "value": "Rientrano in questa categoria tutti i punti di interesse connessi all'intrattenimento come zoo, discoteche, pub, teatri, acquari, stadi, casino, parchi divertimenti, ecc."
+ },
+ {
+ "key": "POI-AP_IT_PointOfInterestCategory_POICategoryName",
+ "value": "Settore intrattenimento"
+ },
+ {
+ "key": "POI-AP_IT_PointOfInterestCategory_POICategoryIdentifier",
+ "value": "cat_1"
+ }
+ ],
+ ...
+]
+```
+
+
+#### example: Luoghi Istat / CLV_AP-IT
+
+```
+$ curl -X GET http://localhost:9000/kb/v1/hierarchies/properties?vocabulary_name=Istat-Classificazione-08-Territorio&ontology_name=clvapit&lang=it \
+-H "accept: application/json" -H "content-type: application/json"
```
which will return the results:
@@ -68,7 +209,7 @@ which will return the results:
```
-## example configurations
+### example configurations
An example configuration for working with a vocabulary (VocabularyAPI):
@@ -122,8 +263,13 @@ Eventually the idea of pre-loading ontologies and vocabularies from disk can be
----
-TODO:
+## TODO
+ more documentation / comments
+ more proper tests
-+ remove redundant classes for RDFRepository, importing external kb-core dependency, instead
\ No newline at end of file
++ remove redundant classes for RDFRepository, importing external kb-core dependency, instead
+
+
+## known ISSUES
+
+...
diff --git a/semantic_standardization/app/generated_controllers/semantic_standardization.yaml.scala b/semantic_standardization/app/generated_controllers/semantic_standardization.yaml.scala
index c13894d..532ae7a 100644
--- a/semantic_standardization/app/generated_controllers/semantic_standardization.yaml.scala
+++ b/semantic_standardization/app/generated_controllers/semantic_standardization.yaml.scala
@@ -1,11 +1,11 @@
-import play.api.mvc.{ Action, Controller }
+import play.api.mvc.{Action,Controller}
import play.api.data.validation.Constraint
import play.api.i18n.MessagesApi
-import play.api.inject.{ ApplicationLifecycle, ConfigurationProvider }
+import play.api.inject.{ApplicationLifecycle,ConfigurationProvider}
import de.zalando.play.controllers._
@@ -17,10 +17,74 @@ import scala.util._
import javax.inject._
+import play.api.mvc.{Action,Controller}
+import play.api.data.validation.Constraint
+import play.api.i18n.MessagesApi
+import play.api.inject.{ApplicationLifecycle,ConfigurationProvider}
+import de.zalando.play.controllers._
+import PlayBodyParsing._
+import PlayValidations._
+import scala.util._
+import javax.inject._
+import play.api.mvc.{Action,Controller}
+import play.api.data.validation.Constraint
+import play.api.i18n.MessagesApi
+import play.api.inject.{ApplicationLifecycle,ConfigurationProvider}
+import de.zalando.play.controllers._
+import PlayBodyParsing._
+import PlayValidations._
+import scala.util._
+import javax.inject._
+import play.api.mvc.{Action,Controller}
+import play.api.data.validation.Constraint
+import play.api.i18n.MessagesApi
+import play.api.inject.{ApplicationLifecycle,ConfigurationProvider}
+import de.zalando.play.controllers._
+import PlayBodyParsing._
+import PlayValidations._
+import scala.util._
+import javax.inject._
+import play.api.mvc.{Action,Controller}
+import play.api.data.validation.Constraint
+import play.api.i18n.MessagesApi
+import play.api.inject.{ApplicationLifecycle,ConfigurationProvider}
+import de.zalando.play.controllers._
+import PlayBodyParsing._
+import PlayValidations._
+import scala.util._
+import javax.inject._
+import play.api.mvc.{Action,Controller}
+import play.api.data.validation.Constraint
+import play.api.i18n.MessagesApi
+import play.api.inject.{ApplicationLifecycle,ConfigurationProvider}
+import de.zalando.play.controllers._
+import PlayBodyParsing._
+import PlayValidations._
+import scala.util._
+import javax.inject._
+import play.api.mvc.{Action,Controller}
+import play.api.data.validation.Constraint
+import play.api.i18n.MessagesApi
+import play.api.inject.{ApplicationLifecycle,ConfigurationProvider}
+import de.zalando.play.controllers._
+import PlayBodyParsing._
+import PlayValidations._
+import scala.util._
+import javax.inject._
+import play.api.mvc.{Action,Controller}
+import play.api.data.validation.Constraint
+import play.api.i18n.MessagesApi
+import play.api.inject.{ApplicationLifecycle,ConfigurationProvider}
+import de.zalando.play.controllers._
+import PlayBodyParsing._
+import PlayValidations._
+import scala.util._
+import javax.inject._
import java.io.File
import modules.KBModuleBase
import play.api.libs.ws.WSClient
import play.api.libs.concurrent.Execution.Implicits.defaultContext
+import semantic_standardization.yaml.SemanticAnnotationInfo
/**
* This controller is re-generated after each change in the specification.
@@ -28,33 +92,59 @@ import play.api.libs.concurrent.Execution.Implicits.defaultContext
*/
package semantic_standardization.yaml {
- // ----- Start of unmanaged code area for package Semantic_standardizationYaml
-
- // ----- End of unmanaged code area for package Semantic_standardizationYaml
- class Semantic_standardizationYaml @Inject() (
- // ----- Start of unmanaged code area for injections Semantic_standardizationYaml
+ // ----- Start of unmanaged code area for package Semantic_standardizationYaml
+
+ // ----- End of unmanaged code area for package Semantic_standardizationYaml
+ class Semantic_standardizationYaml @Inject() (
+ // ----- Start of unmanaged code area for injections Semantic_standardizationYaml
kb: KBModuleBase,
ws: WSClient,
- // ----- End of unmanaged code area for injections Semantic_standardizationYaml
- val messagesApi: MessagesApi,
- lifecycle: ApplicationLifecycle,
- config: ConfigurationProvider) extends Semantic_standardizationYamlBase {
- // ----- Start of unmanaged code area for constructor Semantic_standardizationYaml
+ // ----- End of unmanaged code area for injections Semantic_standardizationYaml
+ val messagesApi: MessagesApi,
+ lifecycle: ApplicationLifecycle,
+ config: ConfigurationProvider
+ ) extends Semantic_standardizationYamlBase {
+ // ----- Start of unmanaged code area for constructor Semantic_standardizationYaml
// wrapper for triplestore
val kbrepo = kb.kbrepo
- // ----- End of unmanaged code area for constructor Semantic_standardizationYaml
- val propertiesHierarchyList = propertiesHierarchyListAction { input: (String, String, String) =>
- val (vocabulary_name, ontology_name, lang) = input
- // ----- Start of unmanaged code area for action Semantic_standardizationYaml.propertiesHierarchyList
- val parameters = Map("lang" -> lang)
+ // ----- End of unmanaged code area for constructor Semantic_standardizationYaml
+ val semanticAnnotationLookup = semanticAnnotationLookupAction { (semantic_annotation: String) =>
+ // ----- Start of unmanaged code area for action Semantic_standardizationYaml.semanticAnnotationLookup
+ val infos = kb.annotation_api.lookup(semantic_annotation).get
+ .map { info =>
+ SemanticAnnotationInfo(
+ info.get("vocabulary_id").get.toString(),
+ info.get("vocabulary").get.toString(),
+ info.get("ontology").get.toString(),
+ info.get("semantic_annotation").get.toString(),
+ info.get("property_id").get.toString(),
+ info.get("concept_id").get.toString(),
+ info.get("ontology_prefix").get.toString(),
+ info.get("ontology_id").get.toString(),
+ info.get("concept").get.toString(),
+ info.get("property").get.toString())
+ }
+
+ SemanticAnnotationLookup200(infos)
+ .recoverWith {
+ case ex: Throwable =>
+ SemanticAnnotationLookup500(Error(s"problems retrieving informations from semantic_annotation: ${semantic_annotation}", ex.getMessage))
+ }
+ // ----- End of unmanaged code area for action Semantic_standardizationYaml.semanticAnnotationLookup
+ }
+ val propertiesHierarchyList = propertiesHierarchyListAction { input: (String, String, String) =>
+ val (vocabulary_name, ontology_name, lang) = input
+ // ----- Start of unmanaged code area for action Semantic_standardizationYaml.propertiesHierarchyList
+ val parameters = Map("lang" -> lang)
val vocapi = kb.vocabularyAPI.items(vocabulary_name)
val ontoapi = kb.ontologyAPI.items(ontology_name)
val fields = vocapi.extract_keys(parameters)
+
val items = ontoapi.extract_hierarchy_properties(parameters, fields)
.map { item =>
val vocabulary = item.get("vocabulary").get.asInstanceOf[String]
@@ -76,12 +166,12 @@ package semantic_standardization.yaml {
case ex: Throwable =>
PropertiesHierarchyList500(Error(s"cannot obtain property hierarchies for ${ontology_name}/${vocabulary_name} ", ex.getMessage))
}
- // ----- End of unmanaged code area for action Semantic_standardizationYaml.propertiesHierarchyList
- }
- val vocabularyDataset = vocabularyDatasetAction { input: (String, String) =>
- val (name, lang) = input
- // ----- Start of unmanaged code area for action Semantic_standardizationYaml.vocabularyDataset
- val vocapi = kb.vocabularyAPI.items(name)
+ // ----- End of unmanaged code area for action Semantic_standardizationYaml.propertiesHierarchyList
+ }
+ val vocabularyDataset = vocabularyDatasetAction { input: (String, String) =>
+ val (name, lang) = input
+ // ----- Start of unmanaged code area for action Semantic_standardizationYaml.vocabularyDataset
+ val vocapi = kb.vocabularyAPI.items(name)
val tree = vocapi.extract_data(Map("lang" -> "it"))
val items = tree
@@ -96,8 +186,8 @@ package semantic_standardization.yaml {
case ex: Throwable =>
VocabularyDataset500(Error(s"problems obtaining a flat representation for Vocabulary ${name}", ex.getMessage))
}
- // ----- End of unmanaged code area for action Semantic_standardizationYaml.vocabularyDataset
+ // ----- End of unmanaged code area for action Semantic_standardizationYaml.vocabularyDataset
+ }
+
}
-
- }
}
diff --git a/semantic_standardization/app/it/almawave/linkeddata/kb/repo/RDFRepository.scala b/semantic_standardization/app/it/almawave/linkeddata/kb/repo/RDFRepository.scala
index f517cca..607f1a9 100644
--- a/semantic_standardization/app/it/almawave/linkeddata/kb/repo/RDFRepository.scala
+++ b/semantic_standardization/app/it/almawave/linkeddata/kb/repo/RDFRepository.scala
@@ -9,6 +9,8 @@ import org.eclipse.rdf4j.rio.Rio
import java.io.FileInputStream
import java.net.URLDecoder
import org.eclipse.rdf4j.query.QueryLanguage
+import scala.collection.mutable.ListBuffer
+import org.eclipse.rdf4j.model.Statement
object RDFRepository {
@@ -34,6 +36,17 @@ class RDFRepository(repo: Repository) {
object store {
+ def statements() = {
+ val list = new ListBuffer[Statement]
+ val conn = repo.getConnection
+ val st_list = conn.getStatements(null, null, null, false)
+ while (st_list.hasNext()) {
+ list += st_list.next()
+ }
+ conn.close()
+ list
+ }
+
def clear(contexts: String*) = Try {
val conn = repo.getConnection
@@ -88,7 +101,7 @@ class RDFRepository(repo: Repository) {
val results = conn.prepareTupleQuery(QueryLanguage.SPARQL, query)
.evaluate()
- .toStream
+ // .toStream
.map(_.toMap())
.toList
diff --git a/semantic_standardization/app/it/almawave/linkeddata/kb/repo/utils/ConfigHelper.scala b/semantic_standardization/app/it/almawave/linkeddata/kb/repo/utils/ConfigHelper.scala
index b908a7b..fac8e5e 100644
--- a/semantic_standardization/app/it/almawave/linkeddata/kb/repo/utils/ConfigHelper.scala
+++ b/semantic_standardization/app/it/almawave/linkeddata/kb/repo/utils/ConfigHelper.scala
@@ -2,6 +2,8 @@ package it.almawave.linkeddata.kb.repo.utils
import com.typesafe.config.Config
import com.typesafe.config.ConfigValueFactory
+import com.typesafe.config.ConfigFactory
+import java.io.File
object ConfigHelper {
@@ -12,4 +14,17 @@ object ConfigHelper {
.withoutPath(conf_key)
}
+ def load(conf_files: String*): Config = {
+
+ var conf = ConfigFactory.empty()
+
+ conf_files.foreach { conf_name =>
+ val file = new File(conf_name).getAbsoluteFile
+ conf = conf.withFallback(ConfigFactory.parseFile(file))
+ }
+
+ conf.resolve()
+
+ }
+
}
\ No newline at end of file
diff --git a/semantic_standardization/app/it/almawave/linkeddata/kb/repo/utils/JSONHelper.scala b/semantic_standardization/app/it/almawave/linkeddata/kb/repo/utils/JSONHelper.scala
index a732507..f37e106 100644
--- a/semantic_standardization/app/it/almawave/linkeddata/kb/repo/utils/JSONHelper.scala
+++ b/semantic_standardization/app/it/almawave/linkeddata/kb/repo/utils/JSONHelper.scala
@@ -10,7 +10,6 @@ object JSONHelper {
private val json_mapper = new ObjectMapper()
.registerModule(DefaultScalaModule)
-
.configure(SerializationFeature.CLOSE_CLOSEABLE, true)
.configure(SerializationFeature.EAGER_SERIALIZER_FETCH, true)
.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, true)
@@ -24,6 +23,7 @@ object JSONHelper {
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
private val json_writer = json_mapper.writerWithDefaultPrettyPrinter()
+
private val json_reader = json_mapper.reader()
def parse(json: String): JsonNode = {
diff --git a/semantic_standardization/app/it/gov/daf/semantics/api/AnnotationLookupAPI.scala b/semantic_standardization/app/it/gov/daf/semantics/api/AnnotationLookupAPI.scala
new file mode 100644
index 0000000..1e81d64
--- /dev/null
+++ b/semantic_standardization/app/it/gov/daf/semantics/api/AnnotationLookupAPI.scala
@@ -0,0 +1,116 @@
+package it.gov.daf.semantics.api
+
+import com.typesafe.config.Config
+import com.typesafe.config.ConfigValueFactory
+import com.typesafe.config.ConfigFactory
+import org.eclipse.rdf4j.rio.Rio
+
+import it.almawave.linkeddata.kb.repo.RDFRepository
+
+import java.nio.file.Files
+import java.nio.file.Paths
+import java.io.File
+
+import scala.collection.JavaConversions._
+import scala.collection.JavaConverters._
+
+object AnnotationLookupAPI {
+
+ val DEFAULT_CONFIG = ConfigFactory.parseString("""
+
+ # lookup configuration for an ontology and its related vocabularies
+ POI-AP_IT {
+
+ files: [
+ ${data_dir}"/ontologies/agid/POI-AP_IT/POI-AP_IT.ttl",
+ ${data_dir}"/ontologies/l0.ttl",
+ ${data_dir}"/vocabularies/POICategoryClassification.ttl"
+ ]
+
+ contexts: [ "http://dati.gov.it/onto/poiapit#" ]
+
+ lookup.annotation: ${data_dir}"/references/lookup_semantic_annotation.sparql"
+
+ }
+
+ # REVIEW: lookup query can't work with class or instances in this way...
+ CLV_AP-IT {
+
+ files: [
+ ${data_dir}"/ontologies/agid/CLV-AP_IT/CLV-AP_IT.ttl",
+ ${data_dir}"/ontologies/l0.ttl",
+ ${data_dir}"/vocabularies/Istat-Classificazione-08-Territorio.ttl"
+ ]
+
+ contexts: [ "http://dati.gov.it/onto/clvapit#" ]
+
+ # TODO: REVIEW for CLV
+ lookup.annotation: ${data_dir}"/references/lookup_semantic_annotation.sparql"
+
+ }
+
+ """)
+
+}
+
+class AnnotationLookupAPI() {
+
+ val repo = RDFRepository.memory()
+
+ // val conf = config.withValue("data_dir", ConfigValueFactory.fromAnyRef("dist/data")).resolve()
+
+ var conf = ConfigFactory.empty()
+
+ def config(config: Config) {
+ conf = config
+ }
+
+ def start = {
+ repo.start()
+ this.load()
+ }
+
+ def stop = repo.stop()
+
+ def mime(file: File) = Rio.getParserFormatForFileName(file.getName).get.getDefaultMIMEType
+
+ /*
+ * loads ontologies and vocabularies for each configuration
+ */
+ def load() = {
+
+ conf.root().keySet().map { key =>
+
+ val files_path = key.trim() + ".files"
+ val contexts_path = key.trim() + ".contexts"
+
+ if (conf.hasPath(contexts_path)) {
+
+ val contexts = conf.getStringList(contexts_path)
+
+ val files = conf.getStringList(files_path).map { f => new File(f) }
+ files.foreach { file => repo.io.addRDFFile(file, mime(file), contexts: _*) }
+
+ }
+
+ }
+
+ }
+
+ def lookup(semantic_annotation: String) = {
+
+ val annotations = semantic_annotation.split("\\.")
+ val ontology_id = annotations(0)
+ val concept_id = annotations(1)
+ val property_id = annotations(2)
+
+ val query = Files.readAllLines(Paths.get(conf.getString(s"${ontology_id}.lookup.annotation")))
+ .mkString("\n")
+ .replace("${semantic_annotation}", semantic_annotation)
+
+ repo.sparql.query(query)
+
+ }
+
+}
+
diff --git a/semantic_standardization/app/it/gov/daf/semantics/api/OntologyAPI.scala b/semantic_standardization/app/it/gov/daf/semantics/api/OntologyAPI.scala
index c0f1b5c..a6b6f35 100644
--- a/semantic_standardization/app/it/gov/daf/semantics/api/OntologyAPI.scala
+++ b/semantic_standardization/app/it/gov/daf/semantics/api/OntologyAPI.scala
@@ -1,6 +1,7 @@
package it.gov.daf.semantics.api
import com.typesafe.config.ConfigFactory
+
import it.almawave.linkeddata.kb.repo.RDFRepository
import java.io.File
import com.typesafe.config.Config
@@ -9,12 +10,11 @@ import java.nio.file.Paths
import scala.util.Try
import scala.io.Source
import play.Logger
-import it.almawave.linkeddata.kb.utils.JSONHelper
-class OntologyAPI(conf: Config = ConfigFactory.empty()) {
+import scala.collection.JavaConversions._
+import scala.collection.JavaConverters._
- import scala.collection.JavaConversions._
- import scala.collection.JavaConverters._
+class OntologyAPI(conf: Config = ConfigFactory.empty()) {
val logger = Logger.underlying()
@@ -24,7 +24,6 @@ class OntologyAPI(conf: Config = ConfigFactory.empty()) {
val onto_name = conf.getString("ontology.name")
val query_template = readFile(conf.getString("ontology.query.hierarchy"))
- // println("QUERY_TEMPLATE: " + query_template)
def start() {
@@ -79,13 +78,23 @@ class OntologyAPI(conf: Config = ConfigFactory.empty()) {
txt
}
- def extract_hierarchy(parameters: Map[String, Object] = Map.empty) = {
+ def extract_hierarchy(parameters: Map[String, Object] = Map.empty): List[Map[String, Object]] = {
+
+ var results: List[Map[String, Object]] = List()
val query = parse_query(parameters).get
- repo.sparql
- .query(query).get
- .toList
+ try {
+ results = repo.sparql
+ .query(query).get
+ .toList
+ } catch {
+ case ex: Throwable =>
+ // ex.printStackTrace()
+ logger.error(s"error on query: ${query}\n ${ex}")
+ }
+
+ results
}
@@ -93,11 +102,14 @@ class OntologyAPI(conf: Config = ConfigFactory.empty()) {
parameters: Map[String, Object],
properties: List[String] = List()): List[Map[String, Object]] = {
+ // NOTE: ?id should be used in the bindings
+
+ // extracting a list of concept ids
val hierarchy_elements = extract_hierarchy(parameters)
- .sortBy { map => map.get("rank").get.asInstanceOf[String] }
- .map { map => map.get("id").get.asInstanceOf[String] }
+ .sortBy { map => map.get("rank").getOrElse("0").asInstanceOf[String] }
+ .map { map => map.get("id").getOrElse("").toString() }
- // TODO: fix the _ with .
+ // NOTE: in the SPARQL query we need to use the `_`, here we fix it with `.`
properties.map { prop =>
// hack for preserving correct naming conventions
@@ -183,8 +195,6 @@ object OntologyAPIFactory {
// TODO: load from file!
val DEFAULT_CONFIG = ConfigFactory.parseString("""
- "data_dir": "./data"
-
clvapit {
ontology.name: "CLV-AP_IT"
@@ -197,6 +207,21 @@ object OntologyAPIFactory {
ontology.query.hierarchy: ${data_dir}"/ontologies/agid/CLV-AP_IT/CLV-AP_IT.hierarchy.sparql"
}
+
+ poiapit {
+
+ ontology.name: "POI-AP_IT"
+ ontology.prefix: "poiapit"
+
+ # CHECK: multiple files import: Ontology + Vocabulary
+ #ontology.file: ${data_dir}"/ontologies/agid/POI-AP_IT/POI-AP_IT.ttl"
+ ontology.file: ${data_dir}"/vocabularies/POICategoryClassification.ttl"
+
+ ontology.contexts: [ "http://dati.gov.it/onto/poiapit#" ]
+
+ ontology.query.hierarchy: ${data_dir}"/ontologies/agid/POI-AP_IT/POI-AP_IT.hierarchy.sparql"
+
+ }
""")
diff --git a/semantic_standardization/app/it/gov/daf/semantics/api/Testing.scala b/semantic_standardization/app/it/gov/daf/semantics/api/Testing.scala
new file mode 100644
index 0000000..12deea4
--- /dev/null
+++ b/semantic_standardization/app/it/gov/daf/semantics/api/Testing.scala
@@ -0,0 +1,58 @@
+package it.gov.daf.semantics.api
+
+import org.eclipse.rdf4j.repository.sail.SailRepository
+import org.eclipse.rdf4j.sail.memory.MemoryStore
+import org.eclipse.rdf4j.query.QueryLanguage
+import it.almawave.linkeddata.kb.repo.RDFRepository
+
+object Testing extends App {
+
+ val repo = RDFRepository.memory()
+
+ repo.start()
+// repo.io.addRDFFile(new File, mimeFormat, contexts)
+
+ def query = """SELECT DISTINCT * WHERE { ?s ?p ?o } """
+
+
+
+
+ repo.stop()
+
+ // ------------------------------------------------------------------
+
+ def query2 = """
+ PREFIX rdf:
+ PREFIX owl:
+ PREFIX rdfs:
+ PREFIX xsd:
+ PREFIX clvapit:
+ PREFIX skos:
+ PREFIX l0:
+ PREFIX poiapit:
+
+ SELECT ?ontology ?id ?uri ?label ?rank
+
+ FROM
+
+ WHERE {
+
+ ?uri a skos:Concept . #poiapit:PointOfInterestCategory
+ ?uri a ?concept .
+ ?uri skos:prefLabel ?label .
+ ?uri clvapit:hasRankOrder ?rank .
+
+ ?uri ?property [] .
+ ?property l0:controlledVocabulary ?vocabulary .
+ ?uri a ?concept . ?concept rdfs:isDefinedBy ?ontology .
+
+ BIND(REPLACE(STR(?uri), '^.*/(.*)[#/].*$', '$1', 'i') AS ?id) #TODO:Concept-id
+
+ # parameters!
+ FILTER(LANG(?label) = 'it')
+ }
+
+ ORDER BY ?rank
+ """
+
+}
\ No newline at end of file
diff --git a/semantic_standardization/app/it/gov/daf/semantics/api/VocabularyAPI.scala b/semantic_standardization/app/it/gov/daf/semantics/api/VocabularyAPI.scala
index f50366e..c49042a 100644
--- a/semantic_standardization/app/it/gov/daf/semantics/api/VocabularyAPI.scala
+++ b/semantic_standardization/app/it/gov/daf/semantics/api/VocabularyAPI.scala
@@ -88,6 +88,7 @@ class VocabularyAPI(conf: Config = ConfigFactory.empty()) {
def extract_data(parameters: Map[String, Object] = Map.empty) = {
+ // we will use the ontology name as a prefix for property_names
val oname = conf.getString("vocabulary.ontology.name")
extract_data_map(parameters).map {
@@ -113,7 +114,9 @@ class VocabularyAPI(conf: Config = ConfigFactory.empty()) {
.toStream
.map {
// fixing name
- _.toList.map { el => (el._1.replace(oprefix, oname), el._2) }.toMap
+ _.toList.map { el =>
+ (el._1.replace(oprefix, oname), el._2)
+ }.toMap
}
.toList
@@ -173,7 +176,7 @@ object VocabularyAPIFactory {
// TODO: load from file!
val DEFAULT_CONFIG = ConfigFactory.parseString("""
- "data_dir": "./data"
+ #"data_dir": "./data"
"Istat-Classificazione-08-Territorio" {
@@ -189,6 +192,21 @@ object VocabularyAPIFactory {
vocabulary.query.csv: ${data_dir}"/vocabularies/Istat-Classificazione-08-Territorio#dataset.csv.sparql"
}
+
+ "POICategoryClassification" {
+
+ vocabulary.name: "POICategoryClassification"
+
+ vocabulary.ontology.name: "POI-AP_IT"
+ vocabulary.ontology.prefix: "poiapit"
+
+ vocabulary.file: ${data_dir}"/vocabularies/POICategoryClassification.ttl"
+
+ vocabulary.contexts: [ "http://dati.gov.it/onto/poiapit#" ]
+
+ vocabulary.query.csv: ${data_dir}"/vocabularies/POICategoryClassification#dataset.csv.sparql"
+
+ }
""")
diff --git a/semantic_standardization/app/modules/KBModule.scala b/semantic_standardization/app/modules/KBModule.scala
index 7948b34..98affd7 100644
--- a/semantic_standardization/app/modules/KBModule.scala
+++ b/semantic_standardization/app/modules/KBModule.scala
@@ -19,6 +19,7 @@ import play.Mode
import com.typesafe.config.Config
import com.typesafe.config.ConfigValueFactory
import it.almawave.linkeddata.kb.repo.utils.ConfigHelper
+import it.gov.daf.semantics.api.AnnotationLookupAPI
@ImplementedBy(classOf[KBModuleBase])
trait KBModule
@@ -35,6 +36,8 @@ class KBModuleBase @Inject() (lifecycle: ApplicationLifecycle) extends KBModule
// VocabularyAPI service
val vocabularyAPI = new VocabularyAPIFactory()
+ val annotation_api = new AnnotationLookupAPI() // TODO: factory!
+
// when application starts...
@Inject
def onStart(
@@ -51,10 +54,7 @@ class KBModuleBase @Inject() (lifecycle: ApplicationLifecycle) extends KBModule
case "prod" => "./data"
}
- println("\n\n\nUSING DATA DIR:" + data_dir)
-
// starting OntologyAPI service
- // val config_ontologies = ConfigHelper.injectParameter(OntologyAPIFactory.DEFAULT_CONFIG, "data_dir", data_dir)
val config_ontologies = ConfigHelper.injectParameter(OntologyAPIFactory.DEFAULT_CONFIG, "data_dir", "./dist/data")
ontologyAPI.config(config_ontologies)
ontologyAPI.start()
@@ -65,6 +65,10 @@ class KBModuleBase @Inject() (lifecycle: ApplicationLifecycle) extends KBModule
vocabularyAPI.config(config_vocabularies)
vocabularyAPI.start()
+ // lookup service
+ val config_annotations = ConfigHelper.injectParameter(AnnotationLookupAPI.DEFAULT_CONFIG, "data_dir", "./dist/data")
+ annotation_api.config(config_annotations)
+ annotation_api.start
}
// when application stops...
@@ -78,6 +82,8 @@ class KBModuleBase @Inject() (lifecycle: ApplicationLifecycle) extends KBModule
// stopping OntologyAPI service
ontologyAPI.stop()
+ annotation_api.stop
+
// this is useful for saving files, closing connections, release indexes, etc
// kbrepo.stop()
Logger.info("KBModule.STOP....")
diff --git a/semantic_standardization/conf/semantic_standardization.yaml b/semantic_standardization/conf/semantic_standardization.yaml
index 3aa6f1c..617ab77 100644
--- a/semantic_standardization/conf/semantic_standardization.yaml
+++ b/semantic_standardization/conf/semantic_standardization.yaml
@@ -23,6 +23,32 @@ produces:
- "application/json"
paths:
+
+ "/daf/annotation/lookup":
+ get:
+ summary: "lookup from the semantic_annotation"
+ description: "lookup from the semantic_annotation"
+ operationId: "semanticAnnotationLookup"
+ produces:
+ - "application/json"
+ parameters:
+ - name: semantic_annotation
+ in: query
+ description: "semantic_annotation"
+ required: true
+ type: string
+ responses:
+ 200:
+ description: "semantic annotation lookup"
+ schema:
+ type: array
+ items:
+ $ref: '#/definitions/SemanticAnnotationInfo'
+ 500:
+ description: unexpected error
+ schema:
+ $ref: '#/definitions/Error'
+ tags: [ POC ]
"/hierarchies/properties":
get:
@@ -146,6 +172,41 @@ definitions:
type: "string"
level:
type: "integer"
+
+ SemanticAnnotationInfo:
+ type: object
+ required:
+ - semantic_annotation
+ - ontology_prefix
+ - ontology_id
+ - ontology
+ - vocabulary_id
+ - vocabulary
+ - property_id
+ - property
+ - concept_id
+ - concept
+ properties:
+ semantic_annotation:
+ type: string
+ ontology_prefix:
+ type: string
+ ontology_id:
+ type: string
+ ontology:
+ type: string
+ vocabulary_id:
+ type: string
+ vocabulary:
+ type: string
+ property_id:
+ type: string
+ property:
+ type: string
+ concept_id:
+ type: string
+ concept:
+ type: string
Error:
type: "object"
diff --git a/semantic_standardization/conf/semantic_standardization.yaml.bkp b/semantic_standardization/conf/semantic_standardization.yaml.bkp
new file mode 100644
index 0000000..3aa6f1c
--- /dev/null
+++ b/semantic_standardization/conf/semantic_standardization.yaml.bkp
@@ -0,0 +1,159 @@
+swagger: "2.0"
+info:
+ version: "0.1.0"
+ title: "semantic_standardization"
+ description: "semantic standardization api"
+ termsOfService: "http://swagger.io/terms/"
+ contact:
+ name: "swagger"
+ email: "apiteam@swagger.io"
+ url: https://github.com/seralf/semantic_standardization
+
+ license:
+ name: "Apache 2.0"
+ url: "http://www.apache.org/licenses/LICENSE-2.0.html"
+
+host: localhost:9000
+basePath: /kb/v1
+schemes:
+ - "http"
+consumes:
+ - "application/json"
+produces:
+ - "application/json"
+
+paths:
+
+ "/hierarchies/properties":
+ get:
+ summary: "a vocabulary dataset"
+ description: "a vocabulary dataset"
+ operationId: "propertiesHierarchyList"
+ produces:
+ - "application/json"
+ parameters:
+ - name: vocabulary_name
+ in: query
+ description: "the name of a vocabulary"
+ required: true
+ type: string
+ - name: ontology_name
+ in: query
+ description: "the name of an ontology"
+ required: true
+ type: string
+ - name: lang
+ in: query
+ description: the language used for exporting vocabulary data
+ required: true
+ type: string
+ responses:
+ 200:
+ description: "vocabulary data"
+ schema:
+ #type: string
+ type: array
+ items:
+ $ref: '#/definitions/PropertyHierarchy'
+ 500:
+ description: unexpected error
+ schema:
+ $ref: '#/definitions/Error'
+ tags: [ POC ]
+
+
+ "/vocabularies/{name}":
+ get:
+ summary: "a vocabulary dataset"
+ description: "a vocabulary dataset"
+ operationId: "vocabularyDataset"
+ produces:
+ - "application/json"
+ parameters:
+ - name: name
+ in: path
+ description: "the name of a vocabulary"
+ required: true
+ type: string
+ - name: lang
+ in: query
+ description: the language used for exporting vocabulary data
+ required: true
+ type: string
+ responses:
+ 200:
+ description: "vocabulary data"
+ schema:
+ #type: string
+ type: array
+ items:
+ $ref: '#/definitions/VocabularyItem'
+ 500:
+ description: unexpected error
+ schema:
+ $ref: '#/definitions/Error'
+ tags: [ POC ]
+
+
+definitions:
+
+ # HACK: we have to find a general purpose method for mapping generic different models here
+ # only for prototype....................
+
+ VocabularyItem:
+ type: array
+ items:
+ $ref: '#/definitions/VocabularyItemValue'
+
+ VocabularyItemValue:
+ type: object
+ required:
+ - key
+ - value
+ properties:
+ key:
+ type: "string"
+ value:
+ type: "string"
+
+
+ PropertyHierarchy:
+ type: object
+ required:
+ - vocabulary
+ - path
+ - hierarchy_flat
+ - hierarchy
+ properties:
+ vocabulary:
+ type: "string"
+ path:
+ type: "string"
+ hierarchy_flat:
+ type: "string"
+ hierarchy:
+ type: array
+ items:
+ $ref: '#/definitions/PropertyHierarchyLevel'
+
+ PropertyHierarchyLevel:
+ type: object
+ required:
+ - class
+ - level
+ properties:
+ class:
+ type: "string"
+ level:
+ type: "integer"
+
+ Error:
+ type: "object"
+ required:
+ - message
+ - description
+ properties:
+ message:
+ type: string
+ description:
+ type: string
diff --git a/semantic_standardization/dist/data/ontologies/agid/CLV-AP_IT/CLV-AP_IT.hierarchy.sparql b/semantic_standardization/dist/data/ontologies/agid/CLV-AP_IT/CLV-AP_IT.hierarchy.sparql
index 149be18..eb0d966 100644
--- a/semantic_standardization/dist/data/ontologies/agid/CLV-AP_IT/CLV-AP_IT.hierarchy.sparql
+++ b/semantic_standardization/dist/data/ontologies/agid/CLV-AP_IT/CLV-AP_IT.hierarchy.sparql
@@ -16,7 +16,8 @@ WHERE {
?uri rdfs:label ?label .
?uri clvapit:hasRankOrder ?rank .
- FILTER(LANG(?label)='${lang}')
+ #FILTER(LANG(?label)='${lang}')
+ FILTER(LANG(?label)='it')
BIND(REPLACE(STR(?uri), 'http://dati.gov.it/onto/clvapit#(.*)', '$1') AS ?id)
BIND(CONCAT('clvapit') AS ?ontology)
diff --git a/semantic_standardization/dist/data/ontologies/agid/POI-AP_IT/POI-AP_IT.hierarchy.sparql b/semantic_standardization/dist/data/ontologies/agid/POI-AP_IT/POI-AP_IT.hierarchy.sparql
new file mode 100644
index 0000000..84f4aa6
--- /dev/null
+++ b/semantic_standardization/dist/data/ontologies/agid/POI-AP_IT/POI-AP_IT.hierarchy.sparql
@@ -0,0 +1,39 @@
+PREFIX rdf:
+PREFIX owl:
+PREFIX rdfs:
+PREFIX xsd:
+
+PREFIX skos:
+PREFIX l0:
+
+PREFIX clvapit:
+PREFIX poiapit:
+
+SELECT DiSTINCT ?id ?label ?rank ?vocabulary ?ontology ?concept ?uri
+
+FROM
+
+WHERE {
+
+ ?instance_uri a ?concept .
+ ?instance_uri a poiapit:PointOfInterestCategory .
+
+ ?instance_uri skos:prefLabel ?label .
+ ?instance_uri clvapit:hasRankOrder ?rank .
+
+ # CHECK: ?instance_uri ?property [] . ?property l0:controlledVocabulary ?vocabulary .
+
+ # ?instance_uri a ?concept . ?concept rdfs:isDefinedBy ?ontology .
+
+ # EX:
+ #BIND(xsd:string('PointOfInterestCategory') AS ?id)
+ BIND(REPLACE(STR(?concept), '^.*/.*[#/](.*)$', '$1', 'i') AS ?id)
+ #BIND(xsd:string('ID_01') AS ?id)
+
+ # TODO: parameters!
+ #FILTER(LANG(?label)='it')
+ FILTER(LANG(?label)='${lang}')
+
+}
+
+ORDER BY ?rank
diff --git a/semantic_standardization/dist/data/ontologies/agid/POI-AP_IT/POI-AP_IT.ttl b/semantic_standardization/dist/data/ontologies/agid/POI-AP_IT/POI-AP_IT.ttl
new file mode 100644
index 0000000..1e59572
--- /dev/null
+++ b/semantic_standardization/dist/data/ontologies/agid/POI-AP_IT/POI-AP_IT.ttl
@@ -0,0 +1,471 @@
+@prefix : .
+@prefix dc: .
+@prefix l0: .
+@prefix ti: .
+@prefix dct: .
+@prefix owl: .
+@prefix rdf: .
+@prefix xml: .
+@prefix xsd: .
+@prefix prov: .
+@prefix rdfs: .
+@prefix clvapit: .
+@base .
+
+ rdf:type owl:Ontology ;
+ owl:versionIRI ;
+ owl:imports ti: ,
+ clvapit: ,
+ l0: ;
+ dc:creator "Institute of Cognitive Sciences and Technologies of the Italian Research Council (CNR) - Semantic Technology Laboratory (STLab)"@en ,
+ "Italian Digital Transformation Team"@en ;
+ owl:versionInfo "Version 0.2 - 03 November 2017 - Added associated with the controlled vocabiulary"@en ;
+ rdfs:isDefinedBy ;
+ dc:creator "Istituto di Scienze e Tecnologie della Cognizione del CNR - Laboratorio di Tecnologie Semantiche (STLab)"@it ;
+ dct:issued "2017-10-16"^^xsd:date ;
+ dc:creator "Team per la Trasformazione Digitale"@it ;
+ owl:versionInfo "Versione 0.2 - 03 Novembre 2017 - Aggiunta associazione con i core vocabulary"@it ;
+ dct:modified "2017-11-3" ;
+ dc:creator "Agency for Digital Italy - AgID"@en ;
+ rdfs:label "Punti di Interesse"@it ;
+ rdfs:comment "This is the ontology of the Italian application profile for Points of Interest"@en ,
+ "Questa è l'ontologia del profilo italiano sui Punti di Interesse (Point of Interest - Italian Application Profile - POI-AP_IT)"@it ;
+ rdfs:label "Point of Interest"@en ;
+ dc:creator "Agenzia per l'Italia Digitale - AgID"@it .
+
+#################################################################
+# Annotation properties
+#################################################################
+
+### http://dati.gov.it/onto/l0/controlledVocabulary
+l0:controlledVocabulary rdf:type owl:AnnotationProperty .
+
+
+#################################################################
+# Object Properties
+#################################################################
+
+### http://dati.gov.it/onto/clvapit#hasAddress
+clvapit:hasAddress rdf:type owl:ObjectProperty ;
+ rdfs:domain owl:Thing ;
+ rdfs:range clvapit:Address ;
+ rdfs:isDefinedBy .
+
+
+### http://dati.gov.it/onto/clvapit#hasGeometry
+clvapit:hasGeometry rdf:type owl:ObjectProperty ;
+ rdfs:domain owl:Thing ;
+ rdfs:range clvapit:Geometry ;
+ rdfs:isDefinedBy .
+
+
+### http://dati.gov.it/onto/poiapit#hasPOICategory
+:hasPOICategory rdf:type owl:ObjectProperty ;
+ owl:inverseOf :isPOICategoryFor ;
+ rdfs:domain :PointOfInterest ;
+ rdfs:range :PointOfInterestCategory ;
+ rdfs:comment "Questa proprietà lega il punto di inreresse alla sua categoria generale."@it ,
+ "This property links the point of interest to its general cateogry."@en ;
+ rdfs:isDefinedBy ;
+ rdfs:label "ha categoria del punto di interesse"@it ,
+ "has point of interest category"@en ;
+ owl:versionInfo "stabile"@it ,
+ "stable"@en .
+
+
+### http://dati.gov.it/onto/poiapit#hasPOINameInITime
+:hasPOINameInITime rdf:type owl:ObjectProperty ;
+ owl:inverseOf :isPOINameInTimeFor ;
+ rdfs:domain :PointOfInterest ;
+ rdfs:range :POINameInTime ;
+ rdfs:comment "Questa proprietà lega il punto di interesse alla situazione (evento) del suo nome ch ecambia nel tempo."@it ,
+ "This property lnks the point of time to the situation (event) of its name that changes over time."@en ;
+ rdfs:isDefinedBy ;
+ rdfs:label "ha name in time of the point of interest"@en ,
+ "ha nome nel tempo del punto di interesse"@it ;
+ owl:versionInfo "provvisoria"@it ,
+ "unstable"@en .
+
+
+### http://dati.gov.it/onto/poiapit#hasPOIState
+:hasPOIState rdf:type owl:ObjectProperty ;
+ owl:inverseOf :isPOIStateFor ;
+ rdf:type owl:FunctionalProperty ;
+ rdfs:domain :PointOfInterest ;
+ rdfs:range :POIState ;
+ rdfs:comment "Questa proprietà lega il punto di interesse al suo stato."@it ,
+ "This property links the point of interest to its status."@en ;
+ rdfs:isDefinedBy ;
+ rdfs:label "ha stato del punto di interesse"@it ,
+ "has point of interest status"@en ;
+ owl:versionInfo "stabile"@it ,
+ "stable"@en .
+
+
+### http://dati.gov.it/onto/poiapit#includesPOI
+:includesPOI rdf:type owl:ObjectProperty ;
+ owl:inverseOf :isIncludedInPOI ;
+ rdfs:domain :MultiplePointOfInterest ;
+ rdfs:range :PointOfInterest ;
+ rdfs:comment "Questa proprietà lega un punto di interesse multiplo a tutti i punti di interesse in esso contenuti."@it ,
+ "This property links a multiple point of interest with all the points of interest included in it."@en ;
+ rdfs:isDefinedBy ;
+ rdfs:label "include punto di interesse"@it ,
+ "includes point of interest"@en ;
+ owl:versionInfo "stabile"@it ,
+ "stable"@en .
+
+
+### http://dati.gov.it/onto/poiapit#isIncludedInPOI
+:isIncludedInPOI rdf:type owl:ObjectProperty ;
+ rdfs:domain :PointOfInterest ;
+ rdfs:range :MultiplePointOfInterest ;
+ rdfs:comment ,
+ "Inverse property of \"includes point of interest\"."@en ,
+ "Proprietà inversa di \"include punto di interesse\"."@it ;
+ rdfs:label "is included in point of interest"@en ,
+ "è incluso nel punto di interesse"@it ;
+ owl:versionInfo "stabile"@it ,
+ "stable"@en .
+
+
+### http://dati.gov.it/onto/poiapit#isPOICategoryFor
+:isPOICategoryFor rdf:type owl:ObjectProperty ;
+ rdfs:domain :PointOfInterestCategory ;
+ rdfs:range :PointOfInterest ;
+ rdfs:comment "Proprietà inversa di \"ha categoria del punto di interesse\"."@it ,
+ "This is the inverse property of \"has point of interest category\"."@en ;
+ rdfs:isDefinedBy ;
+ rdfs:label "is point of interest category for"@en ,
+ "è categoria del punto di interesse per"@it ;
+ owl:versionInfo "stabile"@it ,
+ "stable"@en .
+
+
+### http://dati.gov.it/onto/poiapit#isPOINameInTimeFor
+:isPOINameInTimeFor rdf:type owl:ObjectProperty ,
+ owl:FunctionalProperty ;
+ rdfs:domain :POINameInTime ;
+ rdfs:range :PointOfInterest ;
+ rdfs:comment "Inverse property of \"has point of interest name in time\"."@en ,
+ "Proprietà inversa di \"ha nome nel tempo del punto di interesse\"."@it ;
+ rdfs:isDefinedBy ;
+ rdfs:label "is point of interest name in time for"@en ,
+ "è nome nel tempo del punto di interesse per"@it ;
+ owl:versionInfo "provvisoria"@it ,
+ "unstable"@en .
+
+
+### http://dati.gov.it/onto/poiapit#isPOIStateFor
+:isPOIStateFor rdf:type owl:ObjectProperty ;
+ rdfs:domain :POIState ;
+ rdfs:range :PointOfInterest ;
+ rdfs:comment "Proprietà inversa di \"ha stato del punto di interesse\"."@it ,
+ "inverse property of \"has point of interest status\"."@en ;
+ rdfs:isDefinedBy ;
+ rdfs:label "is point of interest status for"@en ,
+ "è stato del punto di interesse per"@it ;
+ owl:versionInfo "stabile"@it ,
+ "stable"@en .
+
+
+### http://dati.gov.it/onto/smapit/hasImage
+ rdf:type owl:ObjectProperty ;
+ rdfs:domain owl:Thing ;
+ rdfs:range ;
+ rdfs:isDefinedBy .
+
+
+### http://dati.gov.it/onto/tiapit/atTime
+ti:atTime rdf:type owl:ObjectProperty ;
+ rdfs:domain owl:Thing ;
+ rdfs:range ti:TimeInterval ;
+ rdfs:isDefinedBy ti: .
+
+
+#################################################################
+# Data properties
+#################################################################
+
+### http://dati.gov.it/onto/poiapit#POIID
+:POIID rdf:type owl:DatatypeProperty ,
+ owl:FunctionalProperty ;
+ rdfs:domain :PointOfInterest ;
+ rdfs:range rdfs:Literal ;
+ rdfs:comment "Questa proprietà rappresenta l'identificativo univoco del punto di interesse."@it ,
+ "This property represents a unique identifier of the point of interest."@en ;
+ rdfs:isDefinedBy ;
+ rdfs:label "identificativo punto di interesse"@it ,
+ "point of interest identifier"@en ;
+ owl:versionInfo "stabile"@it ,
+ "stable"@en .
+
+
+### http://dati.gov.it/onto/poiapit#POIalternativeName
+:POIalternativeName rdf:type owl:DatatypeProperty ;
+ rdfs:domain :POINameInTime ;
+ rdfs:range rdfs:Literal ;
+ rdfs:comment "Questa proprietà rappresenta un nome alternativo (acrononimo, o altro nome) con cui è conosciuto il punto di interesse."@it ,
+ "This property represents an alternative name (acronym, or any other name) with which the point of interest is known."@en ;
+ rdfs:isDefinedBy ;
+ rdfs:label "nome alternativo del punto di interesse"@it ,
+ "point of interest alternative name"@en ;
+ owl:versionInfo "stabile"@it ,
+ "stable"@en .
+
+
+### http://dati.gov.it/onto/poiapit#POIcategoryIdentifier
+:POIcategoryIdentifier rdf:type owl:DatatypeProperty ;
+ l0:controlledVocabulary ;
+ rdfs:comment "Questa proprietà è l'identificativo nel vocabolario controllato della categoria dei punti di interesse. E' equivalente a dct:identifier e skos:notation utilizzati nel vocabolario controllato stesso."@it ;
+ rdfs:isDefinedBy ;
+ rdfs:label "POI category identifier"@en ,
+ "identificativo categoria punto di interesse"@it ;
+ owl:versionInfo "stabile"@it ,
+ "stable"@en .
+
+
+### http://dati.gov.it/onto/poiapit#POIcategoryName
+:POIcategoryName rdf:type owl:DatatypeProperty ;
+ rdfs:domain :PointOfInterestCategory ;
+ rdfs:range rdfs:Literal ;
+ l0:controlledVocabulary ;
+ rdfs:comment "Questa proprietà rappresenta l'etichetta (nome) della categoria del punto di interesse."@it ,
+ "This property represents the preferred label (name) of the category of the point of interest."@en ;
+ rdfs:isDefinedBy ;
+ rdfs:label "name of point of interest category"@en ,
+ "nome categoria del punto di interesse"@it ;
+ owl:versionInfo "stabile"@it ,
+ "stable"@en .
+
+
+### http://dati.gov.it/onto/poiapit#POIdescription
+:POIdescription rdf:type owl:DatatypeProperty ;
+ rdfs:domain :PointOfInterest ;
+ rdfs:range rdfs:Literal ;
+ rdfs:comment "Questa proprietà rappresenta una generica descrizione del punto di interesse."@it ,
+ "This property represents a generic description of the point of interest."@en ;
+ rdfs:isDefinedBy ;
+ rdfs:label "descrizione del punto di interesse"@it ,
+ "point of interest description"@en ;
+ owl:versionInfo "stabile"@it ,
+ "stable"@en .
+
+
+### http://dati.gov.it/onto/poiapit#POIofficialName
+:POIofficialName rdf:type owl:DatatypeProperty ;
+ rdfs:domain [ rdf:type owl:Class ;
+ owl:unionOf ( :POINameInTime
+ :PointOfInterest
+ )
+ ] ;
+ rdfs:range rdfs:Literal ;
+ rdfs:comment "Questa proprietà rappresenta il nome ufficiale del punto di interesse."@it ,
+ "This property represents the official name of the point of interest."@en ;
+ rdfs:isDefinedBy ;
+ rdfs:label "nome ufficiale del punto di interesse"@it ,
+ "point of interest official name"@en ;
+ owl:versionInfo "stabile"@it ,
+ "stable"@en .
+
+
+### http://dati.gov.it/onto/poiapit#POIstate
+:POIstate rdf:type owl:DatatypeProperty ;
+ rdfs:domain :POIState ;
+ rdfs:range rdfs:Literal ;
+ rdfs:comment "Questa proprietà rappresenta l'etichetta (stringa) dello stato del punto di interesse."@it ,
+ "This property is the preferred label for the status of the point of interest."@en ;
+ rdfs:isDefinedBy ;
+ rdfs:label "stato"@it ,
+ "status"@en ;
+ owl:versionInfo "stabile"@it ,
+ "stable"@en .
+
+
+#################################################################
+# Classes
+#################################################################
+
+### http://dati.gov.it/onto/clvapit#Address
+clvapit:Address rdf:type owl:Class ;
+ rdfs:isDefinedBy .
+
+
+### http://dati.gov.it/onto/clvapit#Geometry
+clvapit:Geometry rdf:type owl:Class ;
+ rdfs:isDefinedBy .
+
+
+### http://dati.gov.it/onto/l0/Characteristic
+l0:Characteristic rdf:type owl:Class ;
+ rdfs:isDefinedBy l0: .
+
+
+### http://dati.gov.it/onto/l0/Entity
+l0:Entity rdf:type owl:Class ;
+ rdfs:isDefinedBy l0: .
+
+
+### http://dati.gov.it/onto/l0/Event
+l0:Event rdf:type owl:Class ;
+ rdfs:isDefinedBy l0: .
+
+
+### http://dati.gov.it/onto/l0/Topic
+l0:Topic rdf:type owl:Class ;
+ rdfs:isDefinedBy l0: .
+
+
+### http://dati.gov.it/onto/poiapit#MultiplePointOfInterest
+:MultiplePointOfInterest rdf:type owl:Class ;
+ rdfs:subClassOf :PointOfInterest ,
+ [ rdf:type owl:Restriction ;
+ owl:onProperty :includesPOI ;
+ owl:allValuesFrom :PointOfInterest
+ ] ;
+ rdfs:comment "Questa classe rappresenta una collezione di punti di interesse. Per esempio un centro commerciale è un punto di interesse ma a sua volta una collezioni di tanti punti di interesse (farmacia, negozi, ristoranti, cinema, ecc.)"@it ,
+ "This class represents a collection of points of interest."@en ;
+ rdfs:isDefinedBy ;
+ rdfs:label "Multiple Point Of Interest"@en ,
+ "Punto di Interesse Multiplo"@it ;
+ owl:versionInfo "stabile"@it ,
+ "stable"@en .
+
+
+### http://dati.gov.it/onto/poiapit#POINameInTime
+:POINameInTime rdf:type owl:Class ;
+ rdfs:subClassOf l0:Event ,
+ [ rdf:type owl:Restriction ;
+ owl:onProperty :isPOINameInTimeFor ;
+ owl:qualifiedCardinality "1"^^xsd:nonNegativeInteger ;
+ owl:onClass :PointOfInterest
+ ] ,
+ [ rdf:type owl:Restriction ;
+ owl:onProperty ti:atTime ;
+ owl:qualifiedCardinality "1"^^xsd:nonNegativeInteger ;
+ owl:onClass ti:TimeInterval
+ ] ,
+ [ rdf:type owl:Restriction ;
+ owl:onProperty :POIofficialName ;
+ owl:someValuesFrom rdfs:Literal
+ ] ,
+ [ rdf:type owl:Restriction ;
+ owl:onProperty :POIalternativeName ;
+ owl:allValuesFrom rdfs:Literal
+ ] ;
+ rdfs:comment "Questa classe rappresenta la situazione del nome del punto di interesse che cambia nel tempo. Essa è rappresentata quindi come una relazione ennaria tra il punto di interesse, il tempo e il nome. Questa classe può essere utile nel caso si voglia tracciare l'evoluzione dei nomi di punti di interesse nel tempo."@it ,
+ "This class represents the situation of the name of the point of interest that changes over time. It is therefore represented as an ennary relationship between the point of interest, time and name. This class can be useful in case you want to trace the evolution of names of points of interest over time."@en ;
+ rdfs:isDefinedBy ;
+ rdfs:label "Name in Time of the Point of Interest"@en ,
+ "Nome nel Tempo del Punto di Interesse"@it ;
+ owl:versionInfo "provvisoria"@it ,
+ "unstable"@en .
+
+
+### http://dati.gov.it/onto/poiapit#POIState
+:POIState rdf:type owl:Class ;
+ rdfs:subClassOf l0:Characteristic ,
+ [ rdf:type owl:Restriction ;
+ owl:onProperty :isPOIStateFor ;
+ owl:allValuesFrom :PointOfInterest
+ ] ,
+ [ rdf:type owl:Restriction ;
+ owl:onProperty :POIstate ;
+ owl:someValuesFrom rdfs:Literal
+ ] ;
+ rdfs:comment "Questa classe rappresenta lo stato del punto di interesse. I suoi valori possono essere fissati per tipologia di punto di interesse. Per esempio, essi possono essere \"di turno\", \"aperta\", \"chiusa\", ecc. per le farmacie oppure \"libero\", \"occupato\" per i parcheggi, oppure \"aperto\", \"chiuso\", \"in ristrutturazione\" nel caso di strutture ricettive, ecc."@it ,
+ "This class represents the status of the point of interest. Its values can be fixed but vary according to the type of point of interest. For example, they may be \"on duty\",\"open\",\"closed\", etc. for pharmacies or \"free\",\"occupied\" for parking, or \"open\",\"closed\",\"under renovation\" in the case of accommodation facilities, etc."@en ;
+ rdfs:isDefinedBy ;
+ rdfs:label "Point of Interest Status"@en ,
+ "Stato del Punto di Interesse"@it ;
+ owl:versionInfo "stabile"@it ,
+ "stable"@en .
+
+
+### http://dati.gov.it/onto/poiapit#PointOfInterest
+:PointOfInterest rdf:type owl:Class ;
+ rdfs:subClassOf l0:Entity ,
+ [ rdf:type owl:Restriction ;
+ owl:onProperty :hasPOICategory ;
+ owl:someValuesFrom :PointOfInterestCategory
+ ] ,
+ [ rdf:type owl:Restriction ;
+ owl:onProperty :hasPOINameInITime ;
+ owl:allValuesFrom :POINameInTime
+ ] ,
+ [ rdf:type owl:Restriction ;
+ owl:onProperty ;
+ owl:allValuesFrom
+ ] ,
+ [ rdf:type owl:Restriction ;
+ owl:onProperty ti:atTime ;
+ owl:allValuesFrom ti:TimeInterval
+ ] ,
+ [ rdf:type owl:Restriction ;
+ owl:onProperty clvapit:hasGeometry ;
+ owl:qualifiedCardinality "1"^^xsd:nonNegativeInteger ;
+ owl:onClass clvapit:Geometry
+ ] ,
+ [ rdf:type owl:Restriction ;
+ owl:onProperty clvapit:hasAddress ;
+ owl:maxQualifiedCardinality "1"^^xsd:nonNegativeInteger ;
+ owl:onClass clvapit:Address
+ ] ,
+ [ rdf:type owl:Restriction ;
+ owl:onProperty :hasPOIState ;
+ owl:maxQualifiedCardinality "1"^^xsd:nonNegativeInteger ;
+ owl:onClass :POIState
+ ] ,
+ [ rdf:type owl:Restriction ;
+ owl:onProperty :isIncludedInPOI ;
+ owl:maxQualifiedCardinality "1"^^xsd:nonNegativeInteger ;
+ owl:onClass :MultiplePointOfInterest
+ ] ,
+ [ rdf:type owl:Restriction ;
+ owl:onProperty :POIofficialName ;
+ owl:someValuesFrom rdfs:Literal
+ ] ,
+ [ rdf:type owl:Restriction ;
+ owl:onProperty :POIdescription ;
+ owl:allValuesFrom rdfs:Literal
+ ] ,
+ [ rdf:type owl:Restriction ;
+ owl:onProperty :POIID ;
+ owl:cardinality "1"^^xsd:nonNegativeInteger
+ ] ;
+ rdfs:comment "Questa classe rappresenta un punto di interesse, ovvero un particolare punto che qualcuno trova utile o di interesse. Esso può essere un parcheggio, una struttura ricettiva, una feramta dell'autobus, una farmacia, un centro commerciale, un incrocio, ecc. E' da notare che questa classe rappresenta di fatto una sovrastruttura utile per modellare cose di interesse ma allo stesso tempo è anche accettato considerarla come luogo (infatti la classe è definita come sotto classe di \"Entity-Entità\" dell'ontologia L0 che a sua volta può essere un oggetto o un luogo). Questo tipo di modellazione quindi consente a utenti di poter cercare oggetti di interesse ma anche fare query su punti di interessse intesi come luoghi."@it ,
+ "This class represents a point of interest, which is a particular point that someone finds useful or interesting. It may be a parking , an accommodation, a bus stop, a pharmacy, a shopping centre, a crossroads, etc. This class represents a \"superstructure\" used to model things of some kind of interest; however, at the same time it can be viewed as a location or place or feature (it is indeed a subclass of Entity in the top level ontology L0 which can be in turn a Location or an Object). This kind of modelling allows users to get information if they search for both a location and things to which they are interested in."@en ;
+ rdfs:isDefinedBy ;
+ rdfs:label "Point of Interest"@en ,
+ "Punto di Interesse"@it ;
+ owl:versionInfo "stabile"@it ,
+ "stable"@en .
+
+
+### http://dati.gov.it/onto/poiapit#PointOfInterestCategory
+:PointOfInterestCategory rdf:type owl:Class ;
+ rdfs:subClassOf l0:Topic ,
+ [ rdf:type owl:Restriction ;
+ owl:onProperty :POIcategoryName ;
+ owl:someValuesFrom rdfs:Literal
+ ] ;
+ rdfs:comment "Questa classe rappresenta la categoria attraverso cui classificare il punto di interesse. Essa assume i valori di un vocabolario controllato (che sarà rilasciato nelle prossime settimane e ispirato dalla classificazione di Open Street Map) che identifica in linea generale i tipi di punti di interesse come per esempio: divertimento, cibo, servizio pubbico, viaggi/turismo, ecc. I suoi individui possono essere anche sottoclassi della classe Punto di Interesse (questa tecnica di modellazione in OWL si chiama Punning)."@it ,
+ "This class represents the category of the point of interest. It individuals can be data of a controlled vocabulary (that we will make available in the upcoming weeks and that will be inspired by the classification offered by Open Street Map). The controlled vocabulary identifies the general types of Points of Interest such as, \"entertainament, food, public service, travel/tourism\", etc. The individuals of this class can also be subclasses of the class \"Point of Interest\" (Punning)"@en ;
+ rdfs:isDefinedBy ;
+ rdfs:label "Categoria del Punto di Interesse"@it ,
+ "Point of Interest Category"@en ;
+ owl:versionInfo "stabile"@it ,
+ "stable"@en .
+
+
+### http://dati.gov.it/onto/smapit/Image
+ rdf:type owl:Class ;
+ rdfs:comment .
+
+
+### http://dati.gov.it/onto/tiapit/TimeInterval
+ti:TimeInterval rdf:type owl:Class ;
+ rdfs:isDefinedBy ti: .
+
+
+### Generated by the OWL API (version 4.2.8.20170104-2310) https://github.com/owlcs/owlapi
diff --git a/semantic_standardization/dist/data/ontologies/l0.ttl b/semantic_standardization/dist/data/ontologies/l0.ttl
new file mode 100644
index 0000000..6d86d18
--- /dev/null
+++ b/semantic_standardization/dist/data/ontologies/l0.ttl
@@ -0,0 +1,127 @@
+@prefix : .
+@prefix owl: .
+@prefix rdf: .
+@prefix xml: .
+@prefix xsd: .
+@prefix rdfs: .
+@prefix dc: .
+@prefix prov: .
+@prefix dct: .
+@base .
+
+ rdf:type owl:Ontology ;
+ rdfs:comment "Questa ontologia fornisce il livello fondazionale allo stack ontologico di dati.gov.it. Il nome L0 sta per Level-0 ontology poiché essa fornisce le fondamenta concettuali elementari all'intero stack. Questa ontologia è parzialmente ispirata da DOLCE zero (http://www.ontologydesignpatterns.org/ont/d0.owl)"@it ;
+ prov:wasInfluencedBy ;
+ rdfs:comment "This ontology provides the foundational level of the ontological stack of dati.gov.it. The name L0 stands for Level-0 ontology as it provides the basic conceptual foundations to the whole stack. This ontology is partially inspired by DOLCE 0 (http://www.ontologydesignpatterns.org/ont/d0.owl)"@en ;
+ owl:versionInfo "0.2 - added the following axiom: Location subclass of Entity; added soft link with DOLCE 0"@en ;
+ owl:verionInfo "0.2 - aggiunto il seguente assioma: Location sottoclasse di Entity e aggiunto un collegamento con DOLCE 0." ;
+ dct:issued "2017-09-29" ;
+ dct:modified "2017-10-18" ;
+ dc:creator "Agency for Digital Italy - AgID"@en ,
+ "Institute of Cognitive Sciences and Technologies of the Italian Research Council (CNR) - Semantic Technology Laboratory (STLab)"@en ,
+ "Italian Digital Transformation Team"@en ;
+ rdfs:label "Level-0 ontology"@en ,
+ "Ontologia Level-0"@it .
+
+#################################################################
+# Annotation properties
+#################################################################
+
+### http://www.w3.org/ns/prov#wasInfluencedBy
+ rdf:type owl:AnnotationProperty .
+
+### http://dati.gov.it/onto/l0/controlledVocabulary
+:controlledVocabulary rdf:type owl:AnnotationProperty ;
+ rdfs:label "controlled vocabulary"@en ;
+ rdfs:label "vocabolario controllato"@it ;
+ rdfs:comment "Questa proprietà è utilizzata per collegare una proprietà (data type property) di un'ontologia al relativo vocabolario controllato dove si trovano le istanze della proprietà stessa" ;
+ rdfs:comment "This property is used to link a property (data type property) of an ontology to the related controlled vocabulary where the individuals of the property are located" .
+
+#################################################################
+# Classes
+#################################################################
+
+### http://dati.gov.it/onto/l0/Activity
+:Activity rdf:type owl:Class ;
+ rdfs:comment "La classe che rappresenta un'attività."@it ,
+ "The class whose that models an activity."@en ;
+ rdfs:label "Activity"@en ,
+ "Attività"@it .
+
+
+### http://dati.gov.it/onto/l0/Agent
+:Agent rdf:type owl:Class ;
+ rdfs:subClassOf :Entity ;
+ rdfs:comment "Any agentive Object , either physical (e.g. a person, a robot, an oak), or social (e.g. a corporation, an institution, a community)."@en ,
+ "Un agente, sia fisico (ex. una persona, un robot, una quercia), o sociale (ex. una società, un'istituzione, una comunità)."@it ;
+ rdfs:label "Agent"@en ,
+ "Agente"@it .
+
+
+### http://dati.gov.it/onto/l0/Characteristic
+:Characteristic rdf:type owl:Class ;
+ rdfs:comment "Questa classe rappresenta una caratteristica."@it ,
+ "This class represent a characteristic."@en ;
+ rdfs:label "Caratteristica"@it ,
+ "Characteristic"@en .
+
+
+### http://dati.gov.it/onto/l0/Collection
+:Collection rdf:type owl:Class ;
+ rdfs:comment "La classe che rappresenta una collezione di qualsiasi cosa."@it ,
+ "The class that represents a collection of things."@en ;
+ rdfs:label "Collection"@en ,
+ "Collezione"@it .
+
+
+### http://dati.gov.it/onto/l0/Entity
+:Entity rdf:type owl:Class ;
+ rdfs:comment "Anything: real, possible, or imaginary, which some modeller wants to talk about for some purpose."@en ,
+ "Qualsiasi cosa reale, possibile o immaginaria."@it ;
+ rdfs:label "Entity"@en ,
+ "Entità"@it .
+
+
+### http://dati.gov.it/onto/l0/Event
+:Event rdf:type owl:Class ;
+ rdfs:comment "Rappresentazione del concetto di evento."@it ,
+ "Representation of the concept of event."@en ;
+ rdfs:label "Event"@en ,
+ "Evento"@it .
+
+
+### http://dati.gov.it/onto/l0/Location
+:Location rdf:type owl:Class ;
+ rdfs:subClassOf :Entity ;
+ rdfs:comment "Classe che rappresenta il concetto di luogo. Le istanze di questa classe sono, pertanto, luoghi."@it ,
+ "The class that reprepresents a location. Individuals of this class are locations (e.g. geographical places, spacial objects, etc.)."@en ;
+ rdfs:label "Location"@en ,
+ "Luogo"@it .
+
+
+### http://dati.gov.it/onto/l0/Object
+:Object rdf:type owl:Class ;
+ rdfs:subClassOf :Entity ;
+ rdfs:comment "An object."@en ,
+ "Un oggetto."@it ;
+ rdfs:label "Object"@en ,
+ "Oggetto"@it .
+
+
+### http://dati.gov.it/onto/l0/System
+:System rdf:type owl:Class ;
+ rdfs:comment "Questa classe rappresenta un sistema. Esempi di sistema sono un sistema politico o economico."@it ,
+ "This class represents a system. Example of systems are politacal or economical systems."@en ;
+ rdfs:label "Sistema"@it ,
+ "System"@en .
+
+
+### http://dati.gov.it/onto/l0/Topic
+:Topic rdf:type owl:Class ;
+ rdfs:comment "Il concetto di tema o argomento."@it ,
+ "The concept of topic."@en ;
+ rdfs:label "Tema"@it ,
+ "Topic"@en .
+
+
+### Generated by the OWL API (version 4.2.8.20170104-2310) https://github.com/owlcs/owlapi
diff --git a/semantic_standardization/dist/data/references/example_lookup.sparql b/semantic_standardization/dist/data/references/example_lookup.sparql
new file mode 100644
index 0000000..8b37216
--- /dev/null
+++ b/semantic_standardization/dist/data/references/example_lookup.sparql
@@ -0,0 +1,38 @@
+PREFIX rdf:
+PREFIX owl:
+PREFIX rdfs:
+PREFIX xsd:
+PREFIX clvapit:
+PREFIX skos:
+PREFIX l0:
+
+# lookup service from daf semantic annotation ${semantic_annotation}
+
+SELECT ?semantic_annotation ?ontology_name ?concept_id ?property ?vocabulary ?ontology ?ontology_id
+FROM
+
+WHERE {
+
+ ?uri a ?concept .
+
+ ?uri ?property [] .
+ BIND(REPLACE(STR(?property), '^.*/.*[#/](.*)$', '$1', 'i') AS ?property_id)
+
+ ?property l0:controlledVocabulary ?vocabulary .
+
+ FILTER(CONTAINS(STR(?concept), ?concept_id))
+
+ ?concept rdfs:isDefinedBy ?ontology .
+ BIND(REPLACE(STR(?ontology), '^.*/.*[#/](.*)$', '$1', 'i') AS ?ontology_id)
+
+ # parameters! ------------------------------------------------------------------------------------------------------------
+ BIND('POI-AP_IT' AS ?ontology_name) # NOTA: non coincide con il prefix!!!
+ BIND('PointOfInterestCategory' AS ?concept_id)
+
+ BIND(CONCAT('POI-AP_IT.PointOfInterestCategory.', STR(?property_id)) AS ?semantic_annotation)
+
+ # ex: semantic_annotation = POI-AP_IT.PointOfInterestCategory.POIcategoryIdentifier
+
+}
+
+ORDER BY ?rank
diff --git a/semantic_standardization/dist/data/references/lookup_semantic_annotation.sparql b/semantic_standardization/dist/data/references/lookup_semantic_annotation.sparql
new file mode 100644
index 0000000..e9969ae
--- /dev/null
+++ b/semantic_standardization/dist/data/references/lookup_semantic_annotation.sparql
@@ -0,0 +1,36 @@
+PREFIX rdf:
+PREFIX owl:
+PREFIX rdfs:
+PREFIX xsd:
+PREFIX clvapit:
+PREFIX skos:
+PREFIX l0:
+
+# this lookup service, given a daf semantic annotation retrieves metadata for (vocabulary, ontology)
+
+SELECT DISTINCT ?semantic_annotation ?ontology_prefix ?ontology_id ?ontology ?concept_id ?concept ?property_id ?property ?vocabulary_id ?vocabulary
+#FROM
+
+WHERE {
+
+ ?uri a ?concept .
+ ?uri ?property [] .
+
+ ?property l0:controlledVocabulary ?vocabulary .
+ BIND(REPLACE(STR(?vocabulary), '^.*/.*[#/](.*)$', '$1', 'i') AS ?vocabulary_id)
+
+ ?concept rdfs:isDefinedBy ?ontology .
+ BIND(REPLACE(STR(?ontology), '^.*/.*[#/](.*)$', '$1', 'i') AS ?ontology_prefix)
+
+ # parameters! ------------------------------------------------------------------------------------------------------------
+ # ex: semantic_annotation = POI-AP_IT.PointOfInterestCategory.POIcategoryIdentifier
+ BIND(xsd:string("${semantic_annotation}") AS ?semantic_annotation)
+ BIND(REPLACE(STR(?semantic_annotation), '^(.*)\\..*\\..*$', '$1', 'i') AS ?ontology_id)
+ BIND(REPLACE(STR(?semantic_annotation), '^.*\\.(.*)\\..*$', '$1', 'i') AS ?concept_id)
+ BIND(REPLACE(STR(?semantic_annotation), '^.*\\..*\\.(.*)$', '$1', 'i') AS ?property_id)
+
+ FILTER(CONTAINS(STR(?concept), STR(?concept_id)))
+ FILTER(CONTAINS(STR(?property), STR(?property_id)))
+
+}
+
\ No newline at end of file
diff --git a/semantic_standardization/dist/data/vocabularies/POICategoryClassification#dataset.csv.sparql b/semantic_standardization/dist/data/vocabularies/POICategoryClassification#dataset.csv.sparql
new file mode 100644
index 0000000..e23a7a6
--- /dev/null
+++ b/semantic_standardization/dist/data/vocabularies/POICategoryClassification#dataset.csv.sparql
@@ -0,0 +1,36 @@
+PREFIX skos:
+PREFIX clvapit:
+PREFIX poiapit:
+PREFIX dct:
+
+#SELECT DISTINCT *
+# SELECT DISTINCT ?poiapit_PointOfInterestCategory_notation
+
+SELECT DISTINCT
+?poiapit_PointOfInterestCategory_POICategoryIdentifier
+?poiapit_PointOfInterestCategory_POICategoryName
+?poiapit_PointOfInterestCategory_POICategoryIdentifier_label
+?poiapit_PointOfInterestCategory_definition
+
+
+# dataset de-normalization for ${vocabulary.name} for ${vocabulary.ontology}
+WHERE {
+
+ ?s a ?klass .
+
+ #CHECK: skos:Concept , poiapit:PointOfInterestCategory
+
+ ?s skos:inScheme ?scheme ;
+ skos:notation ?poiapit_PointOfInterestCategory_notation ;
+ dct:identifier ?poiapit_PointOfInterestCategory_identifier ;
+ poiapit:POIcategoryIdentifier ?poiapit_PointOfInterestCategory_POICategoryIdentifier ;
+ clvapit:hasRankOrder ?poiapit_PointOfInterestCategory_rank ; # CHECK
+ skos:prefLabel ?poiapit_PointOfInterestCategory_label ; # CHECK
+ poiapit:POIcategoryName ?poiapit_PointOfInterestCategory_POICategoryName ;
+ skos:definition ?poiapit_PointOfInterestCategory_definition ; # CHECK
+ .
+
+ FILTER(LANG(?poiapit_PointOfInterestCategory_POICategoryName) = 'it')
+ FILTER(LANG(?poiapit_PointOfInterestCategory_label) = 'it')
+
+}
diff --git a/semantic_standardization/dist/data/vocabularies/POICategoryClassification.ttl b/semantic_standardization/dist/data/vocabularies/POICategoryClassification.ttl
new file mode 100644
index 0000000..f4556f2
--- /dev/null
+++ b/semantic_standardization/dist/data/vocabularies/POICategoryClassification.ttl
@@ -0,0 +1,176 @@
+@prefix dct: .
+@prefix adms: .
+@prefix rdfs: .
+@prefix owl: .
+@prefix rdf: .
+@prefix dc: .
+@prefix skos: .
+@prefix poiapit: .
+@prefix xkos: .
+@prefix clvapit: .
+
+
+skos:ConceptScheme
+ a rdfs:Class .
+
+skos:Concept
+ a rdfs:Class .
+
+poiapit:PointOfInterestCategory
+ a rdfs:Class .
+
+skos:prefLabel
+ a rdfs:Property .
+
+skos:notation
+ a rdfs:Property .
+
+skos:inScheme
+ a rdfs:Property .
+
+skos:narrower
+ a rdfs:Property .
+
+skos:broader
+ a rdfs:Property .
+
+skos:broaderTransitive
+ a rdfs:Property .
+
+skos:narrowerTransitive
+ a rdfs:Property .
+
+skos:definition
+ a rdfs:Property .
+
+dct:identifier
+ a rdfs:Property .
+
+poiapit:POIcategoryName
+ a rdfs:Property .
+
+poiapit:POIcategoryIdentifier
+ a rdfs:Property .
+
+xkos:numberOfLevels
+ a rdfs:Property .
+
+clvapit:hasRankOrder
+ a rdfs:Property .
+
+
+ a skos:ConceptScheme , adms:SemanticAsset ;
+ rdfs:comment "Classification of the categories of the point of interest. The classification is based on the first level of the classification proposed by Open Street Map."@en ;
+ rdfs:comment "Classificazione delle categorie dei punti di interesse. La classificazione è basata su sul primo livello della classificazione proposta da Open Street Map"@it ;
+ rdfs:label "Point of Interest Category Classification"@en ;
+ dct:type ;
+ xkos:numberOfLevels "1";
+ adms:representationTechnique ;
+ dc:creator "Agenzia per l'Italia Digitale (AgID)"@it , "Italian Digital Agency - AgID"@en , "Team per la Trasformazione Digitale"@it , "Digital Transformation Team"@en ;
+ rdfs:label "Classificazione delle categorie dei punti di interesse"@it ;
+ dct:issued "2017-10-20" ;
+ dct:modified "2017-10-20" .
+
+
+ a skos:Concept , poiapit:PointOfInterestCategory ;
+ skos:inScheme ;
+ skos:notation "cat_1" ;
+ dct:identifier "cat_1" ;
+ poiapit:POIcategoryIdentifier "cat_1" ;
+ clvapit:hasRankOrder "1" ;
+ skos:prefLabel "Settore intrattenimento"@it ;
+ poiapit:POIcategoryName "Settore intrattenimento"@it ;
+ poiapit:POIcategoryName "Entertainment"@en ;
+ skos:prefLabel "Entertainment"@en ;
+ skos:definition "Rientrano in questa categoria tutti i punti di interesse connessi all'intrattenimento come zoo, discoteche, pub, teatri, acquari, stadi, casino, parchi divertimenti, ecc."@it .
+
+
+ a skos:Concept , poiapit:PointOfInterestCategory ;
+ skos:inScheme ;
+ skos:notation "cat_2" ;
+ dct:identifier "cat_2" ;
+ poiapit:POIcategoryIdentifier "cat_2" ;
+ clvapit:hasRankOrder "1" ;
+ skos:prefLabel "Settore svago"@it ;
+ poiapit:POIcategoryName "Settore svago"@it ;
+ poiapit:POIcategoryName "Recreation"@en ;
+ skos:prefLabel "Recreation"@en ;
+ skos:definition "Rientrano in questa categoria tutti i punti di interesse connessi allo svago quali centri sportivi, giardini, parchi, centri benessere, ecc,"@it .
+
+
+ a skos:Concept , poiapit:PointOfInterestCategory ;
+ skos:inScheme ;
+ skos:notation "cat_3" ;
+ dct:identifier "cat_3" ;
+ poiapit:POIcategoryIdentifier "cat_3" ;
+ clvapit:hasRankOrder "1" ;
+ skos:prefLabel "Settore cibo"@it ;
+ poiapit:POIcategoryName "Settore cibo"@it ;
+ poiapit:POIcategoryName "Food"@en ;
+ skos:prefLabel "Food"@en ;
+ skos:definition "Rientrano in questa categoria tutti i punti di interesse connessi al cibo quali per esempio ristoranti, fast food, bar, caffetterie, pizzerie, ecc."@it .
+
+
+ a skos:Concept , poiapit:PointOfInterestCategory ;
+ skos:inScheme ;
+ skos:notation "cat_4" ;
+ dct:identifier "cat_4" ;
+ poiapit:POIcategoryIdentifier "cat_4" ;
+ clvapit:hasRankOrder "1" ;
+ skos:prefLabel "Settore shopping/acquisti"@it ;
+ poiapit:POIcategoryName "Settore shopping/acquisti"@it ;
+ poiapit:POIcategoryName "Shopping"@en ;
+ skos:prefLabel "Shopping"@en ;
+ skos:definition "Rientrano in questa categoria tutti i punti di interesse connessi allo shopping quali per esempio, grande distribuzione, piccola distribuzione, mercati, farmacie, agenzie immobiliari, ecc."@it .
+
+
+ a skos:Concept , poiapit:PointOfInterestCategory ;
+ skos:inScheme ;
+ skos:notation "cat_5" ;
+ dct:identifier "cat_5" ;
+ poiapit:POIcategoryIdentifier "cat_5" ;
+ clvapit:hasRankOrder "1" ;
+ skos:prefLabel "Settore automobilistico"@it ;
+ poiapit:POIcategoryName "Settore automobilistico"@it ;
+ poiapit:POIcategoryName "Automotive"@en ;
+ skos:prefLabel "Automotive"@en ;
+ skos:definition "Rientra in questa categoria tutti i punti di interesse connessi al settore automobilistico quali per esempio, saloni automobilistici, benzinai, parcheggi, centri per il lavaggio auto, stazioni per ricariche elettriche auto, ecc."@it .
+
+
+ a skos:Concept , poiapit:PointOfInterestCategory ;
+ skos:inScheme ;
+ skos:notation "cat_6" ;
+ dct:identifier "cat_6" ;
+ poiapit:POIcategoryIdentifier "cat_6" ;
+ clvapit:hasRankOrder "1" ;
+ skos:prefLabel "Settore viaggi/turismo"@it ;
+ poiapit:POIcategoryName "Settore viaggi/turismo"@it ;
+ poiapit:POIcategoryName "Travel/Tourism"@en ;
+ skos:prefLabel "Travel/Tourism"@en ;
+ skos:definition "Rientrano in questa categoria tutti i punti di interesse connessi al settore dei viaggi e del turismo quali per esempio agenzie viaggi, strutture ricettive, centri di cambio valuta, info point per turisti, luoghi della cultura, luoghi freschi, ecc."@it .
+
+
+ a skos:Concept , poiapit:PointOfInterestCategory ;
+ skos:inScheme ;
+ skos:notation "cat_7" ;
+ dct:identifier "cat_7" ;
+ poiapit:POIcategoryIdentifier "cat_7" ;
+ clvapit:hasRankOrder "1" ;
+ skos:prefLabel "Settore geografico"@it ;
+ poiapit:POIcategoryName "Settore geografico"@it ;
+ poiapit:POIcategoryName "Geographical"@en ;
+ skos:prefLabel "Geographical"@en ;
+ skos:definition "Rientrano in questa categoria tutti i punti di interesse connessi al settore geografico quali incroci, strade, aree residenziali, aree industriali, isole, siti naturalistici, ecc."@it .
+
+
+ a skos:Concept , poiapit:PointOfInterestCategory ;
+ skos:inScheme ;
+ skos:notation "cat_8" ;
+ dct:identifier "cat_8" ;
+ poiapit:POIcategoryIdentifier "cat_8" ;
+ clvapit:hasRankOrder "1" ;
+ skos:prefLabel "Settore altri servizi pubblici"@it ;
+ poiapit:POIcategoryName "Settore altri servizi pubblici"@it ;
+ poiapit:POIcategoryName "Other public services"@en ;
+ skos:prefLabel "Other public services"@en ;
+ skos:definition "Rientrano in questa categoria tutti quei punti di interesse che sono connessi a generici servizi pubblici quali per esempio trasporti pubblici, bagni pubblici, bancomat, filiali di banche, sportelli postali, cestini della spazzatura, centri di raccolta rifiuti, ospedali, veterinari, ecc."@it .
diff --git a/semantic_standardization/test/it/gov/daf/semantics/api/MainAnnotationsLookup.scala b/semantic_standardization/test/it/gov/daf/semantics/api/MainAnnotationsLookup.scala
new file mode 100644
index 0000000..aff77ff
--- /dev/null
+++ b/semantic_standardization/test/it/gov/daf/semantics/api/MainAnnotationsLookup.scala
@@ -0,0 +1,39 @@
+package it.gov.daf.semantics.api
+
+import it.almawave.linkeddata.kb.repo.RDFRepository
+import scala.io.Source
+import java.io.File
+import java.nio.file.Files
+import java.nio.file.Paths
+
+import com.typesafe.config.ConfigFactory
+import com.typesafe.config.Config
+import com.typesafe.config.ConfigValueFactory
+import org.eclipse.rdf4j.rio.Rio
+import it.almawave.linkeddata.kb.repo.utils.ConfigHelper
+
+import java.nio.file.Paths
+import scala.collection.JavaConversions._
+import scala.collection.JavaConverters._
+
+object MainAnnotationsLookup extends App {
+
+ val config_annotations = ConfigHelper.injectParameter(AnnotationLookupAPI.DEFAULT_CONFIG, "data_dir", "./dist/data")
+
+ val api = new AnnotationLookupAPI()
+ api.config(config_annotations)
+ api.start
+
+// val semantic_annotation = "POI-AP_IT.PointOfInterestCategory.POIcategoryIdentifier"
+ val semantic_annotation = "CLV_AP-IT.Region.name"
+
+ println(s"given input: ${semantic_annotation}\nreturns:")
+ api.lookup(semantic_annotation)
+ .get
+ .foreach { item =>
+ val row = item.mkString("\n")
+ println(row)
+ }
+
+ api.stop
+}
diff --git a/semantic_standardization/test/it/gov/daf/semantics/api/MainOntologyAPI.scala b/semantic_standardization/test/it/gov/daf/semantics/api/MainOntologyAPI.scala
index 46aaa63..3e8e956 100644
--- a/semantic_standardization/test/it/gov/daf/semantics/api/MainOntologyAPI.scala
+++ b/semantic_standardization/test/it/gov/daf/semantics/api/MainOntologyAPI.scala
@@ -1,35 +1,64 @@
package it.gov.daf.semantics.api
-import it.almawave.linkeddata.kb.utils.JSONHelper
import com.typesafe.config.ConfigFactory
import com.typesafe.config.ConfigValueFactory
import com.typesafe.config.Config
+import java.io.File
+
import it.almawave.linkeddata.kb.repo.utils.ConfigHelper
+//import it.almawave.linkeddata.kb.utils.JSONHelper
+/**
+ * TODO: extract JUnit from here
+ */
object MainOntologyAPI extends App {
val params = Map("lang" -> "it")
- val factory = new OntologyAPIFactory()
+ val ontoapi_factory = new OntologyAPIFactory()
+
+ val conf = OntologyAPIFactory.DEFAULT_CONFIG
- val TEST_CONFIG = ConfigHelper.injectParameter(OntologyAPIFactory.DEFAULT_CONFIG, "data_dir", "./dist/data")
- factory.config(TEST_CONFIG)
+ val TEST_CONFIG = ConfigHelper.injectParameter(conf, "data_dir", "./dist/data")
+ println("TEST_CONFIG\n" + TEST_CONFIG)
- factory.start()
+ ontoapi_factory.config(TEST_CONFIG)
+ ontoapi_factory.start()
- val oapi = factory.items("clvapit")
+ val oapi = ontoapi_factory.items("clvapit")
// TEST
- // val results = oapi.extract_hierarchy(params)
+ val results = oapi.extract_hierarchy(params)
// val hjson = JSONHelper.writeToString(results)
- // println(hjson)
+ // println("\n\nEXTRACTED HIERARCHY" + hjson)
+ println("\n\nEXTRACTED HIERARCHY" + results)
+
+ val fields = List(
+ "CLV-AP_IT.Country.name",
+ "CLV-AP_IT.City.name",
+ "CLV-AP_IT.Province.name",
+ "CLV-AP_IT.Region.name")
- val fields = List("CLV-AP_IT_Country_name", "CLV-AP_IT_City_name", "CLV-AP_IT_Province_name", "CLV-AP_IT_Region_name")
val hierarchy_props = oapi.extract_hierarchy_properties(params, fields)
+ println("\n\nEXTRACTED HIERARCHIES\n" + hierarchy_props.mkString("\n"))
+
+ // ###########################################################################################
+
+ println("\n##########################################")
+ println("POI-AP_IT EXAMPLE")
+
+ // val fields = List("POI-AP_IT.POICategoryClassification.POICategoryName")
+
+ val oapi_poi = ontoapi_factory.items("poiapit")
+ val poi_results = oapi_poi.extract_hierarchy(params)
+ println("HIERARCHY ELEMENTS\n" + poi_results.mkString("\n"))
- val json = JSONHelper.writeToString(hierarchy_props)
- println(json)
+// val poi_hierarchy_props = oapi.extract_hierarchy_properties(
+// params,
+// List("POI-AP_IT.POICategoryClassification.POICategoryName"))
+// println("\n\nEXTRACTED HIERARCHIES\n" + poi_hierarchy_props.mkString("\n"))
- factory.stop()
+ // ###########################################################################################
+ ontoapi_factory.stop()
}
diff --git a/semantic_standardization/test/it/gov/daf/semantics/api/MainVocabularyAPI.scala b/semantic_standardization/test/it/gov/daf/semantics/api/MainVocabularyAPI.scala
index a88c864..49c5313 100644
--- a/semantic_standardization/test/it/gov/daf/semantics/api/MainVocabularyAPI.scala
+++ b/semantic_standardization/test/it/gov/daf/semantics/api/MainVocabularyAPI.scala
@@ -12,21 +12,27 @@ object MainVocabularyAPI extends App {
val logger = Logger.underlying()
- val ontofactory = new VocabularyAPIFactory()
+ val voc_factory = new VocabularyAPIFactory()
+
+ // val config = ConfigHelper.load("conf/vocabularies_api.conf")
val TEST_CONFIG = ConfigHelper.injectParameter(VocabularyAPIFactory.DEFAULT_CONFIG, "data_dir", "./dist/data")
- ontofactory.config(TEST_CONFIG)
+ voc_factory.config(TEST_CONFIG)
- ontofactory.start()
+ voc_factory.start()
- println("ITEMS: " + ontofactory.items)
+ // println("\nconfigured vocabulary datasets:")
+ // println(voc_factory.items.mkString("\n"))
+ // println("\n\n")
- val ontoapi = ontofactory.items("Istat-Classificazione-08-Territorio")
+ // val vocapi = voc_factory.items("Istat-Classificazione-08-Territorio")
+ val vocapi = voc_factory.items("POICategoryClassification")
- val json_tree = ontoapi.extract_data(params)
+ val json_tree = vocapi.extract_data(params)
// val json = JSONHelper.writeToString(json_tree)
- // logger.debug(json)
+ // logger.debug("JSON\n" + json)
+ println("json_tree: " + json_tree)
val results = json_tree.map {
_.toList.map { item =>
@@ -34,13 +40,16 @@ object MainVocabularyAPI extends App {
}.toSeq
}.toSeq.slice(0, 2)
- val json_results = JSONHelper.writeToString(results)
- logger.debug(json_results)
-
- val keys = ontoapi.extract_keys(params)
- logger.debug("\n\nKEYS: {}", keys.mkString(" | "))
+ val keys = vocapi.extract_keys(params)
+ logger.debug("\n\nKEYS:\n{}", keys.mkString(" | "))
- ontofactory.stop()
+ logger.debug("JSON RESULTS: ")
+ results.foreach { result =>
+ // val json_result = JSONHelper.writeToString(result)
+ // logger.debug(json_result)
+ println("json_result: " + result)
+ }
+ voc_factory.stop()
}
diff --git a/semantic_validator/app/generated_controllers/semantic_validator.yaml.scala b/semantic_validator/app/generated_controllers/semantic_validator.yaml.scala
index 9c2cb21..7be7c2d 100644
--- a/semantic_validator/app/generated_controllers/semantic_validator.yaml.scala
+++ b/semantic_validator/app/generated_controllers/semantic_validator.yaml.scala
@@ -19,6 +19,16 @@ import javax.inject._
import java.io.File
+import play.api.mvc.{Action,Controller}
+import play.api.data.validation.Constraint
+import play.api.i18n.MessagesApi
+import play.api.inject.{ApplicationLifecycle,ConfigurationProvider}
+import de.zalando.play.controllers._
+import PlayBodyParsing._
+import PlayValidations._
+import scala.util._
+import javax.inject._
+import java.io.File
import scala.collection.JavaConversions._
import play.api.inject.ApplicationLifecycle
import scala.concurrent.Future
@@ -35,7 +45,7 @@ import play.api.Logger
package semantic_validator.yaml {
// ----- Start of unmanaged code area for package Semantic_validatorYaml
-
+
// ----- End of unmanaged code area for package Semantic_validatorYaml
class Semantic_validatorYaml @Inject() (
// ----- Start of unmanaged code area for injections Semantic_validatorYaml