additional small changes
This commit is contained in:
parent
66dae4e113
commit
64dc2719a0
@ -26,9 +26,7 @@ import edu.stanford.nlp.trees.TreebankLanguagePack;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -56,8 +54,8 @@ public class MYSQLDatahandler {
|
||||
public static final long EXPIRE_TIME_IN_SECONDS = TimeUnit.SECONDS.convert(10, TimeUnit.MINUTES);
|
||||
public static final long EXPIRE_TIME_IN_SECONDS1 = TimeUnit.SECONDS.convert(10, TimeUnit.HOURS);
|
||||
public static MYSQLDatahandler instance = new MYSQLDatahandler();
|
||||
public static int semeticsUpdateCount;
|
||||
private volatile boolean refreshMatrixFromDB;
|
||||
private static int secondaryIterator = 0;
|
||||
private final ConcurrentMap<Integer, String> stringCache;
|
||||
private LinkedHashMap<String, LinkedHashMap<String, Double>> lHMSMX = new LinkedHashMap();
|
||||
private final Stopwatch stopwatch;
|
||||
@ -190,8 +188,16 @@ public class MYSQLDatahandler {
|
||||
LinkedHashMap<String, LinkedHashMap<String, Double>> LHMSMXLocal = lHMSMX;
|
||||
int ij2 = 0;
|
||||
for (String str : stringCachelocal.values()) {
|
||||
if (!LHMSMXLocal.keySet().contains(str)) {
|
||||
boolean updatepresent = false;
|
||||
for (String strlocal : LHMSMXLocal.keySet()) {
|
||||
if (strlocal.equals(str)) {
|
||||
updatepresent = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!updatepresent) {
|
||||
selectUpdate = ij2;
|
||||
System.out.println("selectUpdate in primary: " + selectUpdate + "\n");
|
||||
LinkedHashMap<String, Double> newLHM = new LinkedHashMap();
|
||||
lHMSMX.put(str, newLHM);
|
||||
break;
|
||||
@ -199,32 +205,30 @@ public class MYSQLDatahandler {
|
||||
ij2++;
|
||||
}
|
||||
if (selectUpdate == -1) {
|
||||
ij2 = 0;
|
||||
int valueSize = stringCachelocal.size();
|
||||
for (LinkedHashMap<String, Double> values : LHMSMXLocal.values()) {
|
||||
int lhmSize = values.size();
|
||||
if (lhmSize < valueSize) {
|
||||
selectUpdate = ij2;
|
||||
}
|
||||
ij2++;
|
||||
if (secondaryIterator >= valueSize) {
|
||||
secondaryIterator = 0;
|
||||
}
|
||||
selectUpdate = secondaryIterator;
|
||||
secondaryIterator++;
|
||||
}
|
||||
semeticsUpdateCount = selectUpdate;
|
||||
int beginindex = semeticsUpdateCount;
|
||||
if (selectUpdate == -1 || selectUpdate >= stringCachelocal.size()) {
|
||||
selectUpdate = new Random().nextInt(stringCachelocal.size() - 1);
|
||||
}
|
||||
int beginindex = selectUpdate;
|
||||
System.out.println("beginindex: " + beginindex + "\n");
|
||||
ConcurrentMap<Integer, String> strIndexNavigator = new MapMaker().concurrencyLevel(2).makeMap();
|
||||
String get = stringCachelocal.get(beginindex);
|
||||
strIndexNavigator.put(strIndexNavigator.size() + 1, get);
|
||||
ConcurrentMap<Integer, String> strIndexAll = stringCachelocal;
|
||||
strIndexNavigator.put(0, get);
|
||||
ConcurrentMap<Integer, String> randomIndexesToUpdate = new MapMaker().concurrencyLevel(2).makeMap();
|
||||
int indexes = updateBadgesInteger;
|
||||
if (indexes >= strIndexAll.size()) {
|
||||
indexes = strIndexAll.size() - 1;
|
||||
if (indexes >= stringCachelocal.size()) {
|
||||
indexes = stringCachelocal.size() - 1;
|
||||
}
|
||||
int beginindexes = new Random().nextInt((strIndexAll.size()) - indexes);
|
||||
int beginindexes = new Random().nextInt((stringCachelocal.size()) - indexes);
|
||||
int ij1 = 0;
|
||||
while (beginindexes + ij1 < beginindexes + indexes) {
|
||||
String get1 = strIndexAll.get(beginindexes + ij1);
|
||||
String get1 = stringCachelocal.get(beginindexes + ij1);
|
||||
randomIndexesToUpdate.put(ij1, get1);
|
||||
ij1++;
|
||||
}
|
||||
@ -233,9 +237,23 @@ public class MYSQLDatahandler {
|
||||
strIndexNavigator.values().forEach((str) -> {
|
||||
randomIndexesToUpdate.values().stream().filter((str1) -> (!str.equals(str1))).forEachOrdered((str1) -> {
|
||||
boolean present = false;
|
||||
if ((LHMSMXLocal.containsKey(str)) && LHMSMXLocal.get(str).containsKey(str1)
|
||||
|| (LHMSMXLocal.containsKey(str1)) && LHMSMXLocal.get(str).containsKey(str)) {
|
||||
present = true;
|
||||
LinkedHashMap<String, Double> orDefault = LHMSMXLocal.getOrDefault(str, null);
|
||||
if (orDefault != null) {
|
||||
for (String strdefault : orDefault.keySet()) {
|
||||
if (strdefault.equals(str1)) {
|
||||
present = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
orDefault = LHMSMXLocal.getOrDefault(str1, null);
|
||||
if (orDefault != null) {
|
||||
for (String strdefault : orDefault.keySet()) {
|
||||
if (strdefault.equals(str)) {
|
||||
present = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!present) {
|
||||
SimilarityMatrix SMX = new SimilarityMatrix(str, str1);
|
||||
@ -498,6 +516,18 @@ public class MYSQLDatahandler {
|
||||
if (str1.contains("{lightyellow}")) {
|
||||
str1 = str1.replace("{lightyellow}", " ");
|
||||
}
|
||||
if (str1.contains("{chocolate}")) {
|
||||
str1 = str1.replace("{chocolate}", " ");
|
||||
}
|
||||
if (str1.contains("{beige}")) {
|
||||
str1 = str1.replace("{beige}", " ");
|
||||
}
|
||||
if (str1.contains("{azure}")) {
|
||||
str1 = str1.replace("{azure}", " ");
|
||||
}
|
||||
if (str1.contains("{yellowgreen}")) {
|
||||
str1 = str1.replace("{yellowgreen}", " ");
|
||||
}
|
||||
str1 = str1.trim();
|
||||
if (str1.length() > 2 && (!str1.startsWith("!"))) {
|
||||
strlistreturn.put(strlistreturn.size() + 1, str1);
|
||||
@ -580,11 +610,11 @@ public class MYSQLDatahandler {
|
||||
return strmap;
|
||||
}
|
||||
ConcurrentMap<Integer, String> intervalMap = new MapMaker().concurrencyLevel(2).makeMap();
|
||||
int hardcap = allStrings.size() > 450 ? 450 : allStrings.size();
|
||||
int intvervalAprove = allStrings.size() > hardcap ? allStrings.size() - hardcap : allStrings.size();
|
||||
int intervalAproveRand = new Random().nextInt(intvervalAprove);
|
||||
int intervalAprove = 450;
|
||||
int hardcap = allStrings.size() > intervalAprove ? intervalAprove : allStrings.size();
|
||||
int intervalAproveRand = new Random().nextInt(hardcap < intervalAprove ? 1 : allStrings.size() - intervalAprove);
|
||||
int ij = 0;
|
||||
while (ij < hardcap) {
|
||||
while (ij < hardcap && allStrings.size() > intervalAproveRand + ij) {
|
||||
intervalMap.put(ij, allStrings.get(intervalAproveRand + ij));
|
||||
ij++;
|
||||
}
|
||||
@ -606,14 +636,12 @@ public class MYSQLDatahandler {
|
||||
}
|
||||
}
|
||||
int counter = 0;
|
||||
int ijCounter = 0;
|
||||
boolean calculationIssues = false;
|
||||
for (Future<SimilarityMatrix> future : futures.values()) {
|
||||
System.out.println("futures size: " + futures.size() + "\nijCounter: " + ijCounter + "\n");
|
||||
try {
|
||||
future.get(20, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException | ExecutionException | TimeoutException ex) {
|
||||
System.out.println("counter: " + counter + "\n");
|
||||
//System.out.println("counter timeouts: " + counter + "\n");
|
||||
counter++;
|
||||
if (counter >= 10) {
|
||||
calculationIssues = true;
|
||||
|
@ -29,7 +29,7 @@ public class MessageResponseHandler {
|
||||
public static void getMessage(String message) {
|
||||
if (message != null && !message.isEmpty()) {
|
||||
message = message.replace("@", "");
|
||||
if (message.startsWith("<>")) {
|
||||
if (message.contains("<>")) {
|
||||
message = message.substring(message.indexOf(">"));
|
||||
}
|
||||
if (message.startsWith("[ *")) {
|
||||
|
@ -45,12 +45,14 @@ public class DiscordHandler {
|
||||
}).start();
|
||||
MYSQLDatahandler.shiftReduceParserInitiate();
|
||||
MYSQLDatahandler.instance.instantiateExecutor();
|
||||
if (MYSQLDatahandler.instance.getlHMSMXSize() != 0 && MYSQLDatahandler.instance.getstringCacheSize() != 0) {
|
||||
while (MYSQLDatahandler.instance.getlHMSMXSize() / 2 < (MYSQLDatahandler.instance.getstringCacheSize()
|
||||
/*
|
||||
if (MYSQLDatahandler.instance.getstringCacheSize() != 0) {
|
||||
while (MYSQLDatahandler.instance.getlHMSMXSize() * 3 < (MYSQLDatahandler.instance.getstringCacheSize()
|
||||
* MYSQLDatahandler.instance.getstringCacheSize()) - MYSQLDatahandler.instance.getstringCacheSize()) {
|
||||
MYSQLDatahandler.instance.checkIfUpdateMatrixes();
|
||||
}
|
||||
}
|
||||
*/
|
||||
String token = "NTI5NzAxNTk5NjAyMjc4NDAx.Dw0vDg.7-aMjVWdQMYPl8qVNyvTCPS5F_A";
|
||||
DiscordApi api = new DiscordApiBuilder().setToken(token).login().join();
|
||||
api.addMessageCreateListener(event -> {
|
||||
|
Loading…
Reference in New Issue
Block a user