Ontology Development for Detecting Complex Events in Stream Processing: Use Case of Air Quality Monitoring

: With the increasing amount of data collected by IoT devices, detecting complex events in real-time has become a challenging task. To overcome this challenge, we propose the utilisation of semantic web technologies to create ontologies that structure background knowledge about the complex event-processing (CEP) framework in a way that machines can easily comprehend. Our ontology focuses on Indoor Air Quality (IAQ) data, asthma patients’ activities and symptoms


Introduction
The rise of sensor networks and smart devices has led to an unprecedented increase in data collection, presenting a significant challenge in real-time processing.The Internet of Things (IoT) has revolutionised the way things are connected and is the most important big data project identified by Gartner [1].The ability to react quickly to changing trends and provide instantaneous business intelligence has become a crucial factor in determining the success or failure of a company.Detecting complex events enables intelligent decision making by identifying patterns and correlations, and real-time analysis can yield profits and improve decision making.However, real-time streaming is becoming increasingly challenging with the proliferation of billions of IoT devices, including RFIDs, sensors, remote sensing satellites, and intelligent devices.These devices generate vast amounts of heterogeneous event streams that require constant observation and analysis [2].Among these devices, sensors are commonly used to detect conditions that may lead to complex events.Reacting swiftly in a mission-critical situation can significantly impact various domains, including healthcare, energy, transportation, nuclear, agriculture, and so on.Detecting complex events in real-time, especially when they cannot be identified on the fly, is a formidable challenge in this context.The use of complex event processing (CEP) has become increasingly popular in IoT deployments due to its ability to process real-time event streams effectively in dynamic business environments [3].
Unlike traditional offline analysis methods used in relational databases, CEP continuously processes and analyses high-speed data streams [4].It is an exceptional tool for managing various data streams, providing actionable insights, excelling at correlating distributed data to identify and respond to critical situations instantaneously [5].CEP has proven to be efficient at processing high-frequency data streams in real-time [3].Each stream is considered an event in CEP, with corresponding event objects carrying general meta-data such as time-stamp, event ID, and event-specific information, e.g., sensor ID and measured data.Although a single event may not have a useful meaning, it must be correlated with other events to gain a significant meaning [3].CEP enables the analysis of continuous streams of events, aiding in identifying the existence of complex sequences of events [6].
Despite the recognised importance of CEP, its expressivity is limited when it comes to detecting large numbers of complex events in real-time.The increasing demand for realtime responses in IoT applications poses challenges in collecting and structuring data in a knowledge base.It is in this context that ontologies emerge as a pivotal tool.They have been extensively investigated for capturing background and expert knowledge from various perspectives, integrating data from heterogeneous sources, building knowledge bases, knowledge acquisition, analysing data streams, and managing knowledge and system dynamism [7,8].Ontologies can greatly improve event processing by integrating semantics, allowing for the use of definitions, background knowledge, and behaviour rules [9].This provides a more efficient declarative event processing and detailed descriptions of complex events, patterns, and reactions to situations, which can all be directly transformed into operational efficiency [10].
Incorporating semantics into conventional CEP systems enhances the recognition capabilities of events and provides an enhanced understanding of event implications, resulting in augmented situational awareness and proactive responses.The motivation for this article lies in the following implications of integrating semantics into classical CEP for IoT-enabled systems.

1.
Improved event detection: The primary motivator for improved real-time event detection in stream processing is often hindered by the CEP approaches' reliance on syntactic pattern matching, limiting the expressiveness and efficiency of event detection.

2.
Context-aware event processing: In IoT scenarios, understanding events in context is critical.Semantic integration enables the consideration of context, leading to more precise event recognition.

3.
Expressive event pattern definition: Developing complex event patterns with semantics allows for richer and more nuanced event definitions, accommodating a broader range of real-world scenarios.4.
Real-time event detection: Real-time processing demands rapid event detection.Semantic integration can expedite event recognition, enabling timely responses.

