diff --git a/src/main/java/ru/ulstu/extractor/rule/service/FuzzyInferenceService.java b/src/main/java/ru/ulstu/extractor/rule/service/FuzzyInferenceService.java index 9e0864b..d17d112 100644 --- a/src/main/java/ru/ulstu/extractor/rule/service/FuzzyInferenceService.java +++ b/src/main/java/ru/ulstu/extractor/rule/service/FuzzyInferenceService.java @@ -19,6 +19,7 @@ import ru.ulstu.extractor.rule.model.DbRule; import ru.ulstu.extractor.ts.model.TimeSeries; import ru.ulstu.extractor.ts.service.TimeSeriesService; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -31,6 +32,7 @@ public class FuzzyInferenceService { private final static String RULE_TEMPLATE = "if %s is %s and %s is %s then " + OUTPUT_VARIABLE_NAME + " is %s"; + private final static String NO_RESULT = "Нет результата"; private final DbRuleService ruleService; private final AntecedentValueService antecedentValueService; private final GitRepositoryService gitRepositoryService; @@ -130,6 +132,9 @@ public class FuzzyInferenceService { List consequentValues = dbRules.stream().map(DbRule::getId).collect(Collectors.toList()); engine.addRuleBlock(getRuleBlock(engine, variableValues, antecedentValues, consequentValues)); String consequent = getConsequent(engine, variableValues); + if (consequent.equals(NO_RESULT)) { + return new ArrayList<>(); + } return dbRules .stream() .filter(r -> r.getId().equals(Integer.valueOf(consequent))) @@ -173,7 +178,7 @@ public class FuzzyInferenceService { outputVariable.defuzzify(); } return (outputVariable == null || Double.isNaN(outputVariable.getValue())) - ? "Нет результата" + ? NO_RESULT : outputVariable.highestMembership(outputVariable.getValue()).getSecond().getName(); } } diff --git a/src/main/resources/templates/assessments.html b/src/main/resources/templates/assessments.html index 013e37c..516628a 100644 --- a/src/main/resources/templates/assessments.html +++ b/src/main/resources/templates/assessments.html @@ -34,7 +34,7 @@ -
+
Состояние репозитория описывается следующими выражениями:
@@ -44,5 +44,8 @@ th:text="${assessment.secondAntecedent.description}">';
+
+
Нет результатов
+