some bot overhauls
This commit is contained in:
parent
00f91030f9
commit
d62cdf3aeb
@ -20,9 +20,9 @@ public class DBCPDataSource {
|
|||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
ds.setDriver(new com.mysql.cj.jdbc.Driver());
|
ds.setDriver(new com.mysql.cj.jdbc.Driver());
|
||||||
ds.setUrl("jdbc:mysql://104.248.40.216:3306/ArtificialAutism?useLegacyDatetimeCode=false&serverTimezone=UTC");
|
ds.setUrl("jdbc:mysql://163.172.84.14:3306/ArtificialAutism?useLegacyDatetimeCode=false&serverTimezone=UTC");
|
||||||
ds.setUsername("root");
|
ds.setUsername("root");
|
||||||
ds.setPassword("fb345972349fnsDW234/¤)#2");
|
ds.setPassword("FJEF23423u5r9BFhBFEBFIB234h29");
|
||||||
ds.setMaxTotal(-1);
|
ds.setMaxTotal(-1);
|
||||||
ds.setMinIdle(5);
|
ds.setMinIdle(5);
|
||||||
ds.setMaxIdle(-1);
|
ds.setMaxIdle(-1);
|
||||||
|
@ -38,12 +38,6 @@ public class DataMapper {
|
|||||||
+ "ENGINE = InnoDB;";
|
+ "ENGINE = InnoDB;";
|
||||||
l_pStatement = l_cCon.prepareStatement(l_sSQL);
|
l_pStatement = l_cCon.prepareStatement(l_sSQL);
|
||||||
l_pStatement.execute();
|
l_pStatement.execute();
|
||||||
l_sSQL = "CREATE TABLE IF NOT EXISTS `ArtificialAutism`.`WordMatrix` (`Str1` VARCHAR(254) NOT NULL, `Str2` VARCHAR(254) NOT NULL,\n"
|
|
||||||
+ " `Distance` DOUBLE NOT NULL, `ID` INT NOT NULL AUTO_INCREMENT,\n"
|
|
||||||
+ " PRIMARY KEY (`ID`))\n"
|
|
||||||
+ "ENGINE = InnoDB;";
|
|
||||||
l_pStatement = l_cCon.prepareStatement(l_sSQL);
|
|
||||||
l_pStatement.execute();
|
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
throw new CustomError("failed in DataMapper " + ex.getMessage());
|
throw new CustomError("failed in DataMapper " + ex.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
@ -87,7 +81,7 @@ public class DataMapper {
|
|||||||
java.sql.ResultSet.CONCUR_READ_ONLY);
|
java.sql.ResultSet.CONCUR_READ_ONLY);
|
||||||
l_pStatement.setFetchSize(Integer.MIN_VALUE);
|
l_pStatement.setFetchSize(Integer.MIN_VALUE);
|
||||||
for (String str1 : str.values()) {
|
for (String str1 : str.values()) {
|
||||||
System.out.println("adding str1: " + str1 + "\n");
|
//System.out.println("adding str1: " + str1 + "\n");
|
||||||
l_pStatement.setString(1, str1);
|
l_pStatement.setString(1, str1);
|
||||||
l_pStatement.addBatch();
|
l_pStatement.addBatch();
|
||||||
}
|
}
|
||||||
@ -99,81 +93,6 @@ public class DataMapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getSementicsDBRows() {
|
|
||||||
int count = 0;
|
|
||||||
try (Connection l_cCon = DBCPDataSource.getConnection()) {
|
|
||||||
try (Statement s = l_cCon.createStatement();
|
|
||||||
ResultSet r = s.executeQuery("SELECT COUNT(*) AS rowcount FROM WordMatrix")) {
|
|
||||||
r.next();
|
|
||||||
count = r.getInt("rowcount");
|
|
||||||
}
|
|
||||||
} catch (SQLException ex) {
|
|
||||||
Logger.getLogger(DataMapper.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void insertSementicMatrixes(ConcurrentMap<Integer, SimilarityMatrix> WS4JListUpdate) throws CustomError {
|
|
||||||
Connection l_cCon = null;
|
|
||||||
PreparedStatement l_pStatement = null;
|
|
||||||
ResultSet l_rsSearch = null;
|
|
||||||
String l_sSQL = "INSERT IGNORE `WordMatrix` (`Str1`,`Str2`,`Distance`) VALUES (?, ?, ?)";
|
|
||||||
try {
|
|
||||||
l_cCon = DBCPDataSource.getConnection();
|
|
||||||
l_pStatement = l_cCon.prepareStatement(l_sSQL, java.sql.ResultSet.TYPE_FORWARD_ONLY,
|
|
||||||
java.sql.ResultSet.CONCUR_READ_ONLY);
|
|
||||||
l_pStatement.setFetchSize(0);
|
|
||||||
System.out.println("Matrix update size: " + WS4JListUpdate.size());
|
|
||||||
for (SimilarityMatrix ws4j : WS4JListUpdate.values()) {
|
|
||||||
l_pStatement.setString(1, ws4j.getPrimaryString());
|
|
||||||
l_pStatement.setString(2, ws4j.getSecondaryString());
|
|
||||||
l_pStatement.setDouble(3, ws4j.getDistance());
|
|
||||||
l_pStatement.addBatch();
|
|
||||||
}
|
|
||||||
l_pStatement.executeBatch();
|
|
||||||
} catch (SQLException ex) {
|
|
||||||
throw new CustomError("failed in DataMapper " + ex.getMessage());
|
|
||||||
} finally {
|
|
||||||
CloseConnections(l_pStatement, l_rsSearch, l_cCon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
public static LinkedHashMap<String, LinkedHashMap<String, Double>> getAllRelationScores() {
|
|
||||||
int count = getSementicsDBRows();
|
|
||||||
LinkedHashMap<String, LinkedHashMap<String, Double>> LHMSMX = new LinkedHashMap();
|
|
||||||
try (Connection l_cCon = DBCPDataSource.getConnection()) {
|
|
||||||
l_cCon.setAutoCommit(false);
|
|
||||||
String l_sSQL = "SELECT * FROM `WordMatrix`";
|
|
||||||
try (PreparedStatement l_pStatement = l_cCon.prepareStatement(l_sSQL, java.sql.ResultSet.TYPE_FORWARD_ONLY,
|
|
||||||
java.sql.ResultSet.CONCUR_READ_ONLY)) {
|
|
||||||
l_pStatement.setFetchSize(0);
|
|
||||||
try (ResultSet l_rsSearch = l_pStatement.executeQuery()) {
|
|
||||||
l_rsSearch.setFetchSize(0);
|
|
||||||
int i = 0;
|
|
||||||
LinkedHashMap<String, Double> LHMLocal = new LinkedHashMap();
|
|
||||||
while (l_rsSearch.next()) {
|
|
||||||
String str1 = l_rsSearch.getString(1);
|
|
||||||
String str2 = l_rsSearch.getString(2);
|
|
||||||
Double score = l_rsSearch.getDouble(3);
|
|
||||||
LHMLocal.put(str2, score);
|
|
||||||
while (l_rsSearch.next() && str1.equals(l_rsSearch.getString(1))) {
|
|
||||||
str2 = l_rsSearch.getString(2);
|
|
||||||
score = l_rsSearch.getDouble(3);
|
|
||||||
LHMLocal.put(str2, score);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
LHMSMX.put(str1, LHMLocal);
|
|
||||||
System.out.println("i: " + i + "\n" + "free memory: " + Runtime.getRuntime().freeMemory() + "\n");
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (SQLException ex) {
|
|
||||||
Logger.getLogger(DataMapper.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
return LHMSMX;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
public static ConcurrentMap<Integer, String> getHLstatsMessages() {
|
public static ConcurrentMap<Integer, String> getHLstatsMessages() {
|
||||||
ConcurrentMap<Integer, String> hlStatsMessages = new MapMaker().concurrencyLevel(2).makeMap();
|
ConcurrentMap<Integer, String> hlStatsMessages = new MapMaker().concurrencyLevel(2).makeMap();
|
||||||
try (Connection l_cCon = DBCPDataSourceHLstats.getConnection()) {
|
try (Connection l_cCon = DBCPDataSourceHLstats.getConnection()) {
|
||||||
|
@ -29,6 +29,7 @@ import java.util.Collection;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.ListIterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
@ -37,15 +38,19 @@ import java.util.concurrent.Callable;
|
|||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ForkJoinPool;
|
import java.util.concurrent.ForkJoinPool;
|
||||||
import java.util.concurrent.ForkJoinTask;
|
import java.util.concurrent.ForkJoinTask;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -62,19 +67,15 @@ public class Datahandler {
|
|||||||
private static Annotation strAnnoJMWE;
|
private static Annotation strAnnoJMWE;
|
||||||
private static CoreDocument coreDoc;
|
private static CoreDocument coreDoc;
|
||||||
private static final ConcurrentMap<Integer, String> stringCache = new MapMaker().concurrencyLevel(2).makeMap();
|
private static final ConcurrentMap<Integer, String> stringCache = new MapMaker().concurrencyLevel(2).makeMap();
|
||||||
private static int positiveRelationCounter = 0;
|
private static int RelationCounter = 0;
|
||||||
private static int negativeRelationCounter = 0;
|
|
||||||
private static ConcurrentMap<String, Annotation> pipelineAnnotationCache;
|
private static ConcurrentMap<String, Annotation> pipelineAnnotationCache;
|
||||||
private static ConcurrentMap<String, Annotation> pipelineSentimentAnnotationCache;
|
private static ConcurrentMap<String, Annotation> pipelineSentimentAnnotationCache;
|
||||||
private static ConcurrentMap<String, Annotation> jmweAnnotationCache;
|
private static ConcurrentMap<String, Annotation> jmweAnnotationCache;
|
||||||
private static ConcurrentMap<String, CoreDocument> coreDocumentAnnotationCache;
|
private static ConcurrentMap<String, CoreDocument> coreDocumentAnnotationCache;
|
||||||
private static ConcurrentMap<Integer, String> conversationMatchMap;
|
|
||||||
private static ConcurrentMap<String, Integer> conversationUserMatchMap;
|
private static ConcurrentMap<String, Integer> conversationUserMatchMap;
|
||||||
private static ConcurrentMap<String, SentimentValueCache> sentimentCachingMap = new MapMaker().concurrencyLevel(6).makeMap();
|
private static ConcurrentMap<String, SentimentValueCache> sentimentCachingMap = new MapMaker().concurrencyLevel(6).makeMap();
|
||||||
private static final ConcurrentMap<String, Integer> locateFaultySentences = new MapMaker().concurrencyLevel(6).makeMap();
|
|
||||||
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;
|
||||||
private static final ForkJoinPool executor = instantiateExecutor();
|
|
||||||
private static String similar = "";
|
private static String similar = "";
|
||||||
private static String shiftReduceParserPath = "edu/stanford/nlp/models/srparser/englishSR.ser.gz";
|
private static String shiftReduceParserPath = "edu/stanford/nlp/models/srparser/englishSR.ser.gz";
|
||||||
private static String sentimentModel = "edu/stanford/nlp/models/sentiment/sentiment.ser.gz";
|
private static String sentimentModel = "edu/stanford/nlp/models/sentiment/sentiment.ser.gz";
|
||||||
@ -102,7 +103,6 @@ public class Datahandler {
|
|||||||
this.pipelineAnnotationCache = new MapMaker().concurrencyLevel(4).makeMap();
|
this.pipelineAnnotationCache = new MapMaker().concurrencyLevel(4).makeMap();
|
||||||
this.pipelineSentimentAnnotationCache = new MapMaker().concurrencyLevel(4).makeMap();
|
this.pipelineSentimentAnnotationCache = new MapMaker().concurrencyLevel(4).makeMap();
|
||||||
this.coreDocumentAnnotationCache = new MapMaker().concurrencyLevel(5).makeMap();
|
this.coreDocumentAnnotationCache = new MapMaker().concurrencyLevel(5).makeMap();
|
||||||
this.conversationMatchMap = new MapMaker().concurrencyLevel(4).makeMap();
|
|
||||||
this.conversationUserMatchMap = new MapMaker().concurrencyLevel(4).makeMap();
|
this.conversationUserMatchMap = new MapMaker().concurrencyLevel(4).makeMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,13 +182,6 @@ public class Datahandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ForkJoinPool instantiateExecutor() {
|
|
||||||
//Runtime.getRuntime().availableProcessors() or static value like 25
|
|
||||||
return new ForkJoinPool(Runtime.getRuntime().availableProcessors(),
|
|
||||||
ForkJoinPool.defaultForkJoinWorkerThreadFactory,
|
|
||||||
null, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static GrammaticalStructureFactory getGsf() {
|
public static GrammaticalStructureFactory getGsf() {
|
||||||
return gsf;
|
return gsf;
|
||||||
}
|
}
|
||||||
@ -229,7 +222,7 @@ public class Datahandler {
|
|||||||
hlStatsMessages.put(str, hlStatsMessages.size());
|
hlStatsMessages.put(str, hlStatsMessages.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int capacity = 9550;
|
int capacity = 1500;
|
||||||
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);
|
||||||
@ -274,146 +267,115 @@ public class Datahandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ConcurrentMap<Integer, String> futuresReturnOverallEvaluation(ConcurrentMap<String, Future<SimilarityMatrix>> entries, String str,
|
private ConcurrentMap<Integer, String> futuresReturnOverallEvaluation(List<SimilarityMatrix> similarityMatrixes,
|
||||||
ConcurrentMap<Integer, String> strmapreturn) {
|
ConcurrentMap<Integer, String> strmapreturn) {
|
||||||
for (Entry<String, Future<SimilarityMatrix>> entrySet : entries.entrySet()) {
|
String newPrimary = similarityMatrixes.get(0).getPrimaryString();
|
||||||
String transmittedStr = entrySet.getKey();
|
int evaluationCap = 50000;
|
||||||
SimilarityMatrix getSMX = retrieveFutureSMX(entrySet.getValue());
|
boolean hitCap = false;
|
||||||
int handleRetrievedSMX = handleRetrievedSMX(getSMX, transmittedStr);
|
for (SimilarityMatrix SMX : similarityMatrixes) {
|
||||||
System.out.println("handleRetrievedSMX: " + handleRetrievedSMX + "\n");
|
if (!newPrimary.equals(SMX.getPrimaryString())) {
|
||||||
if (handleRetrievedSMX == 2) {
|
newPrimary = SMX.getPrimaryString();
|
||||||
strmapreturn.put(strmapreturn.size(), str);
|
strmapreturn = addSMXToMapReturn(strmapreturn, SMX);
|
||||||
break;
|
hitCap = false;
|
||||||
} else if (handleRetrievedSMX == 1) {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (getSMX != null) {
|
if (!hitCap) {
|
||||||
SentimentValueCache cacheValue1 = getSMX.getCacheValue1();
|
final Double scoreRelationNewMsgToRecentMsg = SMX.getDistance();
|
||||||
SentimentValueCache cacheValue2 = getSMX.getCacheValue2();
|
RelationCounter += scoreRelationNewMsgToRecentMsg > 0 ? scoreRelationNewMsgToRecentMsg * 2 : scoreRelationNewMsgToRecentMsg;
|
||||||
if (cacheValue1 != null && !sentimentCachingMap.keySet().contains(str)) {
|
if (RelationCounter > evaluationCap) {
|
||||||
sentimentCachingMap.put(str, getSMX.getCacheValue1());
|
strmapreturn = addSMXToMapReturn(strmapreturn, SMX);
|
||||||
}
|
hitCap = true;
|
||||||
if (cacheValue2 != null && !sentimentCachingMap.keySet().contains(transmittedStr)) {
|
} else if (RelationCounter < evaluationCap * -1) {
|
||||||
sentimentCachingMap.put(transmittedStr, getSMX.getCacheValue2());
|
addSMXToMapReturn(strmapreturn, SMX);
|
||||||
|
hitCap = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return strmapreturn;
|
return strmapreturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int handleRetrievedSMX(SimilarityMatrix getSMX, String transmittedStr) {
|
private ConcurrentMap<Integer, String> addSMXToMapReturn(ConcurrentMap<Integer, String> strmapreturn, SimilarityMatrix SMX) {
|
||||||
final int relationCap = 20;
|
System.out.println("RelationCounter cap: " + RelationCounter);
|
||||||
if (getSMX != null) {
|
boolean related = RelationCounter > 0;
|
||||||
//System.out.println("getSMX primary: " + getSMX.getPrimaryString() + "\ngetSMX secondary: " + getSMX.getSecondaryString() + "\n");
|
if (related) {
|
||||||
final Double scoreRelationNewMsgToRecentMsg = getSMX.getDistance();
|
strmapreturn.put(strmapreturn.size(), SMX.getPrimaryString());
|
||||||
//System.out.println("scoreRelationNewMsgToRecentMsg: " + scoreRelationNewMsgToRecentMsg + "\n");
|
String transmittedStr = SMX.getSecondaryString();
|
||||||
if (scoreRelationNewMsgToRecentMsg >= 200.0) {
|
SentimentValueCache cacheValue1 = SMX.getCacheValue1();
|
||||||
positiveRelationCounter++;
|
SentimentValueCache cacheValue2 = SMX.getCacheValue2();
|
||||||
if (positiveRelationCounter >= relationCap) {
|
if (cacheValue1 != null && !sentimentCachingMap.keySet().contains(SMX.getPrimaryString())) {
|
||||||
return 2;
|
sentimentCachingMap.put(SMX.getPrimaryString(), SMX.getCacheValue1());
|
||||||
}
|
|
||||||
} else if (scoreRelationNewMsgToRecentMsg <= -6000.0) {
|
|
||||||
negativeRelationCounter += 1;
|
|
||||||
}
|
}
|
||||||
} else {
|
if (cacheValue2 != null && !sentimentCachingMap.keySet().contains(transmittedStr)) {
|
||||||
Integer getCounts = locateFaultySentences.getOrDefault(transmittedStr, null);
|
sentimentCachingMap.put(transmittedStr, SMX.getCacheValue2());
|
||||||
if (getCounts == null) {
|
|
||||||
locateFaultySentences.put(transmittedStr, 0);
|
|
||||||
} else {
|
|
||||||
locateFaultySentences.put(transmittedStr, getCounts + 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (negativeRelationCounter >= relationCap) {
|
RelationCounter = 0;
|
||||||
return 1;
|
return strmapreturn;
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Entry<ConcurrentMap<String, Future<SimilarityMatrix>>, ConcurrentMap<Integer, String>> StrComparringNoSentenceRelationMap(
|
private List<SimilarityMatrix> StrComparringNoSentenceRelationMap(
|
||||||
ConcurrentMap<Integer, String> strCacheLocal, String str, ConcurrentMap<String, Annotation> localJMWEMap,
|
ConcurrentMap<Integer, String> strCacheLocal, String str, ConcurrentMap<String, Annotation> localJMWEMap,
|
||||||
ConcurrentMap<String, Annotation> localPipelineAnnotation, ConcurrentMap<String, Annotation> localPipelineSentimentAnnotation,
|
ConcurrentMap<String, Annotation> localPipelineAnnotation, ConcurrentMap<String, Annotation> localPipelineSentimentAnnotation,
|
||||||
ConcurrentMap<String, CoreDocument> localCoreDocumentMap) {
|
ConcurrentMap<String, CoreDocument> localCoreDocumentMap) {
|
||||||
final ConcurrentMap<String, Future<SimilarityMatrix>> futures = new MapMaker().concurrencyLevel(4).makeMap();
|
|
||||||
strCacheLocal.values().removeIf(e -> {
|
|
||||||
Integer getFaultyOccurences = locateFaultySentences.getOrDefault(e, null);
|
|
||||||
if (getFaultyOccurences == null || getFaultyOccurences <= 20) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
SentimentValueCache sentimentCacheStr = sentimentCachingMap.getOrDefault(str, null);
|
SentimentValueCache sentimentCacheStr = sentimentCachingMap.getOrDefault(str, null);
|
||||||
|
List<SimilarityMatrix> smxReturnList = new ArrayList();
|
||||||
|
ExecutorService smxService = Executors.newFixedThreadPool(6);
|
||||||
for (String str1 : strCacheLocal.values()) {
|
for (String str1 : strCacheLocal.values()) {
|
||||||
//experimental change
|
if (!str.equals(str1)) {
|
||||||
if (!str.equals(str1) && !futures.keySet().contains(str1)) {
|
SimilarityMatrix SMXInit = new SimilarityMatrix(str, str1);
|
||||||
final SimilarityMatrix SMX = new SimilarityMatrix(str, str1);
|
|
||||||
SentimentValueCache sentimentCacheStr1 = sentimentCachingMap.getOrDefault(str1, null);
|
SentimentValueCache sentimentCacheStr1 = sentimentCachingMap.getOrDefault(str1, null);
|
||||||
final Callable<SimilarityMatrix> worker;
|
Callable<SimilarityMatrix> worker;
|
||||||
if (stringCache.size() < 150) {
|
if (stringCache.size() < 150) {
|
||||||
worker = new SentimentAnalyzerTest(str, str1, SMX,
|
worker = new SentimentAnalyzerTest(str, str1, SMXInit,
|
||||||
localJMWEMap.get(str), localJMWEMap.get(str1), localPipelineAnnotation.get(str),
|
localJMWEMap.get(str), localJMWEMap.get(str1), localPipelineAnnotation.get(str),
|
||||||
localPipelineAnnotation.get(str1), localPipelineSentimentAnnotation.get(str),
|
localPipelineAnnotation.get(str1), localPipelineSentimentAnnotation.get(str),
|
||||||
localPipelineSentimentAnnotation.get(str1), localCoreDocumentMap.get(str), localCoreDocumentMap.get(str1), sentimentCacheStr, sentimentCacheStr1);
|
localPipelineSentimentAnnotation.get(str1), localCoreDocumentMap.get(str), localCoreDocumentMap.get(str1), sentimentCacheStr, sentimentCacheStr1);
|
||||||
} else {
|
} else {
|
||||||
worker = new SentimentAnalyzerTest(str, str1, SMX,
|
worker = new SentimentAnalyzerTest(str, str1, SMXInit,
|
||||||
localJMWEMap.get(str), jmweAnnotationCache.get(str1), localPipelineAnnotation.get(str),
|
localJMWEMap.get(str), jmweAnnotationCache.get(str1), localPipelineAnnotation.get(str),
|
||||||
pipelineAnnotationCache.get(str1), localPipelineSentimentAnnotation.get(str),
|
pipelineAnnotationCache.get(str1), localPipelineSentimentAnnotation.get(str),
|
||||||
pipelineSentimentAnnotationCache.get(str1), localCoreDocumentMap.get(str), coreDocumentAnnotationCache.get(str1), sentimentCacheStr, sentimentCacheStr1);
|
pipelineSentimentAnnotationCache.get(str1), localCoreDocumentMap.get(str), coreDocumentAnnotationCache.get(str1), sentimentCacheStr, sentimentCacheStr1);
|
||||||
}
|
}
|
||||||
futures.put(str1, executor.submit(worker));
|
Future<SimilarityMatrix> future = smxService.submit(worker);
|
||||||
|
try {
|
||||||
|
SimilarityMatrix SMX = future.get();
|
||||||
|
if (SMX != null) {
|
||||||
|
smxReturnList.add(SMX);
|
||||||
|
}
|
||||||
|
} catch (InterruptedException | ExecutionException ex) {
|
||||||
|
//System.out.println("failed future get");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Map.Entry<ConcurrentMap<String, Future<SimilarityMatrix>>, ConcurrentMap<Integer, String>> mapreturn
|
return smxReturnList;
|
||||||
= new AbstractMap.SimpleEntry(futures, strCacheLocal);
|
|
||||||
return mapreturn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ConcurrentMap<Integer, String> stringIteratorComparator(ConcurrentMap<Integer, String> strmap,
|
private ConcurrentMap<Integer, String> stringIteratorComparator(ConcurrentMap<Integer, String> strmap,
|
||||||
ConcurrentMap<Integer, String> strCacheLocal, ConcurrentMap<String, Annotation> localJMWEMap,
|
ConcurrentMap<Integer, String> strCacheLocal, ConcurrentMap<String, Annotation> localJMWEMap,
|
||||||
ConcurrentMap<String, Annotation> localPipelineAnnotation, ConcurrentMap<String, Annotation> localPipelineSentimentAnnotation,
|
ConcurrentMap<String, Annotation> localPipelineAnnotation, ConcurrentMap<String, Annotation> localPipelineSentimentAnnotation,
|
||||||
ConcurrentMap<String, CoreDocument> localCoreDocumentMap) {
|
ConcurrentMap<String, CoreDocument> localCoreDocumentMap) {
|
||||||
int i = 0;
|
ConcurrentMap<Integer, String> strmapreturn = new MapMaker().concurrencyLevel(6).makeMap();
|
||||||
ConcurrentMap<Integer, String> strmapreturn = new MapMaker().concurrencyLevel(4).makeMap();
|
List<SimilarityMatrix> strSenseRelationMap = new ArrayList();
|
||||||
for (String str : strmap.values()) {
|
for (String str : strmap.values()) {
|
||||||
Integer getFaultyOccurences = locateFaultySentences.getOrDefault(str, null);
|
List<SimilarityMatrix> localNoSentenceRelationList = StrComparringNoSentenceRelationMap(strCacheLocal, str,
|
||||||
if (getFaultyOccurences == null || getFaultyOccurences <= 20) {
|
localJMWEMap, localPipelineAnnotation, localPipelineSentimentAnnotation, localCoreDocumentMap);
|
||||||
positiveRelationCounter = 0;
|
for (SimilarityMatrix SMX : localNoSentenceRelationList) {
|
||||||
negativeRelationCounter = 0;
|
strSenseRelationMap.add(SMX);
|
||||||
Entry<ConcurrentMap<String, Future<SimilarityMatrix>>, ConcurrentMap<Integer, String>> strRelationMap
|
|
||||||
= StrComparringNoSentenceRelationMap(strCacheLocal, str, localJMWEMap, localPipelineAnnotation, localPipelineSentimentAnnotation,
|
|
||||||
localCoreDocumentMap);
|
|
||||||
strCacheLocal = strRelationMap.getValue();
|
|
||||||
final ConcurrentMap<String, Future<SimilarityMatrix>> futures = strRelationMap.getKey();
|
|
||||||
strmapreturn = futuresReturnOverallEvaluation(futures, str, strmapreturn);
|
|
||||||
System.out.println("overall advancement of future iterator: " + i + "\nFullMapsize: " + strmap.values().size()
|
|
||||||
+ "\nstrmapreturn size: " + strmapreturn.size() + "\nlocateFaultySentences size: " + locateFaultySentences.size() + "\n");
|
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Collections.sort(strSenseRelationMap, (e1, e2) -> e1.getPrimaryString().compareTo(e2.getPrimaryString()));
|
||||||
|
strmapreturn = futuresReturnOverallEvaluation(strSenseRelationMap, strmapreturn);
|
||||||
return strmapreturn;
|
return strmapreturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final 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.size() < 150 ? strmap : 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());
|
||||||
final ConcurrentMap<String, CoreDocument> localCoreDocumentMap = getMultipleCoreDocumentsWaySuggestion(strmap.values(), pipeline);
|
final ConcurrentMap<String, CoreDocument> localCoreDocumentMap = getMultipleCoreDocumentsWaySuggestion(strmap.values(), pipeline);
|
||||||
System.out.println("finished removeNonSensicalStrings annotations \n");
|
|
||||||
return stringIteratorComparator(strmap, strCacheLocal, localJMWEMap, localPipelineAnnotation, localPipelineSentimentAnnotation, localCoreDocumentMap);
|
return stringIteratorComparator(strmap, strCacheLocal, localJMWEMap, localPipelineAnnotation, localPipelineSentimentAnnotation, localCoreDocumentMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SimilarityMatrix retrieveFutureSMX(Future<SimilarityMatrix> future) {
|
|
||||||
try {
|
|
||||||
// SimilarityMatrix SMX = future.get();
|
|
||||||
SimilarityMatrix SMX = future.get(5, TimeUnit.SECONDS);
|
|
||||||
return SMX;
|
|
||||||
} catch (InterruptedException | ExecutionException | TimeoutException ex) {
|
|
||||||
Logger.getLogger(Datahandler.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
System.out.println("retrieveFutureSMX timeout Exception; " + ex.getLocalizedMessage() + "\n");
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void checkIfUpdateStrings(boolean hlStatsMsg) throws CustomError {
|
public synchronized void checkIfUpdateStrings(boolean hlStatsMsg) 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();
|
||||||
@ -422,7 +384,6 @@ public class Datahandler {
|
|||||||
str = removeSlacks(str);
|
str = removeSlacks(str);
|
||||||
System.out.println("finished removeSlacks \n" + str.size() + "\n");
|
System.out.println("finished removeSlacks \n" + str.size() + "\n");
|
||||||
str = removeNonSensicalStrings(str);
|
str = removeNonSensicalStrings(str);
|
||||||
System.out.println("POST removeNonSensicalStrings size: " + 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;
|
||||||
@ -461,7 +422,7 @@ public class Datahandler {
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getResponseFutures(String strF) {
|
private String getResponseFutures(String strF, ConcurrentMap<String, Integer> mostRecentMsgMap) {
|
||||||
ConcurrentMap<Integer, String> strCache = stringCache;
|
ConcurrentMap<Integer, String> strCache = stringCache;
|
||||||
double preRelationUserCounters = -6500.0;
|
double preRelationUserCounters = -6500.0;
|
||||||
//WHY THE FUCK CANT YOU JUST TRANSFER A SimilarityMatrix OBJECT LIST LIKE ANY OTHER NORMAL COLLECTION, WHY DOES IT HAVE TO BE A FUCKING STRING LIST
|
//WHY THE FUCK CANT YOU JUST TRANSFER A SimilarityMatrix OBJECT LIST LIKE ANY OTHER NORMAL COLLECTION, WHY DOES IT HAVE TO BE A FUCKING STRING LIST
|
||||||
@ -475,9 +436,17 @@ public class Datahandler {
|
|||||||
pipelineSentimentAnnotationCache.get(str1), coreDoc, coreDocumentAnnotationCache.get(str1), null, sentimentCacheStr1);
|
pipelineSentimentAnnotationCache.get(str1), coreDoc, coreDocumentAnnotationCache.get(str1), null, sentimentCacheStr1);
|
||||||
try {
|
try {
|
||||||
SimilarityMatrix getSMX = worker.call();
|
SimilarityMatrix getSMX = worker.call();
|
||||||
//SimilarityMatrix getSMX = executor.submit(worker).get(5, TimeUnit.SECONDS);
|
|
||||||
if (getSMX != null) {
|
if (getSMX != null) {
|
||||||
|
Integer repeatedSentences = mostRecentMsgMap.getOrDefault(getSMX.getSecondaryString(), null);
|
||||||
Double scoreRelationLastUserMsg = getSMX.getDistance();
|
Double scoreRelationLastUserMsg = getSMX.getDistance();
|
||||||
|
/*
|
||||||
|
double oldRelation = overAllOldScoreRelations(getSMX.getSecondaryString());
|
||||||
|
if (oldRelation < 0 && conversationUserMatchMap.size() > 1) {
|
||||||
|
conversationUserMatchMap.clear();
|
||||||
|
} else if (oldRelation > 0) {
|
||||||
|
scoreRelationLastUserMsg += oldRelation;
|
||||||
|
}
|
||||||
|
*/
|
||||||
if (scoreRelationLastUserMsg > preRelationUserCounters) {
|
if (scoreRelationLastUserMsg > preRelationUserCounters) {
|
||||||
preRelationUserCounters = scoreRelationLastUserMsg;
|
preRelationUserCounters = scoreRelationLastUserMsg;
|
||||||
concurrentRelations.add(getSMX.getSecondaryString());
|
concurrentRelations.add(getSMX.getSecondaryString());
|
||||||
@ -493,7 +462,7 @@ public class Datahandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
StringBuilder SB = new StringBuilder();
|
StringBuilder SB = new StringBuilder();
|
||||||
double randomLenghtPermit = strF.length() * (Math.random() * 5.5);
|
double randomLenghtPermit = strF.length() * (Math.random() * 1.5);
|
||||||
Collections.reverse(concurrentRelations);
|
Collections.reverse(concurrentRelations);
|
||||||
for (String secondaryRelation : concurrentRelations) {
|
for (String secondaryRelation : concurrentRelations) {
|
||||||
if (SB.toString().length() > randomLenghtPermit && !SB.toString().isEmpty()) {
|
if (SB.toString().length() > randomLenghtPermit && !SB.toString().isEmpty()) {
|
||||||
@ -506,41 +475,23 @@ public class Datahandler {
|
|||||||
return SB.toString();
|
return SB.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private double setupScoreRelationtoRecent(String strF, ConcurrentMap<String, Double> getPrimaryLocal) {
|
private double overAllOldScoreRelations(String strF) {
|
||||||
double scoreRelationNewMsgToRecentMsg = 0.0;
|
|
||||||
for (String conversationStr : conversationMatchMap.values()) {
|
|
||||||
Double getSecondary = 0.0;
|
|
||||||
getSecondary = getPrimaryLocal.get(conversationStr);
|
|
||||||
if (getSecondary == null) {
|
|
||||||
getSecondary = getScoreRelationStrF(strF, conversationStr);
|
|
||||||
}
|
|
||||||
scoreRelationNewMsgToRecentMsg += getSecondary;
|
|
||||||
System.out.println("scoreRelationNewMsgToRecentMsg: " + scoreRelationNewMsgToRecentMsg + "\n");
|
|
||||||
}
|
|
||||||
return scoreRelationNewMsgToRecentMsg;
|
|
||||||
}
|
|
||||||
|
|
||||||
private double setupScoreRelationOld(String strF, ConcurrentMap<String, Double> getPrimaryLocal) {
|
|
||||||
double scoreRelationOldUserMsg = 0.0;
|
|
||||||
for (String conversationUserStr : conversationUserMatchMap.keySet()) {
|
|
||||||
if (!strF.equals(conversationUserStr)) {
|
|
||||||
double getSecondary = getScoreRelationStrF(strF, conversationUserStr);
|
|
||||||
scoreRelationOldUserMsg += getSecondary;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return scoreRelationOldUserMsg;
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized String getResponseMsg(String str, String MostRecent) throws CustomError {
|
|
||||||
String strF = trimString(str);
|
|
||||||
getSingularAnnotation(strF);
|
|
||||||
if (!conversationMatchMap.values().contains(MostRecent) && !MostRecent.isEmpty()) {
|
|
||||||
conversationMatchMap.put(conversationMatchMap.size(), MostRecent);
|
|
||||||
}
|
|
||||||
if (!conversationUserMatchMap.keySet().contains(strF)) {
|
if (!conversationUserMatchMap.keySet().contains(strF)) {
|
||||||
conversationUserMatchMap.put(strF, conversationUserMatchMap.size());
|
conversationUserMatchMap.put(strF, conversationUserMatchMap.size());
|
||||||
}
|
}
|
||||||
return getResponseFutures(strF);
|
double sentenceContinuity = -500.0;
|
||||||
|
for (String conversationUserStr : conversationUserMatchMap.keySet()) {
|
||||||
|
if (!strF.equals(conversationUserStr)) {
|
||||||
|
sentenceContinuity += getScoreRelationStrF(strF, conversationUserStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sentenceContinuity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized String getResponseMsg(String str, ConcurrentMap<String, Integer> mostRecentMsgMap) throws CustomError {
|
||||||
|
String strF = trimString(str);
|
||||||
|
getSingularAnnotation(strF);
|
||||||
|
return getResponseFutures(strF, mostRecentMsgMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getSingularAnnotation(String str) {
|
public void getSingularAnnotation(String str) {
|
||||||
@ -767,7 +718,7 @@ public class Datahandler {
|
|||||||
}
|
}
|
||||||
if (!tooclosematch) {
|
if (!tooclosematch) {
|
||||||
strreturn.put(strreturn.size() + 1, str1);
|
strreturn.put(strreturn.size() + 1, str1);
|
||||||
System.out.println("adding strreturn str1: " + str1 + "\n");
|
//System.out.println("adding strreturn str1: " + str1 + "\n");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return strreturn;
|
return strreturn;
|
||||||
@ -814,42 +765,35 @@ public class Datahandler {
|
|||||||
private static class AnnotationCollector<T> implements Consumer<T> {
|
private static class AnnotationCollector<T> implements Consumer<T> {
|
||||||
|
|
||||||
private static int i = 0;
|
private static int i = 0;
|
||||||
private final List<T> annotationsT = new ArrayList();
|
private List<T> annotationsT = new ArrayList();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void accept(T ann) {
|
public void accept(T ann) {
|
||||||
|
//System.out.println("adding ann: " + ann.toString());
|
||||||
annotationsT.add(ann);
|
annotationsT.add(ann);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ConcurrentMap<String, CoreDocument> getMultipleCoreDocumentsWaySuggestion(Collection<String> str, StanfordCoreNLP localNLP) {
|
public static ConcurrentMap<String, CoreDocument> getMultipleCoreDocumentsWaySuggestion(Collection<String> str, StanfordCoreNLP localNLP) {
|
||||||
AnnotationCollector<Annotation> annCollector = new AnnotationCollector();
|
AnnotationCollector<Annotation> annCollector = new AnnotationCollector();
|
||||||
System.out.println("processing multiple coreDocuments Annotation: \n");
|
|
||||||
for (final String exampleString : str) {
|
for (final String exampleString : str) {
|
||||||
//System.out.println("exampleString: " + exampleString + "\n");
|
// System.out.println("exampleString: " + exampleString + "\n");
|
||||||
localNLP.annotate(new Annotation(exampleString), annCollector);
|
localNLP.annotate(new Annotation(exampleString), annCollector);
|
||||||
annCollector.i++;
|
annCollector.i++;
|
||||||
//System.out.println("iterator: " + annCollector.i + "\nstr size: " + str.size() + "\n");
|
// System.out.println("iterator: " + annCollector.i + "\nstr size: " + str.size() + "\n");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Thread.sleep(10000);
|
Thread.sleep(4000);
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
Logger.getLogger(Datahandler.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(Datahandler.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
ConcurrentMap<String, CoreDocument> annotationreturnMap = new MapMaker().concurrencyLevel(2).makeMap();
|
ConcurrentMap<String, CoreDocument> annotationreturnMap = new MapMaker().concurrencyLevel(6).makeMap();
|
||||||
List<CoreDocument> coreDocs = annCollector.annotationsT.stream().map(ann -> {
|
for (Annotation ann : annCollector.annotationsT) {
|
||||||
try {
|
if (ann != null) {
|
||||||
return new CoreDocument(ann);
|
CoreDocument CD = new CoreDocument(ann);
|
||||||
} catch (Exception ex) {
|
|
||||||
System.out.println(ex.getLocalizedMessage());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
coreDocs.stream().forEach(CD -> {
|
|
||||||
if (CD != null) {
|
|
||||||
annotationreturnMap.put(CD.text(), CD);
|
annotationreturnMap.put(CD.text(), CD);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
return annotationreturnMap;
|
return annotationreturnMap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,8 @@ public class MessageResponseHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized static String selectReponseMessage(String toString, String mostRecentMsg, String personName) throws CustomError {
|
public synchronized static String selectReponseMessage(String toString, ConcurrentMap<String, Integer> mostRecentMsgMap,
|
||||||
|
String personName) throws CustomError {
|
||||||
ConcurrentMap<Integer, String> str1 = new MapMaker().concurrencyLevel(2).makeMap();
|
ConcurrentMap<Integer, String> str1 = new MapMaker().concurrencyLevel(2).makeMap();
|
||||||
str1.put(str1.size() + 1, toString);
|
str1.put(str1.size() + 1, toString);
|
||||||
str1 = Datahandler.cutContent(str1, false);
|
str1 = Datahandler.cutContent(str1, false);
|
||||||
@ -51,7 +52,7 @@ public class MessageResponseHandler {
|
|||||||
strreturn = str;
|
strreturn = str;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String getResponseMsg = Datahandler.instance.getResponseMsg(strreturn, mostRecentMsg);
|
String getResponseMsg = Datahandler.instance.getResponseMsg(strreturn, mostRecentMsgMap);
|
||||||
getResponseMsg = checkPersonPresentInSentence(personName, getResponseMsg, strreturn);
|
getResponseMsg = checkPersonPresentInSentence(personName, getResponseMsg, strreturn);
|
||||||
return getResponseMsg;
|
return getResponseMsg;
|
||||||
}
|
}
|
||||||
|
@ -13,19 +13,11 @@ import FunctionLayer.StanfordParser.SentimentValueCache;
|
|||||||
*/
|
*/
|
||||||
public class SimilarityMatrix {
|
public class SimilarityMatrix {
|
||||||
|
|
||||||
private static String PrimaryString;
|
private String PrimaryString;
|
||||||
private static String SecondaryString;
|
private String SecondaryString;
|
||||||
private static double distance;
|
private double distance;
|
||||||
private static SentimentValueCache cacheValue1;
|
private SentimentValueCache cacheValue1;
|
||||||
private static SentimentValueCache cacheValue2;
|
private SentimentValueCache cacheValue2;
|
||||||
|
|
||||||
public final SentimentValueCache getCacheValue2() {
|
|
||||||
return cacheValue2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void setCacheValue2(SentimentValueCache cacheValue2) {
|
|
||||||
SimilarityMatrix.cacheValue2 = cacheValue2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final double getDistance() {
|
public final double getDistance() {
|
||||||
return distance;
|
return distance;
|
||||||
@ -70,4 +62,12 @@ public class SimilarityMatrix {
|
|||||||
this.cacheValue1 = cacheValue1;
|
this.cacheValue1 = cacheValue1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final SentimentValueCache getCacheValue2() {
|
||||||
|
return cacheValue2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void setCacheValue2(SentimentValueCache cacheValue2) {
|
||||||
|
this.cacheValue2 = cacheValue2;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -21,11 +21,11 @@ import org.ejml.simple.SimpleMatrix;
|
|||||||
*
|
*
|
||||||
* @author install1
|
* @author install1
|
||||||
*/
|
*/
|
||||||
public final class SentimentValueCache {
|
public class SentimentValueCache {
|
||||||
|
|
||||||
private final String sentence;
|
private String sentence;
|
||||||
private static int counter;
|
private int counter;
|
||||||
private static List<List<TaggedWord>> taggedwordlist = new ArrayList();
|
private List<List<TaggedWord>> taggedwordlist = new ArrayList();
|
||||||
private final ConcurrentMap<Integer, String> tgwlistIndex = new MapMaker().concurrencyLevel(2).makeMap();
|
private final ConcurrentMap<Integer, String> tgwlistIndex = new MapMaker().concurrencyLevel(2).makeMap();
|
||||||
private final ConcurrentMap<Integer, Tree> sentenceConstituencyParseList = new MapMaker().concurrencyLevel(2).makeMap();
|
private final ConcurrentMap<Integer, Tree> sentenceConstituencyParseList = new MapMaker().concurrencyLevel(2).makeMap();
|
||||||
private final Collection<TypedDependency> allTypedDependencies = new ArrayList();
|
private final Collection<TypedDependency> allTypedDependencies = new ArrayList();
|
||||||
@ -33,17 +33,17 @@ public final class SentimentValueCache {
|
|||||||
private final ConcurrentMap<Integer, SimpleMatrix> simpleSMXlist = new MapMaker().concurrencyLevel(3).makeMap();
|
private final ConcurrentMap<Integer, SimpleMatrix> simpleSMXlist = new MapMaker().concurrencyLevel(3).makeMap();
|
||||||
private final ConcurrentMap<Integer, SimpleMatrix> simpleSMXlistVector = new MapMaker().concurrencyLevel(3).makeMap();
|
private final ConcurrentMap<Integer, SimpleMatrix> simpleSMXlistVector = new MapMaker().concurrencyLevel(3).makeMap();
|
||||||
private final ConcurrentMap<Integer, Integer> rnnPredictClassMap = new MapMaker().concurrencyLevel(3).makeMap();
|
private final ConcurrentMap<Integer, Integer> rnnPredictClassMap = new MapMaker().concurrencyLevel(3).makeMap();
|
||||||
private static List classifyRaw;
|
private List classifyRaw;
|
||||||
private static int mainSentiment = 0;
|
private int mainSentiment = 0;
|
||||||
private static int longest = 0;
|
private int longest = 0;
|
||||||
private static int tokensCounter = 0;
|
private int tokensCounter = 0;
|
||||||
private static int anotatorcounter = 0;
|
private int anotatorcounter = 0;
|
||||||
private static int inflectedCounterPositive = 0;
|
private int inflectedCounterPositive = 0;
|
||||||
private static int inflectedCounterNegative = 0;
|
private int inflectedCounterNegative = 0;
|
||||||
private static int MarkedContinuousCounter = 0;
|
private int MarkedContinuousCounter = 0;
|
||||||
private static int MarkedContiniousCounterEntries = 0;
|
private int MarkedContiniousCounterEntries = 0;
|
||||||
private static int UnmarkedPatternCounter = 0;
|
private int UnmarkedPatternCounter = 0;
|
||||||
private static int pairCounter = 0;
|
private int pairCounter = 0;
|
||||||
private final ConcurrentMap<Integer, String> ITokenMapTag = new MapMaker().concurrencyLevel(2).makeMap();
|
private final ConcurrentMap<Integer, String> ITokenMapTag = new MapMaker().concurrencyLevel(2).makeMap();
|
||||||
private final ConcurrentMap<Integer, String> strTokenStems = new MapMaker().concurrencyLevel(2).makeMap();
|
private final ConcurrentMap<Integer, String> strTokenStems = new MapMaker().concurrencyLevel(2).makeMap();
|
||||||
private final ConcurrentMap<Integer, String> strTokenForm = new MapMaker().concurrencyLevel(2).makeMap();
|
private final ConcurrentMap<Integer, String> strTokenForm = new MapMaker().concurrencyLevel(2).makeMap();
|
||||||
@ -57,261 +57,261 @@ public final class SentimentValueCache {
|
|||||||
private final ConcurrentMap<Integer, String> stopwordTokens = new MapMaker().concurrencyLevel(2).makeMap();
|
private final ConcurrentMap<Integer, String> stopwordTokens = new MapMaker().concurrencyLevel(2).makeMap();
|
||||||
private final ConcurrentMap<Integer, String> stopWordLemma = new MapMaker().concurrencyLevel(2).makeMap();
|
private final ConcurrentMap<Integer, String> stopWordLemma = new MapMaker().concurrencyLevel(2).makeMap();
|
||||||
|
|
||||||
public final int getPairCounter() {
|
public int getPairCounter() {
|
||||||
return pairCounter;
|
return pairCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setPairCounter(int pairCounter) {
|
public void setPairCounter(int pairCounter) {
|
||||||
SentimentValueCache.pairCounter = pairCounter;
|
this.pairCounter = pairCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void addStopWordLemma(String str) {
|
public void addStopWordLemma(String str) {
|
||||||
stopWordLemma.put(stopWordLemma.size(), str);
|
stopWordLemma.put(stopWordLemma.size(), str);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void addstopwordTokens(String str) {
|
public void addstopwordTokens(String str) {
|
||||||
stopwordTokens.put(stopwordTokens.size(), str);
|
stopwordTokens.put(stopwordTokens.size(), str);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final ConcurrentMap<Integer, String> getStopwordTokens() {
|
public ConcurrentMap<Integer, String> getStopwordTokens() {
|
||||||
return stopwordTokens;
|
return stopwordTokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final ConcurrentMap<Integer, String> getStopWordLemma() {
|
public ConcurrentMap<Integer, String> getStopWordLemma() {
|
||||||
return stopWordLemma;
|
return stopWordLemma;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void addnerEntityTokenTags(String str) {
|
public void addnerEntityTokenTags(String str) {
|
||||||
nerEntityTokenTags.put(nerEntityTokenTags.size(), str);
|
nerEntityTokenTags.put(nerEntityTokenTags.size(), str);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final ConcurrentMap<Integer, String> getnerEntityTokenTags() {
|
public ConcurrentMap<Integer, String> getnerEntityTokenTags() {
|
||||||
return nerEntityTokenTags;
|
return nerEntityTokenTags;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final ConcurrentMap<Integer, String> getnerEntities1() {
|
public ConcurrentMap<Integer, String> getnerEntities1() {
|
||||||
return nerEntities1;
|
return nerEntities1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final ConcurrentMap<Integer, String> getnerEntities2() {
|
public ConcurrentMap<Integer, String> getnerEntities2() {
|
||||||
return nerEntities2;
|
return nerEntities2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void addNEREntities1(String str) {
|
public void addNEREntities1(String str) {
|
||||||
nerEntities1.put(nerEntities1.size(), str);
|
nerEntities1.put(nerEntities1.size(), str);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void addNEREntities2(String str) {
|
public void addNEREntities2(String str) {
|
||||||
nerEntities2.put(nerEntities2.size(), str);
|
nerEntities2.put(nerEntities2.size(), str);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setTaggedwords(List<List<TaggedWord>> twlist) {
|
public void setTaggedwords(List<List<TaggedWord>> twlist) {
|
||||||
taggedwordlist = twlist;
|
taggedwordlist = twlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final List<List<TaggedWord>> getTaggedwordlist() {
|
public List<List<TaggedWord>> getTaggedwordlist() {
|
||||||
return taggedwordlist;
|
return taggedwordlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void addEntryCounts(int counts) {
|
public void addEntryCounts(int counts) {
|
||||||
entryCounts.put(entryCounts.size(), counts);
|
entryCounts.put(entryCounts.size(), counts);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final ConcurrentMap<Integer, Integer> getEntryCounts() {
|
public ConcurrentMap<Integer, Integer> getEntryCounts() {
|
||||||
return entryCounts;
|
return entryCounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void addstrTokenEntryPOS(String str) {
|
public void addstrTokenEntryPOS(String str) {
|
||||||
strTokenEntryPOS.put(strTokenEntryPOS.size(), str);
|
strTokenEntryPOS.put(strTokenEntryPOS.size(), str);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final ConcurrentMap<Integer, String> getstrTokenEntryPOS() {
|
public ConcurrentMap<Integer, String> getstrTokenEntryPOS() {
|
||||||
return strTokenEntryPOS;
|
return strTokenEntryPOS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void addstrTokenGetiPart(String str) {
|
public void addstrTokenGetiPart(String str) {
|
||||||
strTokenGetiPart.put(strTokenGetiPart.size(), str);
|
strTokenGetiPart.put(strTokenGetiPart.size(), str);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final ConcurrentMap<Integer, String> getstrTokenGetiPart() {
|
public ConcurrentMap<Integer, String> getstrTokenGetiPart() {
|
||||||
return strTokenGetiPart;
|
return strTokenGetiPart;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final ConcurrentMap<Integer, String> getstrTokenGetEntry() {
|
public ConcurrentMap<Integer, String> getstrTokenGetEntry() {
|
||||||
return strTokenGetEntry;
|
return strTokenGetEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void addstrTokenGetEntry(String str) {
|
public void addstrTokenGetEntry(String str) {
|
||||||
strTokenGetEntry.put(strTokenGetEntry.size(), str);
|
strTokenGetEntry.put(strTokenGetEntry.size(), str);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final ConcurrentMap<Integer, String> getstrTokenForm() {
|
public ConcurrentMap<Integer, String> getstrTokenForm() {
|
||||||
return strTokenForm;
|
return strTokenForm;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void addstrTokenForm(String str) {
|
public void addstrTokenForm(String str) {
|
||||||
strTokenForm.put(strTokenForm.size(), str);
|
strTokenForm.put(strTokenForm.size(), str);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final ConcurrentMap<Integer, String> getstrTokenStems() {
|
public ConcurrentMap<Integer, String> getstrTokenStems() {
|
||||||
return strTokenStems;
|
return strTokenStems;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void addstrTokenStems(String str) {
|
public void addstrTokenStems(String str) {
|
||||||
strTokenStems.put(strTokenStems.size(), str);
|
strTokenStems.put(strTokenStems.size(), str);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final ConcurrentMap<Integer, String> getITokenMapTag() {
|
public ConcurrentMap<Integer, String> getITokenMapTag() {
|
||||||
return ITokenMapTag;
|
return ITokenMapTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void addITokenMapTag(String str) {
|
public void addITokenMapTag(String str) {
|
||||||
ITokenMapTag.put(ITokenMapTag.size(), str);
|
ITokenMapTag.put(ITokenMapTag.size(), str);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int getUnmarkedPatternCounter() {
|
public int getUnmarkedPatternCounter() {
|
||||||
return UnmarkedPatternCounter;
|
return UnmarkedPatternCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setUnmarkedPatternCounter(int UnmarkedPatternCounter) {
|
public void setUnmarkedPatternCounter(int UnmarkedPatternCounter) {
|
||||||
SentimentValueCache.UnmarkedPatternCounter = UnmarkedPatternCounter;
|
this.UnmarkedPatternCounter = UnmarkedPatternCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int getMarkedContiniousCounterEntries() {
|
public int getMarkedContiniousCounterEntries() {
|
||||||
return MarkedContiniousCounterEntries;
|
return MarkedContiniousCounterEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setMarkedContiniousCounterEntries(int MarkedContiniousCounterEntries) {
|
public void setMarkedContiniousCounterEntries(int MarkedContiniousCounterEntries) {
|
||||||
SentimentValueCache.MarkedContiniousCounterEntries = MarkedContiniousCounterEntries;
|
this.MarkedContiniousCounterEntries = MarkedContiniousCounterEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int getMarkedContinuousCounter() {
|
public int getMarkedContinuousCounter() {
|
||||||
return MarkedContinuousCounter;
|
return MarkedContinuousCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setMarkedContinuousCounter(int MarkedContinuousCounter) {
|
public void setMarkedContinuousCounter(int MarkedContinuousCounter) {
|
||||||
SentimentValueCache.MarkedContinuousCounter = MarkedContinuousCounter;
|
this.MarkedContinuousCounter = MarkedContinuousCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int getInflectedCounterNegative() {
|
public int getInflectedCounterNegative() {
|
||||||
return inflectedCounterNegative;
|
return inflectedCounterNegative;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setInflectedCounterNegative(int inflectedCounterNegative) {
|
public void setInflectedCounterNegative(int inflectedCounterNegative) {
|
||||||
SentimentValueCache.inflectedCounterNegative = inflectedCounterNegative;
|
this.inflectedCounterNegative = inflectedCounterNegative;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int getInflectedCounterPositive() {
|
public int getInflectedCounterPositive() {
|
||||||
return inflectedCounterPositive;
|
return inflectedCounterPositive;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setInflectedCounterPositive(int inflectedCounterPositive) {
|
public void setInflectedCounterPositive(int inflectedCounterPositive) {
|
||||||
SentimentValueCache.inflectedCounterPositive = inflectedCounterPositive;
|
this.inflectedCounterPositive = inflectedCounterPositive;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int getAnotatorcounter() {
|
public int getAnotatorcounter() {
|
||||||
return anotatorcounter;
|
return anotatorcounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setAnotatorcounter(int anotatorcounter) {
|
public void setAnotatorcounter(int anotatorcounter) {
|
||||||
SentimentValueCache.anotatorcounter = anotatorcounter;
|
this.anotatorcounter = anotatorcounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int getTokensCounter() {
|
public int getTokensCounter() {
|
||||||
return tokensCounter;
|
return tokensCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setTokensCounter(int tokensCounter) {
|
public void setTokensCounter(int tokensCounter) {
|
||||||
SentimentValueCache.tokensCounter = tokensCounter;
|
this.tokensCounter = tokensCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int getMainSentiment() {
|
public int getMainSentiment() {
|
||||||
return mainSentiment;
|
return mainSentiment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setMainSentiment(int mainSentiment) {
|
public void setMainSentiment(int mainSentiment) {
|
||||||
SentimentValueCache.mainSentiment = mainSentiment;
|
this.mainSentiment = mainSentiment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int getLongest() {
|
public int getLongest() {
|
||||||
return longest;
|
return longest;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setLongest(int longest) {
|
public void setLongest(int longest) {
|
||||||
SentimentValueCache.longest = longest;
|
this.longest = longest;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final List getClassifyRaw() {
|
public List getClassifyRaw() {
|
||||||
return classifyRaw;
|
return classifyRaw;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setClassifyRaw(List classifyRaw) {
|
public void setClassifyRaw(List classifyRaw) {
|
||||||
SentimentValueCache.classifyRaw = classifyRaw;
|
this.classifyRaw = classifyRaw;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final ConcurrentMap<Integer, Integer> getRnnPrediectClassMap() {
|
public ConcurrentMap<Integer, Integer> getRnnPrediectClassMap() {
|
||||||
return rnnPredictClassMap;
|
return rnnPredictClassMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void addRNNPredictClass(int rnnPrediction) {
|
public void addRNNPredictClass(int rnnPrediction) {
|
||||||
rnnPredictClassMap.put(rnnPredictClassMap.size(), rnnPrediction);
|
rnnPredictClassMap.put(rnnPredictClassMap.size(), rnnPrediction);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void addSimpleMatrix(SimpleMatrix SMX) {
|
public void addSimpleMatrix(SimpleMatrix SMX) {
|
||||||
simpleSMXlist.put(simpleSMXlist.size(), SMX);
|
simpleSMXlist.put(simpleSMXlist.size(), SMX);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void addSimpleMatrixVector(SimpleMatrix SMX) {
|
public void addSimpleMatrixVector(SimpleMatrix SMX) {
|
||||||
simpleSMXlistVector.put(simpleSMXlistVector.size(), SMX);
|
simpleSMXlistVector.put(simpleSMXlistVector.size(), SMX);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final ConcurrentMap<Integer, GrammaticalStructure> getGsMap() {
|
public ConcurrentMap<Integer, GrammaticalStructure> getGsMap() {
|
||||||
return gsMap;
|
return gsMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final ConcurrentMap<Integer, SimpleMatrix> getSimpleSMXlist() {
|
public ConcurrentMap<Integer, SimpleMatrix> getSimpleSMXlist() {
|
||||||
return simpleSMXlist;
|
return simpleSMXlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final ConcurrentMap<Integer, SimpleMatrix> getSimpleSMXlistVector() {
|
public ConcurrentMap<Integer, SimpleMatrix> getSimpleSMXlistVector() {
|
||||||
return simpleSMXlistVector;
|
return simpleSMXlistVector;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final ConcurrentMap<Integer, GrammaticalStructure> getGs() {
|
public ConcurrentMap<Integer, GrammaticalStructure> getGs() {
|
||||||
return gsMap;
|
return gsMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int getCounter() {
|
public int getCounter() {
|
||||||
return counter;
|
return counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void addGS(GrammaticalStructure gs) {
|
public void addGS(GrammaticalStructure gs) {
|
||||||
gsMap.put(gsMap.size(), gs);
|
gsMap.put(gsMap.size(), gs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Collection<TypedDependency> getAllTypedDependencies() {
|
public Collection<TypedDependency> getAllTypedDependencies() {
|
||||||
return allTypedDependencies;
|
return allTypedDependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void addTypedDependencies(Collection<TypedDependency> TDPlist) {
|
public void addTypedDependencies(Collection<TypedDependency> TDPlist) {
|
||||||
for (TypedDependency TDP : TDPlist) {
|
for (TypedDependency TDP : TDPlist) {
|
||||||
allTypedDependencies.add(TDP);
|
allTypedDependencies.add(TDP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public final ConcurrentMap<Integer, Tree> getSentenceConstituencyParseList() {
|
public ConcurrentMap<Integer, Tree> getSentenceConstituencyParseList() {
|
||||||
return sentenceConstituencyParseList;
|
return sentenceConstituencyParseList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void addSentenceConstituencyParse(Tree tree) {
|
public void addSentenceConstituencyParse(Tree tree) {
|
||||||
sentenceConstituencyParseList.put(sentenceConstituencyParseList.size(), tree);
|
sentenceConstituencyParseList.put(sentenceConstituencyParseList.size(), tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setCounter(int counter) {
|
public void setCounter(int counter) {
|
||||||
SentimentValueCache.counter = counter;
|
counter = counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String getSentence() {
|
public String getSentence() {
|
||||||
return sentence;
|
return sentence;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,12 +320,12 @@ public final class SentimentValueCache {
|
|||||||
this.counter = counter;
|
this.counter = counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final ConcurrentMap<Integer, String> getTgwlistIndex() {
|
public ConcurrentMap<Integer, String> getTgwlistIndex() {
|
||||||
return tgwlistIndex;
|
return tgwlistIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void addTgwlistIndex(String str) {
|
public void addTgwlistIndex(String str) {
|
||||||
tgwlistIndex.put(tgwlistIndex.size(), str);
|
tgwlistIndex.put(tgwlistIndex.size(), str);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SentimentValueCache(String str) {
|
public SentimentValueCache(String str) {
|
||||||
|
@ -18,9 +18,11 @@ import FunctionLayer.CustomError;
|
|||||||
import FunctionLayer.Datahandler;
|
import FunctionLayer.Datahandler;
|
||||||
import FunctionLayer.MessageResponseHandler;
|
import FunctionLayer.MessageResponseHandler;
|
||||||
import FunctionLayer.PipelineJMWESingleton;
|
import FunctionLayer.PipelineJMWESingleton;
|
||||||
|
import com.google.common.collect.MapMaker;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ConcurrentMap;
|
||||||
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 org.javacord.api.DiscordApi;
|
||||||
@ -33,7 +35,7 @@ import org.javacord.api.entity.user.User;
|
|||||||
*/
|
*/
|
||||||
public class DiscordHandler {
|
public class DiscordHandler {
|
||||||
|
|
||||||
private static String MostRecentMsg = "";
|
private static ConcurrentMap<String, Integer> responseTrackerMap = new MapMaker().concurrencyLevel(6).makeMap();
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.setProperty("java.util.concurrent.ForkJoinPool.common.parallelism", "15");
|
System.setProperty("java.util.concurrent.ForkJoinPool.common.parallelism", "15");
|
||||||
@ -83,14 +85,19 @@ public class DiscordHandler {
|
|||||||
}
|
}
|
||||||
if (event.getMessage().getMentionedUsers().contains(api.getYourself())
|
if (event.getMessage().getMentionedUsers().contains(api.getYourself())
|
||||||
|| event.getServerTextChannel().get().toString().contains("general-autism")) {
|
|| event.getServerTextChannel().get().toString().contains("general-autism")) {
|
||||||
String ResponseStr;
|
|
||||||
try {
|
try {
|
||||||
|
String ResponseStr;
|
||||||
String person = event.getMessageAuthor().getName();
|
String person = event.getMessageAuthor().getName();
|
||||||
ResponseStr = MessageResponseHandler.selectReponseMessage(event.getMessage().toString(), MostRecentMsg, person);
|
ResponseStr = MessageResponseHandler.selectReponseMessage(event.getMessage().toString(), responseTrackerMap, person);
|
||||||
if (!ResponseStr.isEmpty()) {
|
if (!ResponseStr.isEmpty()) {
|
||||||
System.out.print("\nResponseStr3: " + ResponseStr + "\n");
|
System.out.print("\nResponseStr3: " + ResponseStr + "\n");
|
||||||
event.getChannel().sendMessage(ResponseStr);
|
event.getChannel().sendMessage(ResponseStr);
|
||||||
MostRecentMsg = ResponseStr;
|
Integer responseTracker = responseTrackerMap.getOrDefault(ResponseStr, null);
|
||||||
|
if (responseTracker == null) {
|
||||||
|
responseTrackerMap.put(ResponseStr, 0);
|
||||||
|
} else {
|
||||||
|
responseTrackerMap.put(ResponseStr, responseTracker + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} 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);
|
||||||
|
Loading…
Reference in New Issue
Block a user