Merge branch 'master' of ssh://git.unloze.com:2222/UNLOZE/projects-jenz
This commit is contained in:
commit
99389c2892
@ -11,4 +11,6 @@ kinda fucking huge
|
|||||||
now requires about 4 GB ram atleast to run.
|
now requires about 4 GB ram atleast to run.
|
||||||
also now requires nlp.stanford.edu/software/stanford-corenlp-full-2018-10-05.zip
|
also now requires nlp.stanford.edu/software/stanford-corenlp-full-2018-10-05.zip
|
||||||
because it needs lexicalized parsers which shift reduce parser does not posses.
|
because it needs lexicalized parsers which shift reduce parser does not posses.
|
||||||
also requires the regular stanford parser except of just shift reduce parser
|
also requires the regular stanford parser except of just shift reduce parser
|
||||||
|
|
||||||
|
jars too large for /lib folder: CorenlpModels-1.0, srParser-1, ws4j-1.0.1, StanfordParserModel-1.0
|
@ -1,99 +1,127 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.mycompany</groupId>
|
<groupId>com.mycompany</groupId>
|
||||||
<artifactId>ArtificialAutism</artifactId>
|
<artifactId>ArtificialAutism</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-dbcp2</artifactId>
|
<artifactId>commons-dbcp2</artifactId>
|
||||||
<version>2.5.0</version>
|
<version>2.5.0</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>mysql</groupId>
|
<groupId>mysql</groupId>
|
||||||
<artifactId>mysql-connector-java</artifactId>
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
<version>8.0.13</version>
|
<version>8.0.13</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.javacord</groupId>
|
<groupId>com.google.guava</groupId>
|
||||||
<artifactId>javacord-api</artifactId>
|
<artifactId>guava</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>26.0-jre</version>
|
||||||
<type>jar</type>
|
</dependency>
|
||||||
</dependency>
|
<dependency>
|
||||||
<dependency>
|
<groupId>com.github.mpkorstanje</groupId>
|
||||||
<groupId>org.javacord</groupId>
|
<artifactId>simmetrics-core</artifactId>
|
||||||
<artifactId>javacord</artifactId>
|
<version>4.1.1</version>
|
||||||
<version>3.0.1</version>
|
</dependency>
|
||||||
<type>pom</type>
|
<dependency>
|
||||||
</dependency>
|
<groupId>ws4j</groupId>
|
||||||
<dependency>
|
<artifactId>ws4j</artifactId>
|
||||||
<groupId>com.google.guava</groupId>
|
<version>1.0.1</version>
|
||||||
<artifactId>guava</artifactId>
|
</dependency>
|
||||||
<version>26.0-jre</version>
|
<dependency>
|
||||||
</dependency>
|
<groupId>StanfordParser</groupId>
|
||||||
<dependency>
|
<artifactId>StanfordParser</artifactId>
|
||||||
<groupId>com.github.mpkorstanje</groupId>
|
<version>1.0</version>
|
||||||
<artifactId>simmetrics-core</artifactId>
|
</dependency>
|
||||||
<version>4.1.1</version>
|
<dependency>
|
||||||
</dependency>
|
<groupId>StanfordParserModel</groupId>
|
||||||
<dependency>
|
<artifactId>StanfordParserModel</artifactId>
|
||||||
<groupId>ws4j</groupId>
|
<version>1.0</version>
|
||||||
<artifactId>ws4j</artifactId>
|
</dependency>
|
||||||
<version>1.0.1</version>
|
<dependency>
|
||||||
</dependency>
|
<groupId>srParser</groupId>
|
||||||
<dependency>
|
<artifactId>srParser</artifactId>
|
||||||
<groupId>StanfordParser</groupId>
|
<version>1</version>
|
||||||
<artifactId>StanfordParser</artifactId>
|
</dependency>
|
||||||
<version>1.0</version>
|
<dependency>
|
||||||
</dependency>
|
<groupId>ejml</groupId>
|
||||||
<dependency>
|
<artifactId>ejml</artifactId>
|
||||||
<groupId>StanfordParserModel</groupId>
|
<version>0.2.3</version>
|
||||||
<artifactId>StanfordParserModel</artifactId>
|
<type>jar</type>
|
||||||
<version>1.0</version>
|
</dependency>
|
||||||
</dependency>
|
<dependency>
|
||||||
<dependency>
|
<groupId>jmweAnno</groupId>
|
||||||
<groupId>srParser</groupId>
|
<artifactId>jmweAnno</artifactId>
|
||||||
<artifactId>srParser</artifactId>
|
<version>1.0</version>
|
||||||
<version>1</version>
|
<type>jar</type>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
<dependency>
|
||||||
<properties>
|
<groupId>edu.mit.jmwe</groupId>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<artifactId>edu.mit.jmwe</artifactId>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<version>1.0.2</version>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<type>jar</type>
|
||||||
<mainClass>PresentationLayer.DiscordHandler</mainClass>
|
</dependency>
|
||||||
</properties>
|
<dependency>
|
||||||
<build>
|
<groupId>CoreNLP</groupId>
|
||||||
<plugins>
|
<artifactId>CoreNLP</artifactId>
|
||||||
<plugin>
|
<version>1.0</version>
|
||||||
<artifactId>maven-dependency-plugin</artifactId>
|
<type>jar</type>
|
||||||
<executions>
|
</dependency>
|
||||||
<execution>
|
<dependency>
|
||||||
<phase>install</phase>
|
<groupId>org.apache.lucene</groupId>
|
||||||
<goals>
|
<artifactId>lucene-analyzers-common</artifactId>
|
||||||
<goal>copy-dependencies</goal>
|
<version>7.2.0</version>
|
||||||
</goals>
|
<type>jar</type>
|
||||||
<configuration>
|
</dependency>
|
||||||
<outputDirectory>${project.build.directory}/lib</outputDirectory>
|
<dependency>
|
||||||
</configuration>
|
<groupId>CorenlpModels</groupId>
|
||||||
</execution>
|
<artifactId>CorenlpModels</artifactId>
|
||||||
</executions>
|
<version>1.0</version>
|
||||||
</plugin>
|
</dependency>
|
||||||
<plugin>
|
<dependency>
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<groupId>com.discord4j</groupId>
|
||||||
<configuration>
|
<artifactId>discord4j-core</artifactId>
|
||||||
<archive>
|
<version>3.1.1</version>
|
||||||
<manifest>
|
</dependency>
|
||||||
<addClasspath>true</addClasspath>
|
</dependencies>
|
||||||
<classpathPrefix>lib/</classpathPrefix>
|
<properties>
|
||||||
<mainClass>${mainClass}</mainClass>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</manifest>
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
</archive>
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
</configuration>
|
<mainClass>PresentationLayer.DiscordHandler</mainClass>
|
||||||
</plugin>
|
</properties>
|
||||||
</plugins>
|
<build>
|
||||||
</build>
|
<plugins>
|
||||||
</project>
|
<plugin>
|
||||||
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>install</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-dependencies</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>${project.build.directory}/lib</outputDirectory>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<archive>
|
||||||
|
<manifest>
|
||||||
|
<addClasspath>true</addClasspath>
|
||||||
|
<classpathPrefix>lib/</classpathPrefix>
|
||||||
|
<mainClass>${mainClass}</mainClass>
|
||||||
|
</manifest>
|
||||||
|
</archive>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
@ -179,7 +179,7 @@ public class Datahandler {
|
|||||||
|
|
||||||
public void updateStringCache() {
|
public void updateStringCache() {
|
||||||
try {
|
try {
|
||||||
checkIfUpdateStrings(true);
|
checkIfUpdateStrings();
|
||||||
} catch (CustomError ex) {
|
} catch (CustomError ex) {
|
||||||
Logger.getLogger(Datahandler.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(Datahandler.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
@ -225,7 +225,7 @@ public class Datahandler {
|
|||||||
hlStatsMessages.put(str, hlStatsMessages.size());
|
hlStatsMessages.put(str, hlStatsMessages.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int capacity = 50;
|
int capacity = 150;
|
||||||
hlStatsMessages.keySet().forEach(str -> {
|
hlStatsMessages.keySet().forEach(str -> {
|
||||||
if (!str.startsWith("!") && MessageResponseHandler.getStr().values().size() < capacity) {
|
if (!str.startsWith("!") && MessageResponseHandler.getStr().values().size() < capacity) {
|
||||||
String orElse = strCacheLocal.values().parallelStream().filter(e -> e.equals(str)).findAny().orElse(null);
|
String orElse = strCacheLocal.values().parallelStream().filter(e -> e.equals(str)).findAny().orElse(null);
|
||||||
@ -318,8 +318,16 @@ public class Datahandler {
|
|||||||
SentimentValueCache sentimentCacheStr = sentimentCachingMap.getOrDefault(strCollection, null);
|
SentimentValueCache sentimentCacheStr = sentimentCachingMap.getOrDefault(strCollection, null);
|
||||||
List<SimilarityMatrix> smxReturnList = new ArrayList();
|
List<SimilarityMatrix> smxReturnList = new ArrayList();
|
||||||
List<String> randomIterationComparision = new ArrayList();
|
List<String> randomIterationComparision = new ArrayList();
|
||||||
int iteratecap = strCacheLocal.size() > prefix_size ? strCacheLocal.size() - prefix_size : strCacheLocal.size();
|
if (strCacheLocal.size() < prefix_size)
|
||||||
|
{
|
||||||
|
for (String colStr : strCollection)
|
||||||
|
{
|
||||||
|
strCacheLocal.put(strCacheLocal.size(), colStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int iteratecap = strCacheLocal.size() > prefix_size ? strCacheLocal.size() - prefix_size : strCacheLocal.size() - 1;
|
||||||
int iterator = ThreadLocalRandom.current().nextInt(0, iteratecap);
|
int iterator = ThreadLocalRandom.current().nextInt(0, iteratecap);
|
||||||
|
|
||||||
int iterated = 0;
|
int iterated = 0;
|
||||||
for (String str1 : strCacheLocal.values()) {
|
for (String str1 : strCacheLocal.values()) {
|
||||||
if (iterated >= iterator && iterated < iterator + prefix_size) {
|
if (iterated >= iterator && iterated < iterator + prefix_size) {
|
||||||
@ -390,7 +398,6 @@ public class Datahandler {
|
|||||||
//System.out.println("strmap siuze: " + strmap.size());
|
//System.out.println("strmap siuze: " + strmap.size());
|
||||||
List<SimilarityMatrix> StrComparringNoSentenceRelationMap = StrComparringNoSentenceRelationMap(strCacheLocal, strmap.values(),
|
List<SimilarityMatrix> StrComparringNoSentenceRelationMap = StrComparringNoSentenceRelationMap(strCacheLocal, strmap.values(),
|
||||||
localJMWEMap, localPipelineAnnotation, localPipelineSentimentAnnotation, localCoreDocumentMap);
|
localJMWEMap, localPipelineAnnotation, localPipelineSentimentAnnotation, localCoreDocumentMap);
|
||||||
System.out.println("StrComparringNoSentenceRelationMap size: " + StrComparringNoSentenceRelationMap.size());
|
|
||||||
Collections.sort(StrComparringNoSentenceRelationMap, (e1, e2) -> e1.getPrimaryString().compareTo(e2.getPrimaryString()));
|
Collections.sort(StrComparringNoSentenceRelationMap, (e1, e2) -> e1.getPrimaryString().compareTo(e2.getPrimaryString()));
|
||||||
ConcurrentMap<Integer, String> strmapreturn = futuresReturnOverallEvaluation(StrComparringNoSentenceRelationMap);
|
ConcurrentMap<Integer, String> strmapreturn = futuresReturnOverallEvaluation(StrComparringNoSentenceRelationMap);
|
||||||
//System.out.println("strmapreturn size: " + strmapreturn.size());
|
//System.out.println("strmapreturn size: " + strmapreturn.size());
|
||||||
@ -398,7 +405,7 @@ public class Datahandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ConcurrentMap<Integer, String> removeNonSensicalStrings(ConcurrentMap<Integer, String> strmap) {
|
private ConcurrentMap<Integer, String> removeNonSensicalStrings(ConcurrentMap<Integer, String> strmap) {
|
||||||
final ConcurrentMap<Integer, String> strCacheLocal = stringCache.size() < 150 ? strmap : stringCache;
|
final ConcurrentMap<Integer, String> strCacheLocal = stringCache;
|
||||||
final ConcurrentMap<String, Annotation> localJMWEMap = getMultipleJMWEAnnotation(strmap.values());
|
final ConcurrentMap<String, Annotation> localJMWEMap = getMultipleJMWEAnnotation(strmap.values());
|
||||||
final ConcurrentMap<String, Annotation> localPipelineAnnotation = getMultiplePipelineAnnotation(strmap.values());
|
final ConcurrentMap<String, Annotation> localPipelineAnnotation = getMultiplePipelineAnnotation(strmap.values());
|
||||||
final ConcurrentMap<String, Annotation> localPipelineSentimentAnnotation = getMultiplePipelineSentimentAnnotation(strmap.values());
|
final ConcurrentMap<String, Annotation> localPipelineSentimentAnnotation = getMultiplePipelineSentimentAnnotation(strmap.values());
|
||||||
@ -406,16 +413,13 @@ public class Datahandler {
|
|||||||
return stringIteratorComparator(strmap, strCacheLocal, localJMWEMap, localPipelineAnnotation, localPipelineSentimentAnnotation, localCoreDocumentMap);
|
return stringIteratorComparator(strmap, strCacheLocal, localJMWEMap, localPipelineAnnotation, localPipelineSentimentAnnotation, localCoreDocumentMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void checkIfUpdateStrings(boolean hlStatsMsg) throws CustomError {
|
public synchronized void checkIfUpdateStrings() throws CustomError {
|
||||||
if (stopwatch.elapsed(TimeUnit.SECONDS) >= EXPIRE_TIME_IN_SECONDS || !stopwatch.isRunning()) {
|
if (stopwatch.elapsed(TimeUnit.SECONDS) >= EXPIRE_TIME_IN_SECONDS || !stopwatch.isRunning()) {
|
||||||
ConcurrentMap<Integer, String> str = MessageResponseHandler.getStr();
|
ConcurrentMap<Integer, String> str = MessageResponseHandler.getStr();
|
||||||
System.out.println("str size: " + str.size());
|
System.out.println("str size: " + str.size());
|
||||||
str = cutContent(str, hlStatsMsg);
|
|
||||||
str = filterContent(str);
|
str = filterContent(str);
|
||||||
str = removeSlacks(str);
|
|
||||||
//System.out.println("finished removeSlacks \n" + str.size() + "\n");
|
|
||||||
str = removeNonSensicalStrings(str);
|
str = removeNonSensicalStrings(str);
|
||||||
System.out.println("removeNonSensicalStrings str size POST: " + str.size() + "\n");
|
//System.out.println("removeNonSensicalStrings str size POST: " + str.size() + "\n");
|
||||||
str = annotationCacheUpdate(str);
|
str = annotationCacheUpdate(str);
|
||||||
System.out.println("annotationCacheUpdate str size POST: " + str.size() + "\n");
|
System.out.println("annotationCacheUpdate str size POST: " + str.size() + "\n");
|
||||||
ConcurrentMap<Integer, String> strf = str;
|
ConcurrentMap<Integer, String> strf = str;
|
||||||
@ -616,20 +620,6 @@ public class Datahandler {
|
|||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ConcurrentMap<Integer, String> cutContent(ConcurrentMap<Integer, String> str, boolean hlStatsMsg) {
|
|
||||||
ConcurrentMap<Integer, String> returnlist = new MapMaker().concurrencyLevel(2).makeMap();
|
|
||||||
str.values().forEach(str1 -> {
|
|
||||||
int iend = str1.indexOf("content: ");
|
|
||||||
if (iend != -1) {
|
|
||||||
String trs = str1.substring(iend + 9);
|
|
||||||
returnlist.put(returnlist.size() + 1, trs.substring(0, trs.length() - 1));
|
|
||||||
} else if (hlStatsMsg) {
|
|
||||||
returnlist.put(returnlist.size() + 1, str1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return returnlist;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ConcurrentMap<Integer, String> filterContent(ConcurrentMap<Integer, String> str) {
|
public static ConcurrentMap<Integer, String> filterContent(ConcurrentMap<Integer, String> str) {
|
||||||
ConcurrentMap<Integer, String> strlistreturn = new MapMaker().concurrencyLevel(2).makeMap();
|
ConcurrentMap<Integer, String> strlistreturn = new MapMaker().concurrencyLevel(2).makeMap();
|
||||||
str.values().forEach(str1 -> {
|
str.values().forEach(str1 -> {
|
||||||
@ -641,12 +631,15 @@ public class Datahandler {
|
|||||||
if (str1.contains("AM*")) {
|
if (str1.contains("AM*")) {
|
||||||
str1 = str1.substring(str1.indexOf("AM*") + 3);
|
str1 = str1.substring(str1.indexOf("AM*") + 3);
|
||||||
}
|
}
|
||||||
for (Character c : str1.toCharArray()) {
|
if (str1.contains("?") || str1.contains("°"))
|
||||||
if (c == '?' || c == '°') {
|
{
|
||||||
|
if (!str1.contains("http"))
|
||||||
|
{
|
||||||
str1 = str1.replace("?", " <:wlenny:514861023002624001> ");
|
str1 = str1.replace("?", " <:wlenny:514861023002624001> ");
|
||||||
str1 = str1.replace("°", " <:wlenny:514861023002624001> ");
|
str1 = str1.replace("°", " <:wlenny:514861023002624001> ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (str1.contains("(Counter-Terrorist)")) {
|
if (str1.contains("(Counter-Terrorist)")) {
|
||||||
str1 = str1.replace("(Counter-Terrorist)", " ");
|
str1 = str1.replace("(Counter-Terrorist)", " ");
|
||||||
}
|
}
|
||||||
@ -730,38 +723,13 @@ public class Datahandler {
|
|||||||
}
|
}
|
||||||
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(), str1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return strlistreturn;
|
return strlistreturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ConcurrentMap<Integer, String> removeSlacks(ConcurrentMap<Integer, String> str) {
|
|
||||||
ConcurrentMap<Integer, String> strreturn = new MapMaker().concurrencyLevel(2).makeMap();
|
|
||||||
if (stringCache.isEmpty()) {
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
Collection<String> values = stringCache.values();
|
|
||||||
str.values().forEach(str1 -> {
|
|
||||||
boolean tooclosematch = false;
|
|
||||||
for (String strVals : values) {
|
|
||||||
LevenshteinDistance leven = new LevenshteinDistance(strVals, str1);
|
|
||||||
double Distance = leven.computeLevenshteinDistance();
|
|
||||||
Double maxpermittedDistance = 2.5;
|
|
||||||
if (Distance < maxpermittedDistance) {
|
|
||||||
tooclosematch = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!tooclosematch) {
|
|
||||||
strreturn.put(strreturn.size() + 1, str1);
|
|
||||||
//System.out.println("adding strreturn str1: " + str1 + "\n");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return strreturn;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ConcurrentMap<Integer, String> annotationCacheUpdate(ConcurrentMap<Integer, String> strmap) {
|
private ConcurrentMap<Integer, String> annotationCacheUpdate(ConcurrentMap<Integer, String> strmap) {
|
||||||
ConcurrentMap<String, Annotation> jmweAnnotation = PipelineJMWESingleton.INSTANCE.getJMWEAnnotation(strmap.values());
|
ConcurrentMap<String, Annotation> jmweAnnotation = PipelineJMWESingleton.INSTANCE.getJMWEAnnotation(strmap.values());
|
||||||
for (Entry<String, Annotation> jmweitr : jmweAnnotation.entrySet()) {
|
for (Entry<String, Annotation> jmweitr : jmweAnnotation.entrySet()) {
|
||||||
|
@ -6,13 +6,17 @@
|
|||||||
package FunctionLayer;
|
package FunctionLayer;
|
||||||
|
|
||||||
import PresentationLayer.DiscordHandler;
|
import PresentationLayer.DiscordHandler;
|
||||||
|
import discord4j.core.event.domain.message.MessageCreateEvent;
|
||||||
|
import discord4j.core.object.entity.User;
|
||||||
|
import discord4j.core.object.entity.channel.TextChannel;
|
||||||
|
import java.math.BigInteger;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.javacord.api.DiscordApi;
|
import reactor.core.publisher.Flux;
|
||||||
import org.javacord.api.entity.user.User;
|
import reactor.core.publisher.Mono;
|
||||||
import org.javacord.api.event.message.MessageCreateEvent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -26,17 +30,25 @@ public class DoStuff {
|
|||||||
return occupied;
|
return occupied;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void doStuff(MessageCreateEvent event, DiscordApi api) {
|
public static void doStuff(MessageCreateEvent event, String usernameBot) {
|
||||||
if (!event.getMessage().getAuthor().isYourself()) {
|
String username = null;
|
||||||
|
try {
|
||||||
|
username = event.getMessage().getAuthor().get().getUsername();
|
||||||
|
} catch (java.util.NoSuchElementException e) {
|
||||||
|
username = null;
|
||||||
|
}
|
||||||
|
if (username != null && !username.equals(usernameBot)) {
|
||||||
occupied = true;
|
occupied = true;
|
||||||
String strtest = event.getServerTextChannel().get().getCategory().toString();
|
TextChannel block = event.getMessage().getChannel().cast(TextChannel.class).block();
|
||||||
strtest = strtest.substring(9, strtest.length() - 1);
|
String name = block.getCategory().block().getName();
|
||||||
|
name = name.toLowerCase();
|
||||||
|
String channelName = block.getName().toLowerCase();
|
||||||
boolean channelpermissionsDenied = false;
|
boolean channelpermissionsDenied = false;
|
||||||
switch (strtest) {
|
switch (name) {
|
||||||
case "Public Area": {
|
case "public area": {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "Information Area": {
|
case "information area": {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
@ -44,25 +56,35 @@ public class DoStuff {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
List<User> blockLast = event.getMessage().getUserMentions().buffer().blockLast();
|
||||||
|
String content = event.getMessage().getContent();
|
||||||
if (!channelpermissionsDenied) {
|
if (!channelpermissionsDenied) {
|
||||||
List<User> userlist = event.getMessage().getMentionedUsers();
|
if (blockLast != null)
|
||||||
String strresult = event.getMessage().toString();
|
{
|
||||||
if (userlist != null) {
|
for (User user : blockLast) {
|
||||||
for (User user : userlist) {
|
content = content.replace(user.getId().asString(), "");
|
||||||
strresult = strresult.replace(user.getIdAsString(), "");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MessageResponseHandler.getMessage(strresult);
|
MessageResponseHandler.getMessage(content);
|
||||||
}
|
}
|
||||||
if (event.getMessage().getMentionedUsers().contains(api.getYourself())
|
boolean mentionedBot = false;
|
||||||
|| event.getServerTextChannel().get().toString().contains("general-autism")) {
|
if (blockLast != null){
|
||||||
|
for (User user : blockLast)
|
||||||
|
{
|
||||||
|
if (user.getUsername().equals(usernameBot))
|
||||||
|
{
|
||||||
|
mentionedBot = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mentionedBot || channelName.contains("general-autism")) {
|
||||||
try {
|
try {
|
||||||
String ResponseStr;
|
String ResponseStr;
|
||||||
String person = event.getMessageAuthor().getName();
|
ResponseStr = MessageResponseHandler.selectReponseMessage(content, username);
|
||||||
ResponseStr = MessageResponseHandler.selectReponseMessage(event.getMessage().toString(), person);
|
|
||||||
if (!ResponseStr.isEmpty()) {
|
if (!ResponseStr.isEmpty()) {
|
||||||
System.out.print("\nResponseStr3: " + ResponseStr + "\n");
|
System.out.print("\nResponseStr3: " + ResponseStr + "\n");
|
||||||
event.getChannel().sendMessage(ResponseStr);
|
event.getMessage().getChannel().block().createMessage(ResponseStr).block();
|
||||||
}
|
}
|
||||||
} catch (CustomError ex) {
|
} catch (CustomError ex) {
|
||||||
Logger.getLogger(DoStuff.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(DoStuff.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
@ -71,7 +93,7 @@ public class DoStuff {
|
|||||||
}
|
}
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
Datahandler.instance.checkIfUpdateStrings(false);
|
Datahandler.instance.checkIfUpdateStrings();
|
||||||
} catch (CustomError ex) {
|
} catch (CustomError ex) {
|
||||||
Logger.getLogger(DiscordHandler.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(DiscordHandler.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,6 @@ public class MessageResponseHandler {
|
|||||||
public static String selectReponseMessage(String toString, String personName) throws CustomError {
|
public static String selectReponseMessage(String toString, String personName) throws CustomError {
|
||||||
ConcurrentMap<Integer, String> str1 = new MapMaker().concurrencyLevel(6).makeMap();
|
ConcurrentMap<Integer, String> str1 = new MapMaker().concurrencyLevel(6).makeMap();
|
||||||
str1.put(str1.size() + 1, toString);
|
str1.put(str1.size() + 1, toString);
|
||||||
str1 = Datahandler.cutContent(str1, false);
|
|
||||||
String strreturn = "";
|
String strreturn = "";
|
||||||
for (String str : str1.values()) {
|
for (String str : str1.values()) {
|
||||||
if (!str.isEmpty()) {
|
if (!str.isEmpty()) {
|
||||||
|
@ -17,14 +17,19 @@ package PresentationLayer;
|
|||||||
import FunctionLayer.Datahandler;
|
import FunctionLayer.Datahandler;
|
||||||
import FunctionLayer.DoStuff;
|
import FunctionLayer.DoStuff;
|
||||||
import FunctionLayer.PipelineJMWESingleton;
|
import FunctionLayer.PipelineJMWESingleton;
|
||||||
|
import discord4j.core.DiscordClient;
|
||||||
|
import discord4j.core.GatewayDiscordClient;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.javacord.api.DiscordApi;
|
import DataLayer.settings;
|
||||||
import org.javacord.api.DiscordApiBuilder;
|
import discord4j.common.util.Snowflake;
|
||||||
|
import discord4j.core.event.domain.message.MessageCreateEvent;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -48,15 +53,19 @@ public class DiscordHandler {
|
|||||||
System.out.println("FINISHED ALL ANNOTATIONS");
|
System.out.println("FINISHED ALL ANNOTATIONS");
|
||||||
Datahandler.instance.addHLstatsMessages();
|
Datahandler.instance.addHLstatsMessages();
|
||||||
Datahandler.instance.updateStringCache();
|
Datahandler.instance.updateStringCache();
|
||||||
String token = "NTI5NzAxNTk5NjAyMjc4NDAx.Dw0vDg.7-aMjVWdQMYPl8qVNyvTCPS5F_A";
|
//String token = "NTI5NzAxNTk5NjAyMjc4NDAx.Dw0vDg.7-aMjVWdQMYPl8qVNyvTCPS5F_A";
|
||||||
DiscordApi api = new DiscordApiBuilder().setToken(token).login().join();
|
String token = new settings().getDiscordToken();
|
||||||
|
final DiscordClient client = DiscordClient.create(token);
|
||||||
|
final GatewayDiscordClient gateway = client.login().block();
|
||||||
|
String usernameBot = gateway.getSelf().block().getUsername();
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
Datahandler.instance.update_autismo_socket_msg();
|
Datahandler.instance.update_autismo_socket_msg();
|
||||||
}).start();
|
}).start();
|
||||||
api.addMessageCreateListener(event -> {
|
gateway.on(MessageCreateEvent.class).subscribe(event -> {
|
||||||
if (!FunctionLayer.DoStuff.isOccupied()) {
|
if (!FunctionLayer.DoStuff.isOccupied()) {
|
||||||
FunctionLayer.DoStuff.doStuff(event, api);
|
FunctionLayer.DoStuff.doStuff(event, usernameBot);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
gateway.onDisconnect().block();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
ArtificialAutism/target/classes/DataLayer/settings.class
Normal file
BIN
ArtificialAutism/target/classes/DataLayer/settings.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
ArtificialAutism/target/classes/FunctionLayer/Datahandler.class
Normal file
BIN
ArtificialAutism/target/classes/FunctionLayer/Datahandler.class
Normal file
Binary file not shown.
BIN
ArtificialAutism/target/classes/FunctionLayer/DoStuff.class
Normal file
BIN
ArtificialAutism/target/classes/FunctionLayer/DoStuff.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
ArtificialAutism/target/lib/CoreNLP-1.0.jar
Normal file
BIN
ArtificialAutism/target/lib/CoreNLP-1.0.jar
Normal file
Binary file not shown.
BIN
ArtificialAutism/target/lib/Servicer-1.0.3.jar
Normal file
BIN
ArtificialAutism/target/lib/Servicer-1.0.3.jar
Normal file
Binary file not shown.
BIN
ArtificialAutism/target/lib/discord-json-1.5.4.jar
Normal file
BIN
ArtificialAutism/target/lib/discord-json-1.5.4.jar
Normal file
Binary file not shown.
BIN
ArtificialAutism/target/lib/discord-json-api-1.5.4.jar
Normal file
BIN
ArtificialAutism/target/lib/discord-json-api-1.5.4.jar
Normal file
Binary file not shown.
BIN
ArtificialAutism/target/lib/discord4j-common-3.1.1.jar
Normal file
BIN
ArtificialAutism/target/lib/discord4j-common-3.1.1.jar
Normal file
Binary file not shown.
BIN
ArtificialAutism/target/lib/discord4j-core-3.1.1.jar
Normal file
BIN
ArtificialAutism/target/lib/discord4j-core-3.1.1.jar
Normal file
Binary file not shown.
BIN
ArtificialAutism/target/lib/discord4j-gateway-3.1.1.jar
Normal file
BIN
ArtificialAutism/target/lib/discord4j-gateway-3.1.1.jar
Normal file
Binary file not shown.
BIN
ArtificialAutism/target/lib/discord4j-rest-3.1.1.jar
Normal file
BIN
ArtificialAutism/target/lib/discord4j-rest-3.1.1.jar
Normal file
Binary file not shown.
BIN
ArtificialAutism/target/lib/discord4j-voice-3.1.1.jar
Normal file
BIN
ArtificialAutism/target/lib/discord4j-voice-3.1.1.jar
Normal file
Binary file not shown.
BIN
ArtificialAutism/target/lib/edu.mit.jmwe-1.0.2.jar
Normal file
BIN
ArtificialAutism/target/lib/edu.mit.jmwe-1.0.2.jar
Normal file
Binary file not shown.
BIN
ArtificialAutism/target/lib/ejml-0.2.3.jar
Normal file
BIN
ArtificialAutism/target/lib/ejml-0.2.3.jar
Normal file
Binary file not shown.
BIN
ArtificialAutism/target/lib/jackson-annotations-2.11.2.jar
Normal file
BIN
ArtificialAutism/target/lib/jackson-annotations-2.11.2.jar
Normal file
Binary file not shown.
BIN
ArtificialAutism/target/lib/jackson-core-2.11.2.jar
Normal file
BIN
ArtificialAutism/target/lib/jackson-core-2.11.2.jar
Normal file
Binary file not shown.
BIN
ArtificialAutism/target/lib/jackson-databind-2.11.2.jar
Normal file
BIN
ArtificialAutism/target/lib/jackson-databind-2.11.2.jar
Normal file
Binary file not shown.
BIN
ArtificialAutism/target/lib/jackson-datatype-jdk8-2.11.2.jar
Normal file
BIN
ArtificialAutism/target/lib/jackson-datatype-jdk8-2.11.2.jar
Normal file
Binary file not shown.
BIN
ArtificialAutism/target/lib/jmweAnno-1.0.jar
Normal file
BIN
ArtificialAutism/target/lib/jmweAnno-1.0.jar
Normal file
Binary file not shown.
BIN
ArtificialAutism/target/lib/lucene-analyzers-common-7.2.0.jar
Normal file
BIN
ArtificialAutism/target/lib/lucene-analyzers-common-7.2.0.jar
Normal file
Binary file not shown.
BIN
ArtificialAutism/target/lib/lucene-core-7.2.0.jar
Normal file
BIN
ArtificialAutism/target/lib/lucene-core-7.2.0.jar
Normal file
Binary file not shown.
BIN
ArtificialAutism/target/lib/netty-buffer-4.1.52.Final.jar
Normal file
BIN
ArtificialAutism/target/lib/netty-buffer-4.1.52.Final.jar
Normal file
Binary file not shown.
BIN
ArtificialAutism/target/lib/netty-codec-4.1.52.Final.jar
Normal file
BIN
ArtificialAutism/target/lib/netty-codec-4.1.52.Final.jar
Normal file
Binary file not shown.
BIN
ArtificialAutism/target/lib/netty-codec-http-4.1.52.Final.jar
Normal file
BIN
ArtificialAutism/target/lib/netty-codec-http-4.1.52.Final.jar
Normal file
Binary file not shown.
BIN
ArtificialAutism/target/lib/netty-codec-http2-4.1.52.Final.jar
Normal file
BIN
ArtificialAutism/target/lib/netty-codec-http2-4.1.52.Final.jar
Normal file
Binary file not shown.
BIN
ArtificialAutism/target/lib/netty-codec-socks-4.1.52.Final.jar
Normal file
BIN
ArtificialAutism/target/lib/netty-codec-socks-4.1.52.Final.jar
Normal file
Binary file not shown.
BIN
ArtificialAutism/target/lib/netty-common-4.1.52.Final.jar
Normal file
BIN
ArtificialAutism/target/lib/netty-common-4.1.52.Final.jar
Normal file
Binary file not shown.
BIN
ArtificialAutism/target/lib/netty-handler-4.1.52.Final.jar
Normal file
BIN
ArtificialAutism/target/lib/netty-handler-4.1.52.Final.jar
Normal file
Binary file not shown.
BIN
ArtificialAutism/target/lib/netty-handler-proxy-4.1.52.Final.jar
Normal file
BIN
ArtificialAutism/target/lib/netty-handler-proxy-4.1.52.Final.jar
Normal file
Binary file not shown.
BIN
ArtificialAutism/target/lib/netty-resolver-4.1.52.Final.jar
Normal file
BIN
ArtificialAutism/target/lib/netty-resolver-4.1.52.Final.jar
Normal file
Binary file not shown.
BIN
ArtificialAutism/target/lib/netty-transport-4.1.52.Final.jar
Normal file
BIN
ArtificialAutism/target/lib/netty-transport-4.1.52.Final.jar
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
ArtificialAutism/target/lib/reactive-streams-1.0.3.jar
Normal file
BIN
ArtificialAutism/target/lib/reactive-streams-1.0.3.jar
Normal file
Binary file not shown.
BIN
ArtificialAutism/target/lib/reactor-core-3.3.10.RELEASE.jar
Normal file
BIN
ArtificialAutism/target/lib/reactor-core-3.3.10.RELEASE.jar
Normal file
Binary file not shown.
BIN
ArtificialAutism/target/lib/reactor-extra-3.3.4.RELEASE.jar
Normal file
BIN
ArtificialAutism/target/lib/reactor-extra-3.3.4.RELEASE.jar
Normal file
Binary file not shown.
BIN
ArtificialAutism/target/lib/reactor-netty-0.9.12.RELEASE.jar
Normal file
BIN
ArtificialAutism/target/lib/reactor-netty-0.9.12.RELEASE.jar
Normal file
Binary file not shown.
BIN
ArtificialAutism/target/lib/simple-fsm-1.0.1.jar
Normal file
BIN
ArtificialAutism/target/lib/simple-fsm-1.0.1.jar
Normal file
Binary file not shown.
BIN
ArtificialAutism/target/lib/stores-api-3.1.4.jar
Normal file
BIN
ArtificialAutism/target/lib/stores-api-3.1.4.jar
Normal file
Binary file not shown.
BIN
ArtificialAutism/target/lib/stores-jdk-3.1.4.jar
Normal file
BIN
ArtificialAutism/target/lib/stores-jdk-3.1.4.jar
Normal file
Binary file not shown.
Binary file not shown.
@ -1,5 +1,5 @@
|
|||||||
#Generated by Maven
|
#Generated by Maven
|
||||||
#Sat Feb 02 20:31:02 CET 2019
|
#Mon Nov 02 11:08:19 CET 2020
|
||||||
version=1.0
|
version=1.0
|
||||||
groupId=com.mycompany
|
groupId=com.mycompany
|
||||||
artifactId=ArtificialAutism
|
artifactId=ArtificialAutism
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
FunctionLayer\Datahandler.class
|
||||||
|
FunctionLayer\Datahandler$AnnotationCollector.class
|
||||||
|
FunctionLayer\SimilarityMatrix.class
|
||||||
|
FunctionLayer\StanfordParser\SentimentValueCache.class
|
||||||
|
DataLayer\DBCPDataSource.class
|
||||||
|
DataLayer\settings.class
|
||||||
|
FunctionLayer\LevenshteinDistance.class
|
||||||
|
FunctionLayer\CustomError.class
|
||||||
|
FunctionLayer\StanfordParser\SentimentAnalyzerTest.class
|
||||||
|
DataLayer\DataMapper.class
|
||||||
|
FunctionLayer\StopwordAnnotator.class
|
||||||
|
DataLayer\DBCPDataSourceHLstats.class
|
||||||
|
FunctionLayer\DoStuff.class
|
||||||
|
FunctionLayer\PipelineJMWESingleton.class
|
||||||
|
PresentationLayer\DiscordHandler.class
|
||||||
|
FunctionLayer\Datahandler$1.class
|
||||||
|
FunctionLayer\MessageResponseHandler.class
|
@ -0,0 +1,15 @@
|
|||||||
|
E:\stationær backup filer\Projects\ArtificialAutism\src\main\java\FunctionLayer\DoStuff.java
|
||||||
|
E:\stationær backup filer\Projects\ArtificialAutism\src\main\java\PresentationLayer\DiscordHandler.java
|
||||||
|
E:\stationær backup filer\Projects\ArtificialAutism\src\main\java\DataLayer\DBCPDataSourceHLstats.java
|
||||||
|
E:\stationær backup filer\Projects\ArtificialAutism\src\main\java\DataLayer\settings.java
|
||||||
|
E:\stationær backup filer\Projects\ArtificialAutism\src\main\java\FunctionLayer\LevenshteinDistance.java
|
||||||
|
E:\stationær backup filer\Projects\ArtificialAutism\src\main\java\FunctionLayer\StopwordAnnotator.java
|
||||||
|
E:\stationær backup filer\Projects\ArtificialAutism\src\main\java\FunctionLayer\StanfordParser\SentimentAnalyzerTest.java
|
||||||
|
E:\stationær backup filer\Projects\ArtificialAutism\src\main\java\FunctionLayer\PipelineJMWESingleton.java
|
||||||
|
E:\stationær backup filer\Projects\ArtificialAutism\src\main\java\DataLayer\DataMapper.java
|
||||||
|
E:\stationær backup filer\Projects\ArtificialAutism\src\main\java\FunctionLayer\CustomError.java
|
||||||
|
E:\stationær backup filer\Projects\ArtificialAutism\src\main\java\FunctionLayer\SimilarityMatrix.java
|
||||||
|
E:\stationær backup filer\Projects\ArtificialAutism\src\main\java\DataLayer\DBCPDataSource.java
|
||||||
|
E:\stationær backup filer\Projects\ArtificialAutism\src\main\java\FunctionLayer\MessageResponseHandler.java
|
||||||
|
E:\stationær backup filer\Projects\ArtificialAutism\src\main\java\FunctionLayer\Datahandler.java
|
||||||
|
E:\stationær backup filer\Projects\ArtificialAutism\src\main\java\FunctionLayer\StanfordParser\SentimentValueCache.java
|
Loading…
Reference in New Issue
Block a user