diff --git a/pom.xml b/pom.xml index a27ee2b..3a0ef96 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ org.sadtech.autoresponder autoresponder - 1.4.0-SNAPSHOT + 1.3.1-RELEASE jar diff --git a/src/main/java/org/sadtech/autoresponder/Autoresponder.java b/src/main/java/org/sadtech/autoresponder/Autoresponder.java index c737fd8..180567d 100644 --- a/src/main/java/org/sadtech/autoresponder/Autoresponder.java +++ b/src/main/java/org/sadtech/autoresponder/Autoresponder.java @@ -17,6 +17,7 @@ public class Autoresponder { public static final Logger log = Logger.getLogger(Autoresponder.class); private UnitService unitService; + private PersonService personService; public PersonService getPersonService() { return personService; @@ -26,8 +27,6 @@ public class Autoresponder { this.personService = personService; } - private PersonService personService; - public Autoresponder(UnitService unitService, PersonService personService) { this.unitService = unitService; this.personService = personService; @@ -68,13 +67,10 @@ public class Autoresponder { Optional patternUnits = nextUnits.stream().filter(nextUnit -> nextUnit.getPattern() != null).filter(nextUnit -> patternReg(nextUnit, message)).max(unitPriorityComparator); if (!patternUnits.isPresent()) { - patternUnits = nextUnits.stream().filter(nextUnit -> (textPercentageMatch(nextUnit, new HashSet<>(Collections.singleton(message))) == 100.0)).max(unitPriorityComparator); - if (!patternUnits.isPresent()) { - Parser parser = new Parser(); - parser.setText(message); - parser.parse(); - patternUnits = nextUnits.stream().filter(nextUnit -> textPercentageMatch(nextUnit, parser.getWords()) >= nextUnit.getMatchThreshold()).max(unitPriorityComparator); - } + Parser parser = new Parser(); + parser.setText(message); + parser.parse(); + patternUnits = nextUnits.stream().filter(nextUnit -> textPercentageMatch(nextUnit, parser.getWords()) >= nextUnit.getMatchThreshold()).max(unitPriorityComparator); } if (!patternUnits.isPresent()) { @@ -100,6 +96,7 @@ public class Autoresponder { if (unit.getKeyWords() != null) { Set temp = new HashSet<>(unit.getKeyWords()); temp.retainAll(words); + log.info("Юнит: " + unit.getClass().getSimpleName()); log.info("Ключевые слова юнита: " + unit.getKeyWords() + " (" + unit.getKeyWords().size() + ")"); log.info("Ключевые слова от пользователя: " + words); log.info("Пересечение: " + temp + " (" + temp.size() + ")"); diff --git a/src/main/java/org/sadtech/autoresponder/service/UnitService.java b/src/main/java/org/sadtech/autoresponder/service/UnitService.java index 7729011..903fe99 100644 --- a/src/main/java/org/sadtech/autoresponder/service/UnitService.java +++ b/src/main/java/org/sadtech/autoresponder/service/UnitService.java @@ -1,9 +1,7 @@ package org.sadtech.autoresponder.service; import org.sadtech.autoresponder.entity.Unit; -import org.sadtech.autoresponder.repository.UnitRepository; -import java.util.List; import java.util.Set; public interface UnitService { diff --git a/src/main/java/org/sadtech/autoresponder/service/impl/UnitServiceImpl.java b/src/main/java/org/sadtech/autoresponder/service/impl/UnitServiceImpl.java index 5cb2fff..499e5db 100644 --- a/src/main/java/org/sadtech/autoresponder/service/impl/UnitServiceImpl.java +++ b/src/main/java/org/sadtech/autoresponder/service/impl/UnitServiceImpl.java @@ -5,8 +5,6 @@ import org.sadtech.autoresponder.entity.Unit; import org.sadtech.autoresponder.repository.UnitRepository; import org.sadtech.autoresponder.service.UnitService; -import java.util.ArrayList; -import java.util.List; import java.util.Set; public class UnitServiceImpl implements UnitService {