5.
Enhanced reasoning and inference: Semantics facilitates advanced reasoning and inference capabilities, empowering systems to make more informed decisions based on detected events.6.
Personalised IoT applications: Personalisation is increasingly crucial in IoT applications.Semantic integration can enable personalised event processing and responses tailored to individual user needs.7.
Scalability and flexibility: Achieving scalability and flexibility in event processing systems is vital.Semantic integration can contribute to the scalability and adaptability of CEP systems.
This research is driven by the need to detect complex events in stream processing for indoor air quality monitoring.This article provides a motivating example of how semantic web technology integration can play a pivotal role in identifying complex events related to environmental factors, asthmatic conditions, asthma symptoms, and daily activities.Therefore, this work endeavoured to find answers to the following questions: 1.
How can we organise knowledge about the CEP framework for IoT applications in a way that machines can interpret?2.
How can structured knowledge integration enhance data analysis and complex event detection, and what is the impact of integrating semantic web technologies on the traditional CEP in real-time complex event detection, making it smarter?
To address the outlined motivations and research questions, we proposed the development of a structured ontology tailored to IoT applications meticulously integrated into the CEP framework.Through practical use cases and competency questions (CQs), we demonstrated the efficiency and effectiveness of this integrated approach in detecting complex events within dynamic event streams.
The remainder of this article is organised as follows: Section 2 provides a comprehensive literature review, examining current research in stream processing, complex event detection, ontologies, and their applications in air quality monitoring.Section 3 outlines our methodology, detailing the data collection process, ontology development, and integration into the CEP framework.This section delves into the specifics of ontology development for air quality monitoring, including design, knowledge acquisition, reasoning, and validation.In Section 4, we discuss the integration of ontology into the CEP framework and its impact on event detection.This section also presents a real-world use case for air quality monitoring, showcasing the practical application of our approach.A comprehensive discussion of our findings, highlighting achievements, limitations, and avenues for future research, was also provided in this section.Finally, Section 5 provides a summary of our conclusions, emphasising the contributions and practical significance of this study.

CEP and IoT
CEP has emerged as a popular solution in the field of IoT research, attracting considerable attention from researchers for its widespread use of IoT devices and its ability to uncover a plethora of innovative applications.These applications require efficient and seamless real-time processing, analysis, and correlation of event streams originating from various data sources.In this section, the related work was focused on IoT applications needing CEP, following early work on complex event processing.In the study [11], the application of Timed Petri Net was instrumental in detecting complex events and modelling their RFID complex event-processing engine.Several studies have proposed different techniques and frameworks for detecting complex events, which have evolved over time to provide a reactive solution.One approach involves using primitive events gathered through the Expressive Stream Language (ESL) and a developed semantic for deriving rule patterns.Another approach [12] employs an automata-based system that uses SQL-like SASE language, while another [13] uses temporal constraints for discovering composite events in an RFID event detection application named RCEDA.
Middleware architectures have also been proposed to integrate wireless sensor networks and RFID systems for real-time analysis of streaming data [14].These middleware use event processing language to define complex events, filter, group, aggregate, and construct them.Dong et al. [15] implemented CEP in their RFID middleware to identify complicated events.Furthermore, event processing systems have been designed using different processing algorithms, such as automata-based processing algorithms, TESLA language, and event meta-modelling [16,17].These systems have been implemented in enterprise information systems using RFID data.Lastly, a CEP-based information middleware has been proposed to develop real-time trajectory-based services [18].Dunken et al. [19] suggested a reference architecture using CEP for the real-time analysis of traffic data in decision-support systems.Their Intelligent Transportation Management System prototype uses event-processing agents and rule-based representation of local traffic expertise.However, the proposed solution requires further evaluation for more distributed implementation.Integrating background knowledge representation through ontologies can enable the automatic translation of natural language interfaces into ontological representations within traditional CEP frameworks.

Ontology for Complex Events
Ontologies play a crucial role in semantic web technologies and provide an explicit specification of conceptualisation.According to Gruber's definition, an ontology is an explicit specification of a conceptualisation, where it defines the vocabulary with which facts about the domain are expressed.With ontologies, it is possible to model knowledge about events and concepts structured in a knowledge base [20].Numerous studies have underscored the significance of ontologies in diverse domains, showcasing their applicability in understanding complex events.Notably, researchers have utilised ontologies to capture context, detect patterns, and enable semantic correlation of events.For instance, Sasa et al. [21] linked reactive rules with ontologies to enable the detection of similar complex event patterns.Moser et al. [22] focused on semantic event correlation, recognising its necessity in relating events from various sources for pattern detection.Paschke [23] proposed a language for semantic CEP pattern design.In contrast, we propose a background knowledge framework using existing ontology languages, allowing for reasoners and standard OWL language support.In the context of smart homes, 'E-care@home' [24] demonstrated the importance of ontological structures in managing complex events domestically.Similarly, the 'Agri-IoT' project [25] leveraged ontologies for intelligent farming applications, addressing complex event monitoring in agriculture.Semantic ontologies were employed in healthcare to navigate intricate healthcare operations and patient care [26].Furthermore, in countering terrorism, complex event processing and ontologies were integrated for the real-time detection of online terrorist content [27].These studies collectively underscore the versatility and applicability of ontologies in diverse domains.However, several gaps remain in the literature.In the context of smart homes, further research should delve into practical implementation challenges and the scalability of ontological context-aware systems.Agriculture requires the exploration of ontological interoperability and standards for seamless data exchange.Healthcare would benefit from practical guidelines for ontological structure implementation.In the realm of counter-terrorism, there is a need to evaluate the real-world effectiveness of integrated systems and their adaptability to evolving online threats.Lastly, a cross-domain gap exists in exploring how ontological structures from various domains can be harmonised to address complex events transcending multiple domains.

