updated README about fonts, added more app configurations and added the app.config file itself
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
app.url=jdbc:mysql://localhost:3306/ArtificialAutism?useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC&allowPublicKeyRetrieval=True
|
||||
app.username=
|
||||
app.password=
|
||||
app.hostip=
|
||||
app.hostip2=
|
||||
app.hostport=
|
||||
app.hostport2=
|
||||
app.discordtoken=
|
||||
app.interval_days=4
|
||||
app.string_count=14000
|
||||
app.thread_count=4
|
||||
app.interval_days_minus=4
|
||||
@@ -7,6 +7,9 @@ package DataLayer;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
@@ -25,10 +28,20 @@ public class DataMapper {
|
||||
PreparedStatement l_pStatement = null;
|
||||
ResultSet l_rsSearch = null;
|
||||
ArrayList<String> arrayListStr = new ArrayList();
|
||||
Properties prop = new Properties();
|
||||
String fileName = "app.config";
|
||||
try (FileInputStream fis = new FileInputStream(fileName)) {
|
||||
prop.load(fis);
|
||||
} catch (FileNotFoundException ex) {
|
||||
} catch (IOException ex) {
|
||||
}
|
||||
try {
|
||||
l_cCon = DBCPDataSource.getConnection();
|
||||
//not better, just forces the responds to variate a lot more
|
||||
String l_sSQL = "SELECT * FROM Sentences where last_used < CURRENT_DATE() - INTERVAL 5 DAY order by LENGTH(Strings) desc";
|
||||
String l_sSQL = "SELECT * FROM `Sentences` where last_used < CURRENT_DATE() - INTERVAL "
|
||||
+ String.valueOf(prop.getProperty("app.interval_days"))
|
||||
+ " DAY order by LENGTH(Strings) desc";
|
||||
//System.out.println("l_sSQL: " + l_sSQL);
|
||||
l_pStatement = l_cCon.prepareStatement(l_sSQL);
|
||||
l_rsSearch = l_pStatement.executeQuery();
|
||||
while (l_rsSearch.next()) {
|
||||
@@ -46,11 +59,20 @@ public class DataMapper {
|
||||
Connection l_cCon = null;
|
||||
PreparedStatement l_pStatement = null;
|
||||
ResultSet l_rsSearch = null;
|
||||
String l_sSQL = "INSERT IGNORE `Sentences` (`Strings`) VALUES (?)";
|
||||
Properties prop = new Properties();
|
||||
String fileName = "app.config";
|
||||
try (FileInputStream fis = new FileInputStream(fileName)) {
|
||||
prop.load(fis);
|
||||
} catch (FileNotFoundException ex) {
|
||||
} catch (IOException ex) {
|
||||
}
|
||||
String l_sSQL = "INSERT IGNORE `Sentences` (`Strings`, `last_used`) VALUES (?, DATE(NOW()) - interval " +
|
||||
String.valueOf(prop.getProperty("app.interval_days_minus")) + " DAY)";
|
||||
try {
|
||||
l_cCon = DBCPDataSource.getConnection();
|
||||
l_pStatement = l_cCon.prepareStatement(l_sSQL);
|
||||
l_pStatement.setString(1, str);
|
||||
|
||||
l_pStatement.execute();
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
@@ -85,6 +107,13 @@ public class DataMapper {
|
||||
}
|
||||
|
||||
public static void checkStringsToDelete() {
|
||||
Properties prop = new Properties();
|
||||
String fileName = "app.config";
|
||||
try (FileInputStream fis = new FileInputStream(fileName)) {
|
||||
prop.load(fis);
|
||||
} catch (FileNotFoundException ex) {
|
||||
} catch (IOException ex) {
|
||||
}
|
||||
PreparedStatement l_pStatement = null;
|
||||
ResultSet l_rsSearch = null;
|
||||
String CountSQL = "select count(*) from Sentences";
|
||||
@@ -94,7 +123,7 @@ public class DataMapper {
|
||||
ResultSet resultSet = l_pStatement.executeQuery();
|
||||
if (resultSet.next()) {
|
||||
int count = resultSet.getInt(1);
|
||||
if (count > 8000) {
|
||||
if (count > Integer.valueOf(prop.getProperty("app.string_count"))) {
|
||||
//System.out.println("cleaning strings: " + l_sSQL);
|
||||
l_pStatement = l_cCon.prepareStatement(l_sSQL);
|
||||
l_pStatement.executeUpdate();
|
||||
|
||||
@@ -19,6 +19,9 @@ import edu.stanford.nlp.trees.*;
|
||||
import edu.stanford.nlp.util.CoreMap;
|
||||
import org.ejml.simple.SimpleMatrix;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.regex.Matcher;
|
||||
@@ -27,6 +30,8 @@ import java.util.regex.Pattern;
|
||||
|
||||
public class Datahandler {
|
||||
|
||||
//wanted to put this in config too but welp cant be arsed to set this up differently.
|
||||
//4 threads for the rest of eternity it is.
|
||||
private ExecutorService pool = Executors.newFixedThreadPool(4);
|
||||
private CompletionService completionService = new ExecutorCompletionService(pool);
|
||||
private HashMap<String, Annotation> pipelineAnnotationCache;
|
||||
@@ -720,16 +725,30 @@ public class Datahandler {
|
||||
} catch (InterruptedException e) {
|
||||
//throw new RuntimeException(e);
|
||||
pending = 0;
|
||||
Properties prop = new Properties();
|
||||
String fileName = "app.config";
|
||||
try (FileInputStream fis = new FileInputStream(fileName)) {
|
||||
prop.load(fis);
|
||||
} catch (FileNotFoundException ex) {
|
||||
} catch (IOException ex) {
|
||||
}
|
||||
System.out.printf(Arrays.toString(e.getStackTrace()));
|
||||
pool.shutdown();
|
||||
pool = Executors.newFixedThreadPool(4);
|
||||
pool = Executors.newFixedThreadPool(Integer.valueOf(prop.getProperty("app.thread_count")));
|
||||
completionService = new ExecutorCompletionService(pool);
|
||||
} catch (ExecutionException e) {
|
||||
//throw new RuntimeException(e);
|
||||
pending = 0;
|
||||
Properties prop = new Properties();
|
||||
String fileName = "app.config";
|
||||
try (FileInputStream fis = new FileInputStream(fileName)) {
|
||||
prop.load(fis);
|
||||
} catch (FileNotFoundException ex) {
|
||||
} catch (IOException ex) {
|
||||
}
|
||||
System.out.printf(Arrays.toString(e.getStackTrace()));
|
||||
pool.shutdown();
|
||||
pool = Executors.newFixedThreadPool(4);
|
||||
pool = Executors.newFixedThreadPool(Integer.valueOf(prop.getProperty("app.thread_count")));
|
||||
completionService = new ExecutorCompletionService(pool);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +115,6 @@ public class DiscordHandler extends ListenerAdapter {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
//the JDA library wants to keep the program alive even when an error is happening. hopefully this just makes the program crash when an error happens.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user