diff --git a/src/main/java/ru/ulstu/fc/rule/controller/InferenceMvcController.java b/src/main/java/ru/ulstu/fc/rule/controller/InferenceMvcController.java index 7267da1..133bf62 100644 --- a/src/main/java/ru/ulstu/fc/rule/controller/InferenceMvcController.java +++ b/src/main/java/ru/ulstu/fc/rule/controller/InferenceMvcController.java @@ -12,6 +12,7 @@ import ru.ulstu.fc.rule.service.FuzzyInferenceService; import java.util.Arrays; import java.util.List; +import java.util.Map; @Controller public class InferenceMvcController { @@ -34,21 +35,24 @@ public class InferenceMvcController { model.addAttribute("ageAntecedents", getAgeAntecedents()); model.addAttribute("incomeAntecedents", getIncomeAntecedents()); model.addAttribute("inferenceForm", inferenceForm); - model.addAttribute("response", fuzzyInferenceService.getFuzzyInference()); + model.addAttribute("response", fuzzyInferenceService.getFuzzyInference( + Map.of("возраст", Double.valueOf(inferenceForm.getAgeAntecedent()), + "доход", Double.valueOf(inferenceForm.getIncomeAntecedent()) + ))); return "index"; } private List getAgeAntecedents() { return Arrays.asList( - new Antecedent("молодой", "young"), - new Antecedent("средний", "average"), - new Antecedent("старый", "old")); + new Antecedent("молодой", "30"), + new Antecedent("средний", "45"), + new Antecedent("старый", "60")); } private List getIncomeAntecedents() { return Arrays.asList( - new Antecedent("малый", "small"), - new Antecedent("средний", "average"), - new Antecedent("высокий", "high")); + new Antecedent("небольшой", "20000"), + new Antecedent("средний", "90000"), + new Antecedent("высокий", "200000")); } } diff --git a/src/main/java/ru/ulstu/fc/rule/service/FuzzyInferenceService.java b/src/main/java/ru/ulstu/fc/rule/service/FuzzyInferenceService.java index 31389f0..5f1b72c 100644 --- a/src/main/java/ru/ulstu/fc/rule/service/FuzzyInferenceService.java +++ b/src/main/java/ru/ulstu/fc/rule/service/FuzzyInferenceService.java @@ -127,8 +127,8 @@ public class FuzzyInferenceService { .collect(Collectors.toList()); } - public List getFuzzyInference() { - return getFuzzyInference(getDemoRules(), Map.of("возраст", 20.0, "доход", 250000.0), + public List getFuzzyInference(Map vals) { + return getFuzzyInference(getDemoRules(), vals, List.of(new Variable("возраст", List.of( new VariableValue("молодой", 35.0), new VariableValue("средний", 60.0), diff --git a/src/main/resources/templates/default.html b/src/main/resources/templates/default.html index a8d2088..9029445 100644 --- a/src/main/resources/templates/default.html +++ b/src/main/resources/templates/default.html @@ -22,8 +22,11 @@ diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index 48b474d..fbeb483 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -50,7 +50,12 @@ -
+
+
Размер кредита:
+
+
Степень принадлежности:
+
+