Debian Codegraph @

Source/Test/Evaluation/CReasonerEvaluationExpressivityRequestSelector.cpp

raw
1 /*
2 * Copyright (C) 2013-2015, 2019 by the Konclude Developer Team.
3 *
4 * This file is part of the reasoning system Konclude.
5 * For details and support, see <http://konclude.com/>.
6 *
7 * Konclude is free software: you can redistribute it and/or modify
8 * it under the terms of version 3 of the GNU Lesser General Public
9 * License (LGPLv3) as published by the Free Software Foundation.
10 *
11 * Konclude is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU (Lesser) General Public License for more details.
15 *
16 * You should have received a copy of the GNU (Lesser) General Public
17 * License along with Konclude. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21 #include "CReasonerEvaluationExpressivityRequestSelector.h"
22
23
24 namespace Konclude {
25
26 namespace Test {
27
28 namespace Evaluation {
29
30
31 CReasonerEvaluationExpressivityRequestSelector::CReasonerEvaluationExpressivityRequestSelector(const QList<COntologyExpressivity>& equalBoundList, const QString& baseExpressivityDir) {
32 mEqualBoundList = equalBoundList;
33 mBaseExpressivityDir = baseExpressivityDir;
34 }
35
36 CReasonerEvaluationExpressivityRequestSelector::CReasonerEvaluationExpressivityRequestSelector(const QList<COntologyExpressivity>& lowerNotIncludedBoundList, const QList<COntologyExpressivity>& upperIncludedBoundList, const QString& baseExpressivityDir) {
37 mLowerNotIncludedBoundList = lowerNotIncludedBoundList;
38 mUpperIncludedBoundList = upperIncludedBoundList;
39 mBaseExpressivityDir = baseExpressivityDir;
40 }
41
42
43 CReasonerEvaluationExpressivityRequestSelector::CReasonerEvaluationExpressivityRequestSelector() {
44 }
45
46
47 bool CReasonerEvaluationExpressivityRequestSelector::isGroupSelected(const QString& groupString) {
48 return true;
49 }
50
51 bool CReasonerEvaluationExpressivityRequestSelector::isRequestSelected(const QString& groupString, const QString& requestString) {
52 QString expressivityString;
53 bool foundExpressivity = false;
54 QString infoFileString = mBaseExpressivityDir+groupString+requestString+".txt";
55 QFile infoFile(infoFileString);
56 if (infoFile.open(QIODevice::ReadOnly)) {
57 while (!foundExpressivity && !infoFile.atEnd()) {
58 QString line = infoFile.readLine();
59 QStringList keyValueLists = line.split("\t");
60 if (keyValueLists.count() >= 2) {
61 if (keyValueLists.first().trimmed() == "Expressivness:") {
62 foundExpressivity = true;
63 expressivityString = keyValueLists.last().trimmed();
64 }
65 }
66 }
67 infoFile.close();
68 }
69 if (!foundExpressivity) {
70 return false;
71 } else {
72 COntologyExpressivity expressivity(expressivityString);
73 foreach (COntologyExpressivity expBound, mEqualBoundList) {
74 if (expressivity.isExpressivityEqual(&expBound)) {
75 return true;
76 }
77 }
78 if (!mEqualBoundList.isEmpty()) {
79 return false;
80 }
81 foreach (COntologyExpressivity expBound, mExcludedBoundList) {
82 if (expressivity.isExpressivityEqual(&expBound)) {
83 return false;
84 }
85 }
86 foreach (COntologyExpressivity expBound, mLowerNotIncludedBoundList) {
87 if (expBound.isExpressivityEntailed(&expressivity)) {
88 return false;
89 }
90 }
91 foreach (COntologyExpressivity expBound, mLowerIncludedBoundList) {
92 if (expBound.isExpressivityEntailed(&expressivity) && !expressivity.isExpressivityEqual(&expBound)) {
93 return false;
94 }
95 }
96 bool entailedByOneUpperBounds = false;
97 foreach (COntologyExpressivity expBound, mUpperNotIncludedBoundList) {
98 if (expBound.isExpressivityEntailed(&expressivity) || !expressivity.isExpressivityEqual(&expBound)) {
99 entailedByOneUpperBounds |= true;
100 }
101 }
102 foreach (COntologyExpressivity expBound, mUpperIncludedBoundList) {
103 if (expBound.isExpressivityEntailed(&expressivity)) {
104 entailedByOneUpperBounds |= true;
105 }
106 }
107 if (!entailedByOneUpperBounds) {
108 return false;
109 }
110 }
111 return true;
112 }
113
114
115
116 }; // end namespace Evaluation
117
118 }; // end namespace Test
119
120 }; // end namespace Konclude