# Ontology-Driven Semantic Analysis of Tabular Data:
## 4 Software Implementation
### Data Export Module  
After receiving the semantic markup of the table at the previous stage, it is necessary to export the received information. The data export module is responsible for this. It takes as input a table with cell values, a semantic markup of the table, and auxiliary data structures that were filled in at the ontology loading stage (lists of classes, objects, properties, relations, and dictionaries for converting a name into an object reference, a property, and a relation). The module goes through each row and each column sequentially. For each cell, one can define col_idx and row_idx--column index and row index, respectively. When processing a cell, two conditions must be met for a successful export:  
1. The index of the column in which the col_idx cell is located must be present in exactly one of the following dictionaries: _col2 object_, _col2 predicate_, and _col2 date_
2. The row index in which the row_idx cell is located must be present in exactly one of the following dictionaries: _row2 object_, _row2 predicate_, and _row2 date_. The fulfillment of these conditions allows for the determination of the object and predicate to which the value of this cell refers. For example, if a row contains an object and a column contains a property, then the numeric value at the intersection of the row and column will be the property of that object. Once the object and predicate are defined, the cell value must be checked to determine if it is of the appropriate type. To do this, using col2 predicate or row2 predicate (depending on the structure of the table), the name of the predicate is taken, then using name2 data_property or name2 object_property, a reference to the property or relation object is determined. An object describing a property or relation has detailed information about the predicate, such as domain, range, whether the predicate is functional, inverse, and so on. With the help of an object with a description of the property, a number of checks are carried out:  
1. Whether the class of the object on which the property will be set belongs to the domain of the property. 2. Whether the cell value belongs to the range of the predicate (or is it possible to cast the cell value to the required type, for example, convert an integer to a real number). If the predicate is a property, then the cell value must contain a string or a number. If the predicate is a relation, then the cell must contain a subject or a list of subjects. 3. Whether the given predicate has an inverse predicate. This condition is relevant only for relations between objects. If the predicate has a predicate inverse to it, then when adding a property to the row/column object, it will be necessary to add the inverse property to the object from the table cell (for example, the lake is in the region, then the region contains the lake). 4. The functionality of the predicate is checked. This condition does not allow more than one property of a given type to be added to an object (for example, a person can have only one age) if this predicate is specified as a functional predicate. If all conditions are met, then the triplet (object, predicate, cell value) is written into the ontology. Moreover, if the predicate is a relationship between objects, then the cell value can contain many objects (for example, a region contains a list of cities). In this case, a triplet must be added for each subject from the cell. As a result of the operation of the export module, the resulting table markup, together with the table data, is converted into triplets, which are then added to the ontology. The result of the work is shown in Figure 5.  
After completing the process of filling the OWL ontology, one can create queries that retrieve related data about water resources and regions; below are examples of useful queries:  
1. Query 1 implements the derivation of water objects, the regions to which these objects belong and the population of this region in the time interval. 2.