Air Quality Monitoring with CEP
Air pollution poses a significant threat to the health of millions of people globally by contributing to respiratory and cardiovascular diseases.It is crucial to monitor air quality in real-time to prevent health complications and fatalities.The framework proposed in [28] leverages the concepts of CEP, software-defined networks, and Fog Computing to predict air quality in near real-time.The real-time calculation of pollutant concentration and patterns is handled by CEP.In [29], an intelligent transportation system model was introduced that utilises CEP and CPNs to determine traffic levels and AQI.In [30], the authors propose using CEP to calculate air quality levels in Spain and Morocco, extracting only useful information in real-time.
The authors of [31,32] have focused on the relationship between asthma attacks and pollutant exposure.Additionally, Ref. [33] reviewed the impact of outdoor and indoor pollutants on individuals with asthma.They found that these pollutants pose a significant threat to the health of asthma patients and can lead to more asthma symptoms, exacerbations, and reduced lung function.Further reviews were performed by [34] that correlate asthma development to air pollution caused by industrial activities, disinfection by-products, traffic, and e-cigarettes/tobacco.The author highlights the role of air pollutants as stimulants of childhood asthma.The proposed framework in [35] effectively monitors and analyses environmental triggers of asthma attacks, which can aid healthcare professionals in better managing and preventing asthma attacks.The potential for early detection of asthma exacerbations can be facilitated by machine learning algorithms over traditional paper-based action plans, as proposed by the authors in [36].However, this approach lacks real-time capabilities as the utilisation of smartphone apps linked to digital spirometers and inhalers for electronic data collection will significantly enhance the predictive ability of these algorithms.The proposed approach by the authors in [37] effectively identifies asthma risk factors from multiple data streams by emphasising the crucial role of time lags between events for correlation.
In summary, while prior studies have provided foundational knowledge in stream processing, complex event detection, and air quality monitoring, this research aims to bridge the gap by developing and integrating ontologies to improve event detection accuracy and facilitate natural language interfaces for complex event specifications and detection in the context of IoT applications.

Ontology Development for Complex Events
Ontology is an explicit specification of a conceptualisation [38].An ontology is a structured representation of concepts, object property relations, instances, data property relations, axioms, and rules [39].It is created using a machine-readable language to develop explicit and formal conceptualisations of a specific domain [38].The three commonly used standards of ontology languages are Web Ontology Language, Resource Description Framework, and Description Logic [40].The focus of this work is to develop an ontology that structures background knowledge about CEP in a machine-interpretable way, allowing for the detection of complex events.

