From d03cb194ee0ef081af66d40fd63081155a68def7 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Fri, 21 Apr 2023 13:23:48 +0400 Subject: [PATCH] #91 -- Fix fuzzy inference --- .../controller/AssessmentController.java | 3 ++- .../assessment/service/AssessmentService.java | 20 ++++++------------- src/main/resources/templates/assessments.html | 19 +++++++++++++++++- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/main/java/ru/ulstu/extractor/assessment/controller/AssessmentController.java b/src/main/java/ru/ulstu/extractor/assessment/controller/AssessmentController.java index e5721fa..35beb28 100644 --- a/src/main/java/ru/ulstu/extractor/assessment/controller/AssessmentController.java +++ b/src/main/java/ru/ulstu/extractor/assessment/controller/AssessmentController.java @@ -29,7 +29,8 @@ public class AssessmentController { public String getAssessments(Model model, @RequestParam Optional branchId) { model.addAttribute("branches", branchService.findAllValid()); if (branchId.isPresent()) { - model.addAttribute("assessments", assessmentService.getAssessmentsByForecastTendencies(branchId.get())); + model.addAttribute("assessments", assessmentService.getAssessments(branchId.get())); + model.addAttribute("singleAssessment", assessmentService.getSingleAssessment(branchId.get())); model.addAttribute("filterBranchForm", new FilterBranchForm(branchId.get())); } else { model.addAttribute("filterBranchForm", new FilterBranchForm()); diff --git a/src/main/java/ru/ulstu/extractor/assessment/service/AssessmentService.java b/src/main/java/ru/ulstu/extractor/assessment/service/AssessmentService.java index 2d9899c..83e99ef 100644 --- a/src/main/java/ru/ulstu/extractor/assessment/service/AssessmentService.java +++ b/src/main/java/ru/ulstu/extractor/assessment/service/AssessmentService.java @@ -34,24 +34,24 @@ public class AssessmentService { this.fuzzyInferenceService = fuzzyInferenceService; } - public List getAssessmentsByForecastTendencies(Integer branchId) { + public List getAssessments(Integer branchId) { List timeSeries = timeSeriesService.getByBranch(branchId); List dbRules = ruleService.getList(); try { - return getAssessmentsByTimeSeriesTendencies(dbRules, timeSeries); + return getAssessments(dbRules, timeSeries); } catch (AssessmentException ex) { ex.printStackTrace(); return new ArrayList<>(); } } - public List getAssessmentsByLastValues(Integer branchId) { + public List getSingleAssessment(Integer branchId) throws AssessmentException { List timeSeries = timeSeriesService.getByBranch(branchId); List dbRules = ruleService.getList(); - return getAssessmentsByLastValues(dbRules, timeSeries); + return getSingleAssessment(dbRules, timeSeries); } - private List getSingleAssessmentByTimeSeriesTendencies(List dbRules, List timeSeries) throws AssessmentException { + private List getSingleAssessment(List dbRules, List timeSeries) throws AssessmentException { Map variableValues = new HashMap<>(); timeSeries.forEach(ts -> variableValues.put(ts.getTimeSeriesType().name(), timeSeriesService.getLastTimeSeriesTendency(ts))); return fuzzyInferenceService.getFuzzyInference(dbRules, @@ -59,7 +59,7 @@ public class AssessmentService { variableValues); } - private List getAssessmentsByTimeSeriesTendencies(List dbRules, List timeSeries) { + private List getAssessments(List dbRules, List timeSeries) { return dbRules .stream() .flatMap(dbRule -> { @@ -77,12 +77,4 @@ public class AssessmentService { .sorted(Comparator.comparing(Assessment::getDegree)) .collect(Collectors.toList()); } - - private List getAssessmentsByLastValues(List dbRules, List timeSeries) { - Map variableValues = new HashMap<>(); - timeSeries.forEach(ts -> variableValues.put(ts.getTimeSeriesType().name(), ts.getValues().get(ts.getValues().size() - 1).getValue())); - return fuzzyInferenceService.getFuzzyInference(dbRules, - antecedentValueService.getList(), - variableValues); - } } diff --git a/src/main/resources/templates/assessments.html b/src/main/resources/templates/assessments.html index 8a8c7f7..f213f81 100644 --- a/src/main/resources/templates/assessments.html +++ b/src/main/resources/templates/assessments.html @@ -33,7 +33,7 @@
Выбрерите ветку для получения оценки репозитория
-
Состояние репозитория описывается следующими выражениями:
+
Состояние репозитория по нескольким правилам описывается следующими выражениями:
вследствие тенденции '' показателя '
Нет результатов
+ +
+ +
+
Состояние репозитория по лидирующему правилу описывается следующими выражениями:
+
+ + вследствие тенденции '' показателя '' + и тенденции '' показателя ''; + +
+
+
+
Нет результатов
+