WIP: страницы для правил #62

Closed
Ghost wants to merge 132 commits from master into 61-rules-pages
2 changed files with 10 additions and 2 deletions
Showing only changes of commit 36e2b09568 - Show all commits

View File

@ -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<Integer> 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();
}
}

View File

@ -34,7 +34,7 @@
<input type="hidden" th:field="*{branchId}">
</form>
<div th:if="${assessments != null}">
<div th:if="${assessments != null && #lists.size(assessments) > 0}">
<h5>Состояние репозитория описывается следующими выражениями:</h5>
<div th:each="assessment: ${assessments}">
<span th:text="${assessment.consequent}"></span>
@ -44,5 +44,8 @@
th:text="${assessment.secondAntecedent.description}"></span>';
</div>
</div>
<div th:if="${assessments != null && #lists.size(assessments) == 0}">
<h5>Нет результатов</h5>
</div>
</div>
</html>