From 7e9d830c422e89ac9d829d5f1edb0df3c844b382 Mon Sep 17 00:00:00 2001 From: christian Date: Mon, 13 Dec 2021 15:05:09 +0100 Subject: [PATCH] reduced total amount of sentences, removed time constraint, deleting more now, added as experiment to run response threads with a 2 thread pool --- .../src/main/java/DataLayer/DataMapper.java | 5 ++--- .../PresentationLayer/DiscordHandler.java | 20 ++++++++++++------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/ArtificialAutism/src/main/java/DataLayer/DataMapper.java b/ArtificialAutism/src/main/java/DataLayer/DataMapper.java index 855a5e11..40419849 100644 --- a/ArtificialAutism/src/main/java/DataLayer/DataMapper.java +++ b/ArtificialAutism/src/main/java/DataLayer/DataMapper.java @@ -89,15 +89,14 @@ public class DataMapper { ResultSet l_rsSearch = null; String CountSQL = "select count(*) from Sentences"; String l_sSQL = "delete from Sentences\n" + - " where DATE(last_used) < DATE_SUB(CURDATE(), INTERVAL 10 DAY)\n" + - " order by last_used asc limit 2"; + " order by last_used asc limit 5"; try { l_cCon = DBCPDataSource.getConnection(); l_pStatement = l_cCon.prepareStatement(CountSQL); ResultSet resultSet = l_pStatement.executeQuery(); if (resultSet.next()) { int count = resultSet.getInt(1); - if (count > 8500) { + if (count > 7000) { l_pStatement = l_cCon.prepareStatement(l_sSQL); l_pStatement.execute(); } diff --git a/ArtificialAutism/src/main/java/PresentationLayer/DiscordHandler.java b/ArtificialAutism/src/main/java/PresentationLayer/DiscordHandler.java index 85786ed6..ef2def3f 100644 --- a/ArtificialAutism/src/main/java/PresentationLayer/DiscordHandler.java +++ b/ArtificialAutism/src/main/java/PresentationLayer/DiscordHandler.java @@ -90,6 +90,7 @@ public class DiscordHandler extends ListenerAdapter { private static Datahandler datahandler; private static StanfordCoreNLP stanfordCoreNLPSentiment; private static ExecutorService executorService = Executors.newFixedThreadPool(1); + private static ExecutorService executorServiceResponse = Executors.newFixedThreadPool(2); private static ExecutorService executorServiceIngame = Executors.newFixedThreadPool(2); //TODO add python program that edits the java code. python program just adds test if statements on @@ -167,13 +168,18 @@ public class DiscordHandler extends ListenerAdapter { } } if (mentionedBot || channelName.contains("general-autism")) { - String ResponseStr; - ResponseStr = datahandler.getResponseMsg(content, username, stanfordCoreNLP, stanfordCoreNLPSentiment, - false); - if (!ResponseStr.isEmpty()) { - System.out.print("\nResponseStr3: " + ResponseStr + "\n"); - event.getMessage().getChannel().sendMessage(ResponseStr).queue(); - } + final String contentF = content; + executorServiceResponse.execute(new Runnable() { + @Override + public void run() { + String ResponseStr = datahandler.getResponseMsg(contentF, username, stanfordCoreNLP, stanfordCoreNLPSentiment, + false); + if (!ResponseStr.isEmpty()) { + System.out.print("\nResponseStr3: " + ResponseStr + "\n"); + event.getMessage().getChannel().sendMessage(ResponseStr).queue(); + } + } + }); } else { final String contentF = content; executorService.execute(new Runnable() {