## 4 The REFINERY Platform
### Data Preparation
However, domain experts generally do not have the necessary IT knowledge to implement the processing steps themselves. For the REFINERY Platform, we have therefore developed an ontology approach that allows domain experts to specify in a simple way how the data needs to be processed for a given use case. In doing so, we use RDF/XML (see [[https://www.w3.org/TR/rdf-syntax-grammar/](https://www.w3.org/TR/rdf-syntax-grammar/)]([https://www.w3.org/TR/rdf-syntax-grammar/](https://www.w3.org/TR/rdf-syntax-grammar/)); accessed on 6 February 2023) for the internal representation of the ontology. We have implemented a processing engine for our ontology that automatically applies the specified data processing rules to the data in question [210]. Figure 5 shows a simplified excerpt from such an ontology. A data processing rule of the ontology always consists of three segments. These three segments correspond to the three questions 'What? ', 'How? ', and 'To what end?'. First, data items must be selected to which the processing rules should be applied. Basically, all cleansed data on the information level can be selected. For instance, all temperature data should be converted into a data product. With this selection, however, the domain expert gains no insight into actual data items but only into which types of data are available and which attributes these items have. Therefore, this does not pose a threat to the privacy requirements of individual data producers. After the source data have been selected, the core part of the data processing rule must describe which kind of processing has to be performed. To this end, we support the three key operators from functional programming, namely the map operator, the filter operator, and the reduce operator. These operators are each applied to a data sequence (e.g., to all data items from temperature sensors). In the following, \(D\) and \(E\) denote two arbitrary data types and \(\mathbb{B}\) stands for Boolean data whereas \(a_{i}\) and \(b_{i}\) are instances of these data types. \[\text{map operator}:(D\to E)\times(a_{0},\dots,a_{n})\to(b_{0},\dots,b_{n})\]  
The map operator applies a unary function to all \(n\) elements of the sequence. This results in a new sequence consisting also of \(n\) elements--namely the \(n\) elements from the original sequence after they have been processed. The data type of the elements may change during processing. In our example, the domain expert could use a map operator to change the unit of temperature data from Celsius to Fahrenheit. \[\text{filter operator}:(D\to\mathbb{B})\times\underbrace{(a_{0},\dots,a_{n})}_ {n}\to\underbrace{(a_{0},\dots,a_{n})}_{m}\mid m\leq n\]  
The filter operator validates all \(n\) elements of a sequence using a unary predicate logical expression. The result is a sequence with the \(m\) elements from the original sequence for which the expression is evaluated to true (\(0\leq m\leq n\)). However, the elements themselves  
Figure 5: A Data Processing Rule Specified in the Ontology Provided by the REFINERY Platform. are not changed in the process. In our example, the domain expert could use a filter operator to filter out the temperature data that are below a certain threshold. \[\text{reduce operator}:(E\times D\to E)\times(a_{0},\dots,a_{n})\times E\to E\]  
The reduce operator aggregates the \(n\) elements of a sequence to a single result value. Unlike the map and filter, reduce applies a binary function. With this function, the reduce operator initially combines the first element of the sequence with an initial value. The result is then combined with the second element of the sequence using the same function. This is repeated until all elements of the sequence have been condensed to a single value. In our example, a reduce operator could calculate the average temperature of the \(n\) data items. We apply the functional programming paradigm since functional programming is very well suited for composing such functions at runtime and applying them to arbitrary data streams.