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