Ontology Development Methodology
Ontology has become a standard practice for describing a shared vocabulary in information sharing and reuse [41].Developing an ontology can be a challenging and time-consuming task, but it is crucial to follow a methodology that is similar to software development [42], as it is an iterative process that involves technical complexity.Developing an ontology does not have a precise methodology, according to Kapoor [43].Similarly, Noy [44] points out that selecting an ontology design methodology is up to the developer and depends on the intended application or purpose, as noted in Aminu's review [41].After reviewing the relevant literature, it was discovered that the prevalent methodologies employed include Noy and McGuiness methodology, Gruninger and Fox's methodology, Uschold and King's methodology, and Methontology, in addition to NEON and other methodologies [41].
Noy and McGuinness methodology follows an iterative process that includes incorporating more details in each iteration and making modelling decisions at various stages of the process [44].However, this approach was not considered in our study due to the lack of ontology evaluation and documentation.
Uschold and King's methodology was designed based on the Enterprise's experience.This methodology was not considered due to its lack of description of activities, processes, techniques, or lifecycle.
The Methontology methodology makes the process of building ontologies at the knowledge level easier, which includes development processes, techniques for each activity, and an evolving prototypes-based life cycle, as described in [45].Among the known methodologies, Methontology is considered the most developed [46].However, it lacks consideration for competency questions, and there is a need for recommendations for pre-development processes.
Gruninger and Fox's methodology, TOVE (Toronto Virtual Enterprise), is a methodology based on scenarios that elucidates the functionality of an ontology [47].The primary goal of this methodology is to identify queries, objects, and predicates in the ontology [48].Nevertheless, we chose not to utilise this approach for our work since it does not take into account the incorporation of pre-existing ontologies.
NeOn Methodology offers guidelines for developing ontologies without imposing a rigid workflow [49,50].The method consists of a glossary that explains the processes and activities required for ontology development.Additionally, two ontology life cycle models, namely the waterfall and iterative models, are provided along with methodological guidelines for various processes and activities.These guidelines are explained in detail in terms of goals, inputs, outputs, and associated constraints.Additionally, they are presented procedurally with workflow specifications and supported by empirical examples [49,51,52].The NeOn methodology emphasises the importance of reusing and re-engineering both ontological and non-ontological knowledge resources, making it a valuable tool for ontology development.This methodology has been demonstrated in [53].
This methodology was chosen for our work due to its effectiveness in constructing ontologies by leveraging existing knowledge-aware resources and adapting them to specific contexts.Additionally, it supports the continuous development of ontology networks in distributed environments, which aligns with the requirements of our study.To ensure that the ontology developed satisfies the competency questions, we must validate it.The methodology proposed here offers a robust framework for ontology evaluation, which includes proving consistency, completeness, properties, relationships, and classes through the use of competency questions (CQs).The approach is characterised by its comprehensive and detailed documentation of every stage of ontology development, which facilitates accurate and rigorous evaluation.
The ontology was developed following the step-by-step waterfall life cycle models, with explicit details and guidelines for every process and activity of ontology development.The choice of the waterfall life cycle model was motivated by its suitability for our specific ontology development needs.The waterfall model is characterised by its structured and sequential approach, where each phase must be completed before moving on to the next.This level of rigour and structure was deemed essential in ensuring the methodical and thorough development of the complex event ontology.This allowed us to provide explicit details and guidelines for each process and activity involved in ontology development, enhancing transparency, traceability, and quality assurance.The proposed methodology for developing the complex event ontology is shown in Figure 1, describing each phase of the life cycle model.Initiation: The first step of our work was to gather all the necessary requirements for developing the ontology and ensuring that it meets all the expected standards.To accomplish our goal, we conducted a thorough investigation by reviewing a vast amount of literature and analysing research documents from different sources.This helped us in developing a highly detailed Ontology Requirements Specification Document (ORSD).The ORSD outlines the ontology's purpose, scope, implementation language, intended users, intended use, and competency questions (CQs) in great detail.The ORSD is depicted in Figure 2.

ONTOLOGY REQUIREMENTS SPECIFICATION DOCUMENT FOR COMPLEX EVENT PROCESSING USING NEON METHODOLOGY Task 1. Identify purpose, scope and level of formality
The purpose of building the CE Ontology is to provide a reference for the representation of knowledge -Detecting complex real-time events on the fly of a given scenario, Serve as a knowledge base for the traditional CEP to automatically filter out complex events and determine possible early warnings to mitigate harmful situations, -Detect potential poor air quality, Asthma patient's indoor activities, and symptoms

Task 2. Scope
The ontology will focus on the knowledge base for detecting complex events

Task 3. Implementation
The ontology will be implemented with Protégé.Also, it has to be conceptualised and formalised to classify classes and the relation between instances and classes.
Use 1: Determine complex patterns that exceed the average threshold Use 2: Background knowledge for a traditional CEP framework Use 3: Filter event conditions using a rule base Task 6. Identify requirements.
For specifying the ontology requirements, we used the competency questions techniques.Competency questions like: CQI What is the activity?CQ2 What causes the activity?CQ3Where is the source of activity?CQ4 What are the main activities?CQ5 What are the major approaches?CQ6 What tools are used to measure?CQ7 Can it filter out atomic and complex events?CQ8 Can it tell the threshold of activities?CQ9 Can indoor air quality be related to the severity of asthma?CQI0 Can it tell the time of detection?CQI1 Can it tell the activities of patients?CQI2 Can it be integrated into the CEP framework to automatically detect complex event patterns in real-time?Task 6. Pre-glossary of terms Activities, sensor, air quality observation, asthma patient

