# AgriEnt: A Knowledge-Based Web Platform for Managing Insect Pests of Field Crops
## 3 AgriEnt: Architecture
### Semantic Layer
#### 3.2.2 Rule-Based Inference Engine  
The farmer's tasks include harvesting and inspecting crops, irrigating farm soil, spraying fertilizer, among others. However, one of the most critical tasks is to diagnose the disease that is affecting their crops. This task consists in identifying the cause of the disease by analyzing the signs and symptoms of their crops. AgriEnt is designed to assist this task through an inference engine that examines the crop's symptoms provided by the farmer against the set of rules, which are used to represent experts knowledge in intelligent systems [30]. These rules were defined by using SWRL, one of the most used languages to express rules on semantic-based systems [32]. SWRL allows rules to be defined in terms of OWL concepts to provide deductive reasoning capabilities. Besides, these rules increase the level of expressivity that is not provided by the OWL language i.e., they allow defining relations that cannot be defined through OWL DL (Description Logic). The rules definition process involved a group of agricultural entomology experts who were interviewed about diseases, insect pests, symptoms, and recommendations of common insect pests in Ecuador. Then, they were asked to establish a set of conditions focused on diagnosing insect pests based on a set of symptoms. Once these conditions were defined, the authors expressed these conditions in the form of if-then statements consisting of an antecedent, also known as the body of the rule, and a consequent, which is also referred to as the head of the rule. Specifically, all rules follow the format depicted in Equation (1):  
\[\text{R}_{1},\,\text{R}_{2},\,\ldots,\,\text{R}_{\text{n}}\rightarrow\text{D} \tag{1}\]  
where R\({}_{1}\), R\({}_{2}\),..., R\({}_{\text{n}}\) is the antecedent part, which contains atomic formulas that represent conditions, while D is the consequent part, which contains conclusions i.e., is the conclusion when all conditions \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Property Name** & **Domain** & **Range** & **Use** \\ \hline hasSymptom & Insect pest & Symptom & It associates an insect pest with their symptoms. \\ isCausedBy & Symptom & Insect pest & It associates a symptom with the insect that cause it. \\ hasTreatment & Insect pest & Treatment & It associates an insect pest with suitable treatments. \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Properties associated with the classes defined by AgriEnt-Ontology. from the antecedent part are fulfilled. For instance, Equation (2) presents the definition of the _Scriophaga excerptalis_ sugarcane pest:  
\[ \begin{array}{c}\text{pest(?x) \wedge hasSymptom(?x, \"parallel rows of shot holes in the emerging}\\ \text{leaves\") \wedge hasSymptom(?x, \"red tunnels in the midribs of leaves\") \wedge hasSymptom(?x,}\\ \text{ ``dead heart in grown up canes\") \wedge hasSymptom(?x, \"dead heart reddish brown in}\\ \text{ color\") \wedge hasSymptom(?x, \"bunchy top due to growth of side shoots\") \rightarrow isPest(?x,}\\ \text{ ``Scripophaga excerptalis\")}\end{array}  \tag{2}\]  
The rule presented in Equation (2) specifies that the Scripophaga excerptalis sugar cane pest will be inferred by the inference engine when all symptoms specified by the hasSymptom conditions match with the symptoms of such insect pest, in this case, parallel rows of shot holes in the emerging leaves, red tunnels in the midribs of leaves, dead heart in grown up canes, dead heart reddish brown in color, and bunchy top due to growth of side shoots. Once insect pest is diagnosed, AgriEnt provides users with information that helps them to better identify the life stage of the insect (egg, larva, pupa, and adult). Sometimes, such information can influence the treatment to follow. Moreover, AgriEnt also provides a set of recommendations for controlling and managing the insect pests diagnosed.