# A Semantic Model for Enhancing Data-Driven Open Banking Services
## 3 Semantic Model
### Building the Knowledge Graph  
Once the OBO ontology has been defined, the data involved can be integrated and consolidated by following the defined semantic model in an RDF repository. The information is then stored in the form of a knowledge graph with a homogeneous format, regardless of the source and avoiding semantic inconsistency. In order to clarify the technology that was used to deploy the model, Table 7 summarizes the package and languages that were involved in each step of the process. This process is illustrated in Figure 2, showing that a series of mapping functions were implemented using RDFLib ([[https://rdflib.dev/](https://rdflib.dev/)]([https://rdflib.dev/](https://rdflib.dev/)) (accessed on 24 November 2022)) to automatically translate the customer's data from the issued invoices and bank statements into RDF format, hence populating the knowledge graph derived from the OBO scheme.  
* Mapping invoice data into RDF. These data are obtained from the ERP systems of the companies involved in CSV format, which comprise four different files: (1) for open invoices, (2) for closed invoices, (3) for companies that issue invoices to customers, and (4) for customer information, by means of the _Customer_ class in OBO. In addition, contents regarding classes _Item_, _Company_, and _Customer_ are also stored in the repository.
* Mapping PSD2 statements into RDF. Data concerning bank statements are collected from the corresponding APIs (of banking entities) in JSON format. The service client provides the user with an access token with which all bank movements can be accessed. Examples of JSON files in Code Listings A1 and A2 in Appendix A show information obtained from the PSD2-compliant API services of banks concerning the customers and their bank accounts. Classes _StatementCustomer_ and _Statement_, among others, are populated in the form of semantic instances (individuals).  
Once the RDF triplets corresponding to bank statements and invoices have been created, they are stored in the RDF repository, which is deployed by means of a Stardog ([[https://www.stardog.com/](https://www.stardog.com/)]([https://www.stardog.com/](https://www.stardog.com/)) (accessed on 22 November 2022)) instance service. Therefore, the integrated data can be efficiently queried through a SPARQL endpoint. In addition, the RDF repository is powered by an SWRL inference engine to explode different sets of semantic rules designed to conduct classification and validation tasks on financial subjects, which, together with the semantic reconciliation mechanisms, are explained in the next section.  
\begin{table}
\begin{tabular}{l l} \hline \hline
**Object Properties** & **Description Logics** \\ \hline \multirow{2}{*}{participating} & \(\exists\) participating Thing \(\sqsubseteq\) StatementsCustomer \\  & \(\top\sqsubseteq\)\(\forall\) participating AccountObj \\ \hline
**Data properties** & **Description logics** \\ \hline \multirow{4}{*}{customer BirthDate} & \(\exists\) customerBirthDate Datatype \\  & Literal \(\sqsubseteq\) StatementsCustomer \\  & \(\top\sqsubseteq\)\(\forall\) customerBirthDate Datatype dateTime \\  & \(\exists\) customerDocument Datatype \\ customerDocument & Literal \(\sqsubseteq\) StatementsCustomer \\  & \(\top\sqsubseteq\)\(\forall\) customerDocument Datatype string \\  & \(\exists\) customerNames Datatype \\ customerNames & Literal \(\sqsubseteq\) StatementsCustomer \\  & \(\top\sqsubseteq\)\(\forall\) customerNames Datatype string \\  & \(\exists\) address Datatype Literal \\ address & \(\sqsubseteq\) StatementsCustomer \(\top\sqsubseteq\)\(\forall\) address \\  & Datatype string \\  & \(\exists\) email Datatype Literal \(\sqsubseteq\) StatementsCustomer \\ email & \(\top\sqsubseteq\) email Datatype string \\  & \(\exists\) phone Datatype Literal \(\sqsubseteq\) StatementsCustomer \\ phone & \(\top\sqsubseteq\)\(\forall\) phone Datatype string \\ \hline \hline \end{tabular}
\end{table}
Table 6: Data and object properties of class StatementsCustomer.