## 5 Methodology: AGO Construction
### Third Phase: Database Building in Neo4j  
The third stage implies building the knowledge-graph database and making the ontology available for its use via programmatic interfaces. For this purpose, a database to store the data was selected. In this case, Neo4j ([[https://neo4j.com/neo4j-graph-database/](https://neo4j.com/neo4j-graph-database/)]([https://neo4j.com/neo4j-graph-database/](https://neo4j.com/neo4j-graph-database/)) accessed on 24 July 2021) _neo4j-community-4.2.0_) was chosen as the database for storing the ontology. To represent the ontology as a graph in Neo4j following the standards, the neosemantics plugin (n10s) ([[https://github.com/neo4j-labs/neosemantics](https://github.com/neo4j-labs/neosemantics)]([https://github.com/neo4j-labs/neosemantics](https://github.com/neo4j-labs/neosemantics)) accessed on 4 August 2021) is required. This enables importing and exporting the ontology graph from and into OWL files for further use. Using _n10s Release 4.1.0_, a Cypher query can be used to import the OWL ontology from a local directory or a URL. In addition, the query can be passed with some specific parameters that determine the names given to the elements in the database. The specific query used to structure the ontology is presented in Figure 6.  
The imported data are further processed by including specific Neo4j labels to classify the nodes according to the core concepts. Grouping nodes with tags related to the first level of classes in the hierarchy (i.e., Action, Object, etc.) helps optimization of the queries to the ontology because the consultation is undertaken for a smaller subset of nodes. Consequently, the ontology-based applications developed in later works should be optimized in terms of ontology consultation. Figure 5: Object property and data property triple examples represented as a graph. Figure 6: Main cypher query used to import the ontology. The resulting graphs' main characteristics are summarized in Table 2. AGO has a total of 523 nodes and 1365 relationships. Some of the class nodes have related properties to provide the user with complete semantic information about each element. These are known as property keys in Neo4j. When including the elements in Neo4j, the features of each element are added as node properties. Table 3 summarizes the included property keys with the related OWL syntax equivalence. \begin{table}
\begin{tabular}{c c} \hline \hline
**Ontology Name** & **AGO** \\ \hline Version & 1.1.0 \\ \hline Neo4j-labels & Context, Object, Action, Event, dataProperty, \\  & objectProperty, metadata \\ \hline Number of Classes (Nodes) & 390 \\ \hline Number of Objects & 296 \\ \hline Number of Actions & 42 \\ \hline Number of Events & 24 \\ \hline Number of Contexts & 33 \\ \hline Number of dataProperties & 57 \\ \hline Number of objectProperties & 64 \\ \hline Number of Relations & 1367 \\ \hline Relationship types & subClassOf, subPropertyOf, DOMAIN, RANGE \\ \hline Number of subClassOf Relations & 398 \\ \hline Number of subPropertyOf Relations & 119 \\ \hline Number of DOMAIN Relations & 364 \\ \hline Number of RANGE Relations & 486 \\ \hline Property Keys & label, name, comment, URI, type \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Main characteristics of the ontology. \begin{table}
\begin{tabular}{c l c} \hline \hline
**Property Key** & **Description** & **OWL Syntax** \\ \hline Uid & A unique identifier is included by default to each element. & - \\ \hline Label & Human-friendly label. Defined for all elements. & rdfs: label \\ \hline name & The name of each class is given in CamelCase. Defined for all the elements & - \\ \hline comment & A brief description of the defined element nature. The user should review the comment to understand how the elements are understood in the automotive domain. & rdfs: comment \\ \hline URI & URIs are used in OWL as object identifiers. Their structure is formalized by the ontology language to be a valid URL where the complete ontology is available and there is a unique name for each class.