some bot overhauls

This commit is contained in:
jenzur
2019-08-03 14:35:09 +02:00
parent 00f91030f9
commit d62cdf3aeb
8 changed files with 491 additions and 594 deletions
@@ -29,6 +29,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
@@ -37,15 +38,19 @@ import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinTask;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.function.Consumer;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
*
@@ -62,19 +67,15 @@ public class Datahandler {
private static Annotation strAnnoJMWE;
private static CoreDocument coreDoc;
private static final ConcurrentMap<Integer, String> stringCache = new MapMaker().concurrencyLevel(2).makeMap();
private static int positiveRelationCounter = 0;
private static int negativeRelationCounter = 0;
private static int RelationCounter = 0;
private static ConcurrentMap<String, Annotation> pipelineAnnotationCache;
private static ConcurrentMap<String, Annotation> pipelineSentimentAnnotationCache;
private static ConcurrentMap<String, Annotation> jmweAnnotationCache;
private static ConcurrentMap<String, CoreDocument> coreDocumentAnnotationCache;
private static ConcurrentMap<Integer, String> conversationMatchMap;
private static ConcurrentMap<String, Integer> conversationUserMatchMap;
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 final Stopwatch stopwatch;
private static final ForkJoinPool executor = instantiateExecutor();
private static String similar = "";
private static String shiftReduceParserPath = "edu/stanford/nlp/models/srparser/englishSR.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.pipelineSentimentAnnotationCache = new MapMaker().concurrencyLevel(4).makeMap();
this.coreDocumentAnnotationCache = new MapMaker().concurrencyLevel(5).makeMap();
this.conversationMatchMap = 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() {
return gsf;
}
@@ -229,7 +222,7 @@ public class Datahandler {
hlStatsMessages.put(str, hlStatsMessages.size());
}
}
int capacity = 9550;
int capacity = 1500;
hlStatsMessages.keySet().forEach(str -> {
if (!str.startsWith("!") && MessageResponseHandler.getStr().values().size() < capacity) {
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) {
for (Entry<String, Future<SimilarityMatrix>> entrySet : entries.entrySet()) {
String transmittedStr = entrySet.getKey();
SimilarityMatrix getSMX = retrieveFutureSMX(entrySet.getValue());
int handleRetrievedSMX = handleRetrievedSMX(getSMX, transmittedStr);
System.out.println("handleRetrievedSMX: " + handleRetrievedSMX + "\n");
if (handleRetrievedSMX == 2) {
strmapreturn.put(strmapreturn.size(), str);
break;
} else if (handleRetrievedSMX == 1) {
break;
String newPrimary = similarityMatrixes.get(0).getPrimaryString();
int evaluationCap = 50000;
boolean hitCap = false;
for (SimilarityMatrix SMX : similarityMatrixes) {
if (!newPrimary.equals(SMX.getPrimaryString())) {
newPrimary = SMX.getPrimaryString();
strmapreturn = addSMXToMapReturn(strmapreturn, SMX);
hitCap = false;
}
if (getSMX != null) {
SentimentValueCache cacheValue1 = getSMX.getCacheValue1();
SentimentValueCache cacheValue2 = getSMX.getCacheValue2();
if (cacheValue1 != null && !sentimentCachingMap.keySet().contains(str)) {
sentimentCachingMap.put(str, getSMX.getCacheValue1());
}
if (cacheValue2 != null && !sentimentCachingMap.keySet().contains(transmittedStr)) {
sentimentCachingMap.put(transmittedStr, getSMX.getCacheValue2());
if (!hitCap) {
final Double scoreRelationNewMsgToRecentMsg = SMX.getDistance();
RelationCounter += scoreRelationNewMsgToRecentMsg > 0 ? scoreRelationNewMsgToRecentMsg * 2 : scoreRelationNewMsgToRecentMsg;
if (RelationCounter > evaluationCap) {
strmapreturn = addSMXToMapReturn(strmapreturn, SMX);
hitCap = true;
} else if (RelationCounter < evaluationCap * -1) {
addSMXToMapReturn(strmapreturn, SMX);
hitCap = true;
}
}
}
return strmapreturn;
}
private int handleRetrievedSMX(SimilarityMatrix getSMX, String transmittedStr) {
final int relationCap = 20;
if (getSMX != null) {
//System.out.println("getSMX primary: " + getSMX.getPrimaryString() + "\ngetSMX secondary: " + getSMX.getSecondaryString() + "\n");
final Double scoreRelationNewMsgToRecentMsg = getSMX.getDistance();
//System.out.println("scoreRelationNewMsgToRecentMsg: " + scoreRelationNewMsgToRecentMsg + "\n");
if (scoreRelationNewMsgToRecentMsg >= 200.0) {
positiveRelationCounter++;
if (positiveRelationCounter >= relationCap) {
return 2;
}
} else if (scoreRelationNewMsgToRecentMsg <= -6000.0) {
negativeRelationCounter += 1;
private ConcurrentMap<Integer, String> addSMXToMapReturn(ConcurrentMap<Integer, String> strmapreturn, SimilarityMatrix SMX) {
System.out.println("RelationCounter cap: " + RelationCounter);
boolean related = RelationCounter > 0;
if (related) {
strmapreturn.put(strmapreturn.size(), SMX.getPrimaryString());
String transmittedStr = SMX.getSecondaryString();
SentimentValueCache cacheValue1 = SMX.getCacheValue1();
SentimentValueCache cacheValue2 = SMX.getCacheValue2();
if (cacheValue1 != null && !sentimentCachingMap.keySet().contains(SMX.getPrimaryString())) {
sentimentCachingMap.put(SMX.getPrimaryString(), SMX.getCacheValue1());
}
} else {
Integer getCounts = locateFaultySentences.getOrDefault(transmittedStr, null);
if (getCounts == null) {
locateFaultySentences.put(transmittedStr, 0);
} else {
locateFaultySentences.put(transmittedStr, getCounts + 1);
if (cacheValue2 != null && !sentimentCachingMap.keySet().contains(transmittedStr)) {
sentimentCachingMap.put(transmittedStr, SMX.getCacheValue2());
}
}
if (negativeRelationCounter >= relationCap) {
return 1;
}
return 0;
RelationCounter = 0;
return strmapreturn;
}
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<String, Annotation> localPipelineAnnotation, ConcurrentMap<String, Annotation> localPipelineSentimentAnnotation,
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);
List<SimilarityMatrix> smxReturnList = new ArrayList();
ExecutorService smxService = Executors.newFixedThreadPool(6);
for (String str1 : strCacheLocal.values()) {
//experimental change
if (!str.equals(str1) && !futures.keySet().contains(str1)) {
final SimilarityMatrix SMX = new SimilarityMatrix(str, str1);
if (!str.equals(str1)) {
SimilarityMatrix SMXInit = new SimilarityMatrix(str, str1);
SentimentValueCache sentimentCacheStr1 = sentimentCachingMap.getOrDefault(str1, null);
final Callable<SimilarityMatrix> worker;
Callable<SimilarityMatrix> worker;
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),
localPipelineAnnotation.get(str1), localPipelineSentimentAnnotation.get(str),
localPipelineSentimentAnnotation.get(str1), localCoreDocumentMap.get(str), localCoreDocumentMap.get(str1), sentimentCacheStr, sentimentCacheStr1);
} else {
worker = new SentimentAnalyzerTest(str, str1, SMX,
worker = new SentimentAnalyzerTest(str, str1, SMXInit,
localJMWEMap.get(str), jmweAnnotationCache.get(str1), localPipelineAnnotation.get(str),
pipelineAnnotationCache.get(str1), localPipelineSentimentAnnotation.get(str),
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
= new AbstractMap.SimpleEntry(futures, strCacheLocal);
return mapreturn;
return smxReturnList;
}
private ConcurrentMap<Integer, String> stringIteratorComparator(ConcurrentMap<Integer, String> strmap,
ConcurrentMap<Integer, String> strCacheLocal, ConcurrentMap<String, Annotation> localJMWEMap,
ConcurrentMap<String, Annotation> localPipelineAnnotation, ConcurrentMap<String, Annotation> localPipelineSentimentAnnotation,
ConcurrentMap<String, CoreDocument> localCoreDocumentMap) {
int i = 0;
ConcurrentMap<Integer, String> strmapreturn = new MapMaker().concurrencyLevel(4).makeMap();
ConcurrentMap<Integer, String> strmapreturn = new MapMaker().concurrencyLevel(6).makeMap();
List<SimilarityMatrix> strSenseRelationMap = new ArrayList();
for (String str : strmap.values()) {
Integer getFaultyOccurences = locateFaultySentences.getOrDefault(str, null);
if (getFaultyOccurences == null || getFaultyOccurences <= 20) {
positiveRelationCounter = 0;
negativeRelationCounter = 0;
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++;
List<SimilarityMatrix> localNoSentenceRelationList = StrComparringNoSentenceRelationMap(strCacheLocal, str,
localJMWEMap, localPipelineAnnotation, localPipelineSentimentAnnotation, localCoreDocumentMap);
for (SimilarityMatrix SMX : localNoSentenceRelationList) {
strSenseRelationMap.add(SMX);
}
}
Collections.sort(strSenseRelationMap, (e1, e2) -> e1.getPrimaryString().compareTo(e2.getPrimaryString()));
strmapreturn = futuresReturnOverallEvaluation(strSenseRelationMap, 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<String, Annotation> localJMWEMap = getMultipleJMWEAnnotation(strmap.values());
final ConcurrentMap<String, Annotation> localPipelineAnnotation = getMultiplePipelineAnnotation(strmap.values());
final ConcurrentMap<String, Annotation> localPipelineSentimentAnnotation = getMultiplePipelineSentimentAnnotation(strmap.values());
final ConcurrentMap<String, CoreDocument> localCoreDocumentMap = getMultipleCoreDocumentsWaySuggestion(strmap.values(), pipeline);
System.out.println("finished removeNonSensicalStrings annotations \n");
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 {
if (stopwatch.elapsed(TimeUnit.SECONDS) >= EXPIRE_TIME_IN_SECONDS || !stopwatch.isRunning()) {
ConcurrentMap<Integer, String> str = MessageResponseHandler.getStr();
@@ -422,7 +384,6 @@ public class Datahandler {
str = removeSlacks(str);
System.out.println("finished removeSlacks \n" + str.size() + "\n");
str = removeNonSensicalStrings(str);
System.out.println("POST removeNonSensicalStrings size: " + str.size() + "\n");
str = annotationCacheUpdate(str);
System.out.println("annotationCacheUpdate str size POST: " + str.size() + "\n");
ConcurrentMap<Integer, String> strf = str;
@@ -461,7 +422,7 @@ public class Datahandler {
return str;
}
private String getResponseFutures(String strF) {
private String getResponseFutures(String strF, ConcurrentMap<String, Integer> mostRecentMsgMap) {
ConcurrentMap<Integer, String> strCache = stringCache;
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
@@ -475,9 +436,17 @@ public class Datahandler {
pipelineSentimentAnnotationCache.get(str1), coreDoc, coreDocumentAnnotationCache.get(str1), null, sentimentCacheStr1);
try {
SimilarityMatrix getSMX = worker.call();
//SimilarityMatrix getSMX = executor.submit(worker).get(5, TimeUnit.SECONDS);
if (getSMX != null) {
Integer repeatedSentences = mostRecentMsgMap.getOrDefault(getSMX.getSecondaryString(), null);
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) {
preRelationUserCounters = scoreRelationLastUserMsg;
concurrentRelations.add(getSMX.getSecondaryString());
@@ -493,7 +462,7 @@ public class Datahandler {
}
}
StringBuilder SB = new StringBuilder();
double randomLenghtPermit = strF.length() * (Math.random() * 5.5);
double randomLenghtPermit = strF.length() * (Math.random() * 1.5);
Collections.reverse(concurrentRelations);
for (String secondaryRelation : concurrentRelations) {
if (SB.toString().length() > randomLenghtPermit && !SB.toString().isEmpty()) {
@@ -506,41 +475,23 @@ public class Datahandler {
return SB.toString();
}
private double setupScoreRelationtoRecent(String strF, ConcurrentMap<String, Double> getPrimaryLocal) {
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);
}
private double overAllOldScoreRelations(String strF) {
if (!conversationUserMatchMap.keySet().contains(strF)) {
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) {
@@ -767,7 +718,7 @@ public class Datahandler {
}
if (!tooclosematch) {
strreturn.put(strreturn.size() + 1, str1);
System.out.println("adding strreturn str1: " + str1 + "\n");
//System.out.println("adding strreturn str1: " + str1 + "\n");
}
});
return strreturn;
@@ -814,42 +765,35 @@ public class Datahandler {
private static class AnnotationCollector<T> implements Consumer<T> {
private static int i = 0;
private final List<T> annotationsT = new ArrayList();
private List<T> annotationsT = new ArrayList();
@Override
public final void accept(T ann) {
public void accept(T ann) {
//System.out.println("adding ann: " + ann.toString());
annotationsT.add(ann);
}
}
public static ConcurrentMap<String, CoreDocument> getMultipleCoreDocumentsWaySuggestion(Collection<String> str, StanfordCoreNLP localNLP) {
AnnotationCollector<Annotation> annCollector = new AnnotationCollector();
System.out.println("processing multiple coreDocuments Annotation: \n");
for (final String exampleString : str) {
//System.out.println("exampleString: " + exampleString + "\n");
// System.out.println("exampleString: " + exampleString + "\n");
localNLP.annotate(new Annotation(exampleString), annCollector);
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 {
Thread.sleep(10000);
Thread.sleep(4000);
} catch (InterruptedException ex) {
Logger.getLogger(Datahandler.class.getName()).log(Level.SEVERE, null, ex);
}
ConcurrentMap<String, CoreDocument> annotationreturnMap = new MapMaker().concurrencyLevel(2).makeMap();
List<CoreDocument> coreDocs = annCollector.annotationsT.stream().map(ann -> {
try {
return new CoreDocument(ann);
} catch (Exception ex) {
System.out.println(ex.getLocalizedMessage());
return null;
}
}).collect(Collectors.toList());
coreDocs.stream().forEach(CD -> {
if (CD != null) {
ConcurrentMap<String, CoreDocument> annotationreturnMap = new MapMaker().concurrencyLevel(6).makeMap();
for (Annotation ann : annCollector.annotationsT) {
if (ann != null) {
CoreDocument CD = new CoreDocument(ann);
annotationreturnMap.put(CD.text(), CD);
}
});
}
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();
str1.put(str1.size() + 1, toString);
str1 = Datahandler.cutContent(str1, false);
@@ -51,7 +52,7 @@ public class MessageResponseHandler {
strreturn = str;
}
}
String getResponseMsg = Datahandler.instance.getResponseMsg(strreturn, mostRecentMsg);
String getResponseMsg = Datahandler.instance.getResponseMsg(strreturn, mostRecentMsgMap);
getResponseMsg = checkPersonPresentInSentence(personName, getResponseMsg, strreturn);
return getResponseMsg;
}
@@ -13,19 +13,11 @@ import FunctionLayer.StanfordParser.SentimentValueCache;
*/
public class SimilarityMatrix {
private static String PrimaryString;
private static String SecondaryString;
private static double distance;
private static SentimentValueCache cacheValue1;
private static SentimentValueCache cacheValue2;
public final SentimentValueCache getCacheValue2() {
return cacheValue2;
}
public final void setCacheValue2(SentimentValueCache cacheValue2) {
SimilarityMatrix.cacheValue2 = cacheValue2;
}
private String PrimaryString;
private String SecondaryString;
private double distance;
private SentimentValueCache cacheValue1;
private SentimentValueCache cacheValue2;
public final double getDistance() {
return distance;
@@ -70,4 +62,12 @@ public class SimilarityMatrix {
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
*/
public final class SentimentValueCache {
public class SentimentValueCache {
private final String sentence;
private static int counter;
private static List<List<TaggedWord>> taggedwordlist = new ArrayList();
private String sentence;
private int counter;
private List<List<TaggedWord>> taggedwordlist = new ArrayList();
private final ConcurrentMap<Integer, String> tgwlistIndex = new MapMaker().concurrencyLevel(2).makeMap();
private final ConcurrentMap<Integer, Tree> sentenceConstituencyParseList = new MapMaker().concurrencyLevel(2).makeMap();
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> simpleSMXlistVector = new MapMaker().concurrencyLevel(3).makeMap();
private final ConcurrentMap<Integer, Integer> rnnPredictClassMap = new MapMaker().concurrencyLevel(3).makeMap();
private static List classifyRaw;
private static int mainSentiment = 0;
private static int longest = 0;
private static int tokensCounter = 0;
private static int anotatorcounter = 0;
private static int inflectedCounterPositive = 0;
private static int inflectedCounterNegative = 0;
private static int MarkedContinuousCounter = 0;
private static int MarkedContiniousCounterEntries = 0;
private static int UnmarkedPatternCounter = 0;
private static int pairCounter = 0;
private List classifyRaw;
private int mainSentiment = 0;
private int longest = 0;
private int tokensCounter = 0;
private int anotatorcounter = 0;
private int inflectedCounterPositive = 0;
private int inflectedCounterNegative = 0;
private int MarkedContinuousCounter = 0;
private int MarkedContiniousCounterEntries = 0;
private int UnmarkedPatternCounter = 0;
private int pairCounter = 0;
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> 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> stopWordLemma = new MapMaker().concurrencyLevel(2).makeMap();
public final int getPairCounter() {
public int getPairCounter() {
return pairCounter;
}
public final void setPairCounter(int pairCounter) {
SentimentValueCache.pairCounter = pairCounter;
public void setPairCounter(int pairCounter) {
this.pairCounter = pairCounter;
}
public final void addStopWordLemma(String str) {
public void addStopWordLemma(String str) {
stopWordLemma.put(stopWordLemma.size(), str);
}
public final void addstopwordTokens(String str) {
public void addstopwordTokens(String str) {
stopwordTokens.put(stopwordTokens.size(), str);
}
public final ConcurrentMap<Integer, String> getStopwordTokens() {
public ConcurrentMap<Integer, String> getStopwordTokens() {
return stopwordTokens;
}
public final ConcurrentMap<Integer, String> getStopWordLemma() {
public ConcurrentMap<Integer, String> getStopWordLemma() {
return stopWordLemma;
}
public final void addnerEntityTokenTags(String str) {
public void addnerEntityTokenTags(String str) {
nerEntityTokenTags.put(nerEntityTokenTags.size(), str);
}
public final ConcurrentMap<Integer, String> getnerEntityTokenTags() {
public ConcurrentMap<Integer, String> getnerEntityTokenTags() {
return nerEntityTokenTags;
}
public final ConcurrentMap<Integer, String> getnerEntities1() {
public ConcurrentMap<Integer, String> getnerEntities1() {
return nerEntities1;
}
public final ConcurrentMap<Integer, String> getnerEntities2() {
public ConcurrentMap<Integer, String> getnerEntities2() {
return nerEntities2;
}
public final void addNEREntities1(String str) {
public void addNEREntities1(String str) {
nerEntities1.put(nerEntities1.size(), str);
}
public final void addNEREntities2(String str) {
public void addNEREntities2(String str) {
nerEntities2.put(nerEntities2.size(), str);
}
public final void setTaggedwords(List<List<TaggedWord>> twlist) {
public void setTaggedwords(List<List<TaggedWord>> twlist) {
taggedwordlist = twlist;
}
public final List<List<TaggedWord>> getTaggedwordlist() {
public List<List<TaggedWord>> getTaggedwordlist() {
return taggedwordlist;
}
public final void addEntryCounts(int counts) {
public void addEntryCounts(int counts) {
entryCounts.put(entryCounts.size(), counts);
}
public final ConcurrentMap<Integer, Integer> getEntryCounts() {
public ConcurrentMap<Integer, Integer> getEntryCounts() {
return entryCounts;
}
public final void addstrTokenEntryPOS(String str) {
public void addstrTokenEntryPOS(String str) {
strTokenEntryPOS.put(strTokenEntryPOS.size(), str);
}
public final ConcurrentMap<Integer, String> getstrTokenEntryPOS() {
public ConcurrentMap<Integer, String> getstrTokenEntryPOS() {
return strTokenEntryPOS;
}
public final void addstrTokenGetiPart(String str) {
public void addstrTokenGetiPart(String str) {
strTokenGetiPart.put(strTokenGetiPart.size(), str);
}
public final ConcurrentMap<Integer, String> getstrTokenGetiPart() {
public ConcurrentMap<Integer, String> getstrTokenGetiPart() {
return strTokenGetiPart;
}
public final ConcurrentMap<Integer, String> getstrTokenGetEntry() {
public ConcurrentMap<Integer, String> getstrTokenGetEntry() {
return strTokenGetEntry;
}
public final void addstrTokenGetEntry(String str) {
public void addstrTokenGetEntry(String str) {
strTokenGetEntry.put(strTokenGetEntry.size(), str);
}
public final ConcurrentMap<Integer, String> getstrTokenForm() {
public ConcurrentMap<Integer, String> getstrTokenForm() {
return strTokenForm;
}
public final void addstrTokenForm(String str) {
public void addstrTokenForm(String str) {
strTokenForm.put(strTokenForm.size(), str);
}
public final ConcurrentMap<Integer, String> getstrTokenStems() {
public ConcurrentMap<Integer, String> getstrTokenStems() {
return strTokenStems;
}
public final void addstrTokenStems(String str) {
public void addstrTokenStems(String str) {
strTokenStems.put(strTokenStems.size(), str);
}
public final ConcurrentMap<Integer, String> getITokenMapTag() {
public ConcurrentMap<Integer, String> getITokenMapTag() {
return ITokenMapTag;
}
public final void addITokenMapTag(String str) {
public void addITokenMapTag(String str) {
ITokenMapTag.put(ITokenMapTag.size(), str);
}
public final int getUnmarkedPatternCounter() {
public int getUnmarkedPatternCounter() {
return UnmarkedPatternCounter;
}
public final void setUnmarkedPatternCounter(int UnmarkedPatternCounter) {
SentimentValueCache.UnmarkedPatternCounter = UnmarkedPatternCounter;
public void setUnmarkedPatternCounter(int UnmarkedPatternCounter) {
this.UnmarkedPatternCounter = UnmarkedPatternCounter;
}
public final int getMarkedContiniousCounterEntries() {
public int getMarkedContiniousCounterEntries() {
return MarkedContiniousCounterEntries;
}
public final void setMarkedContiniousCounterEntries(int MarkedContiniousCounterEntries) {
SentimentValueCache.MarkedContiniousCounterEntries = MarkedContiniousCounterEntries;
public void setMarkedContiniousCounterEntries(int MarkedContiniousCounterEntries) {
this.MarkedContiniousCounterEntries = MarkedContiniousCounterEntries;
}
public final int getMarkedContinuousCounter() {
public int getMarkedContinuousCounter() {
return MarkedContinuousCounter;
}
public final void setMarkedContinuousCounter(int MarkedContinuousCounter) {
SentimentValueCache.MarkedContinuousCounter = MarkedContinuousCounter;
public void setMarkedContinuousCounter(int MarkedContinuousCounter) {
this.MarkedContinuousCounter = MarkedContinuousCounter;
}
public final int getInflectedCounterNegative() {
public int getInflectedCounterNegative() {
return inflectedCounterNegative;
}
public final void setInflectedCounterNegative(int inflectedCounterNegative) {
SentimentValueCache.inflectedCounterNegative = inflectedCounterNegative;
public void setInflectedCounterNegative(int inflectedCounterNegative) {
this.inflectedCounterNegative = inflectedCounterNegative;
}
public final int getInflectedCounterPositive() {
public int getInflectedCounterPositive() {
return inflectedCounterPositive;
}
public final void setInflectedCounterPositive(int inflectedCounterPositive) {
SentimentValueCache.inflectedCounterPositive = inflectedCounterPositive;
public void setInflectedCounterPositive(int inflectedCounterPositive) {
this.inflectedCounterPositive = inflectedCounterPositive;
}
public final int getAnotatorcounter() {
public int getAnotatorcounter() {
return anotatorcounter;
}
public final void setAnotatorcounter(int anotatorcounter) {
SentimentValueCache.anotatorcounter = anotatorcounter;
public void setAnotatorcounter(int anotatorcounter) {
this.anotatorcounter = anotatorcounter;
}
public final int getTokensCounter() {
public int getTokensCounter() {
return tokensCounter;
}
public final void setTokensCounter(int tokensCounter) {
SentimentValueCache.tokensCounter = tokensCounter;
public void setTokensCounter(int tokensCounter) {
this.tokensCounter = tokensCounter;
}
public final int getMainSentiment() {
public int getMainSentiment() {
return mainSentiment;
}
public final void setMainSentiment(int mainSentiment) {
SentimentValueCache.mainSentiment = mainSentiment;
public void setMainSentiment(int mainSentiment) {
this.mainSentiment = mainSentiment;
}
public final int getLongest() {
public int getLongest() {
return longest;
}
public final void setLongest(int longest) {
SentimentValueCache.longest = longest;
public void setLongest(int longest) {
this.longest = longest;
}
public final List getClassifyRaw() {
public List getClassifyRaw() {
return classifyRaw;
}
public final void setClassifyRaw(List classifyRaw) {
SentimentValueCache.classifyRaw = classifyRaw;
public void setClassifyRaw(List classifyRaw) {
this.classifyRaw = classifyRaw;
}
public final ConcurrentMap<Integer, Integer> getRnnPrediectClassMap() {
public ConcurrentMap<Integer, Integer> getRnnPrediectClassMap() {
return rnnPredictClassMap;
}
public final void addRNNPredictClass(int rnnPrediction) {
public void addRNNPredictClass(int rnnPrediction) {
rnnPredictClassMap.put(rnnPredictClassMap.size(), rnnPrediction);
}
public final void addSimpleMatrix(SimpleMatrix SMX) {
public void addSimpleMatrix(SimpleMatrix SMX) {
simpleSMXlist.put(simpleSMXlist.size(), SMX);
}
public final void addSimpleMatrixVector(SimpleMatrix SMX) {
public void addSimpleMatrixVector(SimpleMatrix SMX) {
simpleSMXlistVector.put(simpleSMXlistVector.size(), SMX);
}
public final ConcurrentMap<Integer, GrammaticalStructure> getGsMap() {
public ConcurrentMap<Integer, GrammaticalStructure> getGsMap() {
return gsMap;
}
public final ConcurrentMap<Integer, SimpleMatrix> getSimpleSMXlist() {
public ConcurrentMap<Integer, SimpleMatrix> getSimpleSMXlist() {
return simpleSMXlist;
}
public final ConcurrentMap<Integer, SimpleMatrix> getSimpleSMXlistVector() {
public ConcurrentMap<Integer, SimpleMatrix> getSimpleSMXlistVector() {
return simpleSMXlistVector;
}
public final ConcurrentMap<Integer, GrammaticalStructure> getGs() {
public ConcurrentMap<Integer, GrammaticalStructure> getGs() {
return gsMap;
}
public final int getCounter() {
public int getCounter() {
return counter;
}
public final void addGS(GrammaticalStructure gs) {
public void addGS(GrammaticalStructure gs) {
gsMap.put(gsMap.size(), gs);
}
public final Collection<TypedDependency> getAllTypedDependencies() {
public Collection<TypedDependency> getAllTypedDependencies() {
return allTypedDependencies;
}
public final void addTypedDependencies(Collection<TypedDependency> TDPlist) {
public void addTypedDependencies(Collection<TypedDependency> TDPlist) {
for (TypedDependency TDP : TDPlist) {
allTypedDependencies.add(TDP);
}
}
public final ConcurrentMap<Integer, Tree> getSentenceConstituencyParseList() {
public ConcurrentMap<Integer, Tree> getSentenceConstituencyParseList() {
return sentenceConstituencyParseList;
}
public final void addSentenceConstituencyParse(Tree tree) {
public void addSentenceConstituencyParse(Tree tree) {
sentenceConstituencyParseList.put(sentenceConstituencyParseList.size(), tree);
}
public final void setCounter(int counter) {
SentimentValueCache.counter = counter;
public void setCounter(int counter) {
counter = counter;
}
public final String getSentence() {
public String getSentence() {
return sentence;
}
@@ -320,12 +320,12 @@ public final class SentimentValueCache {
this.counter = counter;
}
public final ConcurrentMap<Integer, String> getTgwlistIndex() {
public ConcurrentMap<Integer, String> getTgwlistIndex() {
return tgwlistIndex;
}
public final void addTgwlistIndex(String str) {
tgwlistIndex.put(tgwlistIndex.size(), str);
public void addTgwlistIndex(String str) {
tgwlistIndex.put(tgwlistIndex.size(), str);
}
public SentimentValueCache(String str) {