Reuse:
In this phase, we used existing resources to describe the scenario.While an ontology that met all of our requirements could not be found, we reused resources found in the air quality, asthma, and event ontologies.We categorised these ontologies into upper, reusable, and application layers and used the Semantic Sensor Net Ontology for the sensor layer.
Merging: There was a need for merging since our work reused different ontologies of different domains to create a new ontology to suit our goals.Therefore, the ontology was aligned using OpenCyc and Event-Model-F event-based, respectively.These ontologies were selected because of the key features representing the upper ontology, domain ontology, and linking the different ontologies to create complex events.
Re-engineering: Re-engineering non-ontological resources was required to align with our goals as the existing ontologies did not entirely fulfil our goals.
Design: In this phase, we consolidated the requirements collected from earlier phases and defined the essential characteristics of each module of our framework.We then translated this information into a formalised conceptual model, ensuring that all technical details were accurately represented.
Implementation: The implementation of the ontology was carried out using Protégé.The evaluation of the ontology involved a case study that explored the relationship between indoor air quality and an asthma patient.The evaluation process compared the ontology with the ontology requirement specification document, which outlines the ontology requirements and competency questions.This comparison ensured that the ontology was built correctly and in compliance with the specified ontology requirements.
Maintenance: This phase will recur, with updates to the ontology and corrections made during the design phase, following the Waterfall life cycle model.

Architecture of Proposed Framework
The framework depicted in Figure 3 combines semantic web technology with the conventional CEP detection mechanism, boosting its ability to identify more complex events.The architecture of the framework is composed of Monitoring, Event Analysis, and Application layers.The CEP framework continuously receives events from diverse sources and processes them instantaneously to detect complex events using predefined rules.The framework exploits ontologies and background knowledge developed to incorporate semantic technology, providing an unambiguous and formal representation of entities, concepts, and their interdependencies.

Monitoring Layer
This layer is the first layer of the proposed framework that performs the task of gathering and processing the event data from multiple sources and sending them to the event analysis layer for further analysis.
-Event Source Sub-Layer: The layer in question is tasked with the responsibility of creating events and transmitting data to the CEP engine for further analysis.The sources from which these events are generated can be any system, device, or application capable of generating events.These events can manifest in different types, including but not limited to financial transactions, temperature readings, and customer behaviour data.In this particular study, the work involved monitoring the continuous real-life activities of asthma patients, including their symptoms and sensor readings from different parameters.-Data Ingestion Processing: Data ingestion is a critical task in the CEP framework's monitoring layer.It involves receiving event data from various sources, parsing, transforming, and ensuring data quality before forwarding it to the CEP engine.The data received from IAQ sensors includes PM10, PM2.5, CO 2 , temperature, and humidity, among others.

Event Analysis Layer
The event analysis layer is a crucial component of the framework that handles the various data streams produced by the event sources.This layer acts as the brain of the system and is responsible for filtering, detecting, aggregating, and correlating patterns across multiple event streams.This layer comprises several sub-layers that work together to ensure that the system can handle complex event-processing tasks efficiently and accurately.
-CEP engine sub-layer: This layer is responsible for detecting and defining patterns and correlations between various events.It uses predefined rules to detect events, processes them to identify atomic events, and forwards them to the semantic sub-layer for subsequent processing.The event processing pipelines and rules of the framework are implemented using Apache Flink, which facilitates effective and efficient stream processing.The CEP engine can be configured to handle a diverse range of rules or models, such as time-based, context-based, or predictive models, to provide flexible and adaptable solutions for different scenarios.By defining time-based rules, the CEP engine can detect correlations between events and identify patterns and relationships that may occur periodically or at certain time intervals.CEP engines use context-aware rules to detect events and take appropriate actions.By analysing contextual information, they can identify triggers such as high CO 2 levels that can cause health issues like asthma.Predictive models can also be used to anticipate events and take proactive measures.For example, the engine may predict that indoor activities like cooking can lead to higher concentrations of particulate matter and provide timely alerts to occupants or take preventive measures.-Semantic engine sub-layer: This sub-layer is critical in the framework.It uses ontology to interpret events and their relationships, enhancing analysis and interpretation beyond individual characteristics.By combining it with the CEP engine sub-layer, it efficiently filters events from multiple atomic sensed events.The semantic engine's reasoning mechanism detects intricate event patterns from the ontology's background knowledge.It identifies significant events beyond simple atomic events involving multiple conditions or causality.The framework's ontology can be easily customised and updated to improve the system's event detection performance, as it continually learns from new insights and data.Advanced event analysis and detection are made possible by leveraging the CEP engine and semantic web technology.The system allows for timely interventions and proactive actions by triggering notifications when events exceed predefined thresholds.
-Event stream processing sub-layer: This layer processes event streams using the CEP Engine's capabilities.It orchestrates a sequence of events and utilises pattern recognition to identify complex events by leveraging the knowledge stored in the ontology.-Complex event detection sub-layer: The purpose of this sub-layer is to detect complex events by combining the outcomes generated by the CEP engine and the semantic engine sub-layers.It does this by applying predefined patterns to the event stream and leveraging the semantic information about the events.The integration with semantics technology enhances the detection capability, making it more accurate and efficient.-Anomaly detection sub-layer: This module is designed to detect any unusual patterns in real-time event streams using advanced algorithms to identify abnormal patterns, allowing for timely interventions.

Application Layer
The application layer presents analysed data to users, generates reports, triggers actions, and alerts them of critical events.It also permits users to customise analysis rules and integrate the system with other software.In the context of this study, the application layer can produce notifications or alerts to the users as soon as the CEP engine identifies a correlation between indoor activities, indoor air pollutants, and asthma symptoms.For example, if cooking triggers asthma symptoms, the CEP Engine sends an alert to occupants if it exceeds the threshold.As a result, they can either avoid cooking at certain times or ventilate the kitchen.This layer is also designed to generate reports that provide a better understanding of indoor air quality and its effects on human health.

Classes and Subclasses
This research focuses on several relevant classes that we have identified and defined in our ontology, depicted in Figure 4. Various classes include, but are not limited to, Asth-maSymptom, IndoorAirQuality, IndoorActivity, Sensor, and Measurement, among others.Each of these classes exhibits a unique entity or concept with its respective properties, relationships, and constraints [54].Object and data properties are the two properties used for this ontology to describe the relationship between two individuals and the relationship between individuals and enter data values for the classes according to their data format.Some properties defined for disease, such as hasDisease, hasSymptoms, has activity, hasIndoorAirQuality are depicted in Figure 5.

SWRL Rules
Figure 7 is an example of the use of SWRL rules in our case.These rules are employed to identify events depending on asthma symptoms, indoor activities, environmental properties, and air quality measurements.By using logical operators such as AND and OR, the rules can combine events to provide a comprehensive analysis.Additionally, temporal patterns can be defined with the use of operators like SEQUENCE, PERIODIC, APERIODIC, and ALL, which allow for the detection of specific event sequences or recurring patterns.Figure 7 illustrates examples of a few of the rules utilised in the proposed ontology.

Ontology Validation
Figure 8 illustrates the outcomes of the OOPS! evaluation process, which was conducted to find common errors in our designed ontology, particularly in relation to complex event detection.The used tool meticulously crosschecked the ontology against a predefined set of patterns, flagging inconsistencies such as missing or inaccurate class definitions, uncertain modelling choices, and inaccurate usage of relationships.This enabled us to detect any potential problems that could hamper the complete and accurate detection of complex events.The findings obtained from the OOPS! evaluation directed improvements that were made to enhance the effectiveness of the ontology.

Complex Event Detection with Illustrative Example
In the context of real-time data analysis, complex event detection is a vital process that involves detecting meaningful patterns and correlations within a continuous stream of data.CEP techniques play a crucial role in this domain.CEP allows us to define event patterns and rules that trigger specific actions or alerts when these patterns are detected.While CEP has a wide range of applications, this paper focuses on the detection of complex events; in particular, we present event detection algorithms designed to identify instances of high indoor air pollution correlated with asthma symptoms and specific indoor activities.

Data Description
The authors conducted a systematic study to obtain data for the study, which involved gathering data on indoor activities, IAQ, and asthma symptoms.This extensive dataset was fundamental in comprehending the correlation between different factors and their influence on human health, especially with regard to respiratory conditions such as asthma.The data collected have been used in this article to test the efficiency of the developed framework.Examples of some of the data instances are depicted in Table 1.

Event Pattern Modelling
The following section outlines the various event patterns that have been established to identify complex events associated with asthma exacerbation.To detect high indoor air pollution and its correlation with asthma symptoms, these patterns utilise a combination of indoor air quality readings, indoor activities, and asthma symptoms.The aim is to pinpoint specific scenarios that suggest elevated indoor air pollution levels and their connection to asthma symptoms.Below are two examples of event patterns we have identified for illustrative purposes.

Event Pattern 1: "High indoor air pollution during cooking and VCleaning with wheezing or breathing issues".
This pattern's objective is to detect "High indoor air pollution during cooking or cleaning with wheezing or breathing issues".The rules of this event pattern, with a few example instances, are outlined in Figure 9. Detected pattern events are represented with RDF triples (semantic web technology) in Listing 1.Each event uses properties like hasdate, hasAsthmaSymptom, hasIndoorActivity, and hasIndoorAirQuality with specific values.
Event Pattern 2: "High indoor air pollution during heating, accompanied by wheezing or breathing issues".This pattern's objective is to identify instances where indoor air pollution is elevated during heating activities, coinciding with reports of wheezing or respiratory issues.The rules of this event pattern, with a few example instances, are outlined in Figure 10.Detected pattern events are represented with RDF triples (semantic web technology) in Listing 2. Each event uses properties like hasdate, hasAsthmaSymptom, hasIndoorActivity, and hasIndoorAirQuality with specific values.

Event Detection Algorithms
In this subsection, we present the algorithms developed to detect complex events based on the defined event patterns previously described.Each event pattern is associated with a set of rules, and the goal is to detect instances that match these patterns within a continuous data stream.

Algorithm 1: High Indoor Air Pollution during Cooking
Algorithm Description: This algorithm iterates through the data stream and checks each data point against the defined rules for Algorithm 1.When all conditions are met, it appends an asthma exacerbation event to the list of detected events.

end if 7: end for
The proposed event detection algorithms provide a systematic approach to detecting complex events related to asthma exacerbation.By leveraging these algorithms, we can analyse real-time data streams and trigger timely alerts and/or interventions when potential asthma exacerbation events are detected.

Performance Evaluation
We evaluated the performance of the proposed complex event detection approaches using the established evaluation metrics.We also compare the results between conventional CEP and CEP integrated with semantic web technologies.

Evaluation Metrics
Our evaluation of event detection involved the use of precision, recall, and F1-score metrics to assess the effectiveness of each approach utilised.True Positives (TP) were identified as the total number of complex events that were correctly detected by the system.False Positives (FP) were events flagged by the system that were not complex events, while False Negatives (FN) represented the total number of complex events missed by the system.The formula to compute precision is shown in Equation ( 1), which was used to determine positive prediction accuracy.The recall was calculated using the Equation ( 2), indicating the proportion of actual positives accurately identified.The F1-score was the harmonic mean of precision and recall and functioned to balance precision and recall.A score of 1 indicated perfect precision and recall, while 0 indicated poor performance.

Precision : Precision
Recall We compared the effectiveness of conventional CEP and CEP with semantic web technologies for detecting complex events in real-time IoT data analysis.The integration of semantic web technologies was found to enhance traditional CEP and improve accuracy.Traditional CEP has proven efficiency in detecting simple events, but as we use more smart things, we need to enhance its capability to find more complicated events.That is why it is useful to use the Semantic Web with CEP to find even more complicated events.
Efficiency: A comparison was conducted to measure efficiency and processing time between conventional CEP and that of the enhanced CEP with semantic web technologies, which is illustrated in Figure 11.Our findings showed that the traditional CEP had a lower processing time than the enhanced CEP.The processing times for different events are shown in the efficiency graph, and it is evident that the integrated approach can handle larger events without a significant increase in processing time.This suggests that the system can scale to meet the demands of real-time event detection in IoT applications.
Accuracy: The use of semantic web technologies enabled CEP to achieve higher levels of accuracy and completeness in generating insights compared to the conventional CEP as outlined in Figure 12.By utilising semantic representations, the proposed framework exhibited enhanced contextual understanding, resulting in more precise and suitable insights, leading to better decision making.The semantic-based CEP framework outperformed traditional CEP in terms of accuracy, precision, and contextual relevance due to semantic web reasoning and inference capabilities.The performance of two approaches, conventional CEP and CEP enhanced with semantic web technologies, are evaluated side by side using four metrics-Accuracy, Precision, Recall, and F1-Score-which are presented in the chart with blue and orange bars representing conventional CEP and CEP with semantic web technologies, respectively.The chart shows that the proposed enhanced CEP framework outperforms conventional CEP in all four metrics, indicating that the integration of semantic web technologies with traditional CEP significantly improves real-time event detection capacity.
Evaluating both approaches reveals their strengths and weaknesses.Conventional CEP shows strength in processing and resource utilisation for limited environments, but it may not handle complex event relationships or integrate diverse data, limiting its applicability for comprehensive event detection.Conversely, the fusion of semantic web technologies with traditional CEP offers significant benefits to event detection.The integration of semantics provides a more robust data representation, enabling the system to comprehend data at a more abstract level and conduct reasoning over it.This leads to heightened accuracy and completeness in event detection, thereby reducing the occurrence of false positives and false negatives.Furthermore, the utilisation of semantic web technologies has allowed for the effortless integration of data from multiple sources, which has resulted in the system being able to achieve greater contextual awareness and adaptability across a wide range of application domains.
Real-time analysis of large-scale and diverse data streams is crucial for streaming IoT applications.However, the increasing complexity of IoT data poses several challenges that require innovative solutions.One such solution proposed in this article is the integration of semantic web technologies with traditional CEP, which holds enormous potential to address these challenges.By leveraging this integration, complex event patterns can be efficiently handled, enabling timely and informed decision making as well as proactive actions based on real-time insights.A comparative analysis of different approaches can assist researchers and practitioners in selecting the most suitable method for their distinct IoT applications and use cases.
In evaluating the two approaches, we consider both traditional performance metrics and computational burden.Understanding the computational requirements of our methods is essential for practical feasibility.In Table 2, we present the combined computation burden metrics for both Traditional CEP and Semantic Web-integrated CEP.Comparing the computational burden metrics between traditional CEP and semantic web technology-integrated CEP approaches, we gain a holistic view of their respective performance.This evaluation extends beyond raw speed and accuracy and delves into the practical feasibility of implementation, particularly in resource-intensive real-time scenarios.Our research focuses on real-time data analysis within the context of our CEP framework.We have addressed the computational burden by optimising our algorithms for efficiency, selecting appropriate hardware configurations, and implementing scalability and resource-monitoring strategies.Within the CEP framework, we have harnessed parallel processing, advanced pattern recognition algorithms, low-latency design, and continuous resource monitoring to optimise our CEP framework for superior performance.

Conclusions
This article has demonstrated the pivotal role of ontologies in enhancing complex event detection, particularly within the context of air quality monitoring in IoT applications.Our work highlights how ontologies significantly contribute to more precise and contextaware event detection by enriching data semantics, thereby reducing false positives and false negatives and increasing event detection precision.The integration of ontologies with traditional CEP expands the capabilities of event detection, particularly in scenarios characterised by intricate event patterns and diverse data sources.While traditional CEP remains efficient, the addition of semantics improves the quality of insights derived from streaming data.Our evaluation has confirmed the advantages of this integrated approach, offering a robust framework for event detection.
The proposed method for detecting complex events in real-time did not take into account the possibility of anomalies in the data streams.This oversight presents a potential issue as streaming data is constantly evolving, thereby increasing the probability of anomalies and irregular patterns in the data, particularly due to cyber-attacks.Failure to identify these anomalies may lead to erroneous event detection.Hence, it is recommended to investigate techniques for anomaly detection and integrate them with the existing method to reinforce its resilience.Moreover, to improve the performance and effectiveness of the framework, future research should also focus on addressing computational overhead, and streamlining complexity in ontology development.By enhancing the algorithms for anomaly detection, optimising computational efficiency, and developing dynamic ontologies, the integrated framework can become a more efficient and powerful tool for generating real-time insights and detecting events in IoT applications.

Figure 3 .
Figure 3. High-level overview of the proposed framework.

Figure 4 .
Figure 4. Classes visualised in OntoGraf.In our ontology, classes and subclasses play a pivotal role in organising concepts within the domain of air quality monitoring and event detection.Here are some key classes and their subclasses along with examples: c l a s s Event { // C l a s s d e f i n i t i o n f o r Event } c l a s s AtomicEvent extends Event {

Figure 5 .
Figure 5.Some of the Object and Data Properties.

3. 3 . 3 .Figure 6
Figure6showcases the utilisation of individuals to populate the ontology with realworld data instances, demonstrating the practical application of the ontology.

Figure 6 .
Figure 6.Some of the individuals in the ontology.

Figure 8 .
Figure 8. Summary of the OOPS! with minor pitfalls.

Figure 11 .
Figure 11.Comparison of processing times for traditional CEP and enhanced CEP.

Figure 12 .
Figure 12.Comparison of detection accuracy of traditional CEP and enhanced CEP.

Table 1 .
Example instances of IAQ dataset.
This algorithm scans the data stream, applying the specified rules for Algorithm Algorithm 2. When the conditions are met, it adds an asthma exacerbation event to the list of detected events.
.2.Comparison of Performance of Traditional CEP and Proposed Enhanced Semantic Web-Integrated CEP

Table 2 .
Computation burden metrics for Traditional CEP and Semantic Web-integrated CEP.