turning more annotations to use compact for supposedly saving memory, added a relation containment based on first response evalutation and hopefully fixed integernames
This commit is contained in:
parent
cc2ca64ad5
commit
09d5d3534d
@ -61,7 +61,6 @@ public class Datahandler {
|
||||
public static final long EXPIRE_TIME_IN_SECONDS = TimeUnit.SECONDS.convert(10, TimeUnit.MINUTES);
|
||||
public static final long EXPIRE_TIME_IN_SECONDS1 = TimeUnit.SECONDS.convert(10, TimeUnit.HOURS);
|
||||
public static Datahandler instance = new Datahandler();
|
||||
private static volatile Double minDistance;
|
||||
private static Annotation strAnno;
|
||||
private static Annotation strAnnoSentiment;
|
||||
private static Annotation strAnnoJMWE;
|
||||
@ -222,7 +221,7 @@ public class Datahandler {
|
||||
hlStatsMessages.put(str, hlStatsMessages.size());
|
||||
}
|
||||
}
|
||||
int capacity = 2500;
|
||||
int capacity = 50;
|
||||
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);
|
||||
@ -248,17 +247,22 @@ public class Datahandler {
|
||||
ConcurrentMap<String, Annotation> AnnotationspipelineSentiment = new MapMaker().concurrencyLevel(2).makeMap();
|
||||
stringCache.values().parallelStream().forEach(str -> {
|
||||
Annotation strAnno = new Annotation(str);
|
||||
strAnno.compact();
|
||||
Annotationspipeline.put(str, strAnno);
|
||||
Annotation strAnno2 = new Annotation(str);
|
||||
strAnno2.compact();
|
||||
AnnotationspipelineSentiment.put(str, strAnno2);
|
||||
});
|
||||
ConcurrentMap<String, CoreDocument> coreDocumentpipelineMap = getMultipleCoreDocumentsWaySuggestion(stringCache.values(), pipeline);
|
||||
pipeline.annotate(Annotationspipeline.values());
|
||||
pipelineSentiment.annotate(AnnotationspipelineSentiment.values());
|
||||
Annotationspipeline.entrySet().forEach(pipelineEntry -> {
|
||||
//relatively experimental change
|
||||
pipelineEntry.getValue().compact();
|
||||
pipelineAnnotationCache.put(pipelineEntry.getKey(), pipelineEntry.getValue());
|
||||
});
|
||||
AnnotationspipelineSentiment.entrySet().forEach(pipelineEntry -> {
|
||||
pipelineEntry.getValue().compact();
|
||||
pipelineSentimentAnnotationCache.put(pipelineEntry.getKey(), pipelineEntry.getValue());
|
||||
});
|
||||
coreDocumentpipelineMap.entrySet().stream().forEach(CD -> {
|
||||
@ -486,19 +490,34 @@ public class Datahandler {
|
||||
}
|
||||
}
|
||||
StringBuilder SB = new StringBuilder();
|
||||
double randomLenghtPermit = strF.length() * (Math.random() * 1.5);
|
||||
double randomLenghtPermit = strF.length() * (Math.random() * 2.0);
|
||||
Collections.reverse(concurrentRelations);
|
||||
String firstRelation = concurrentRelations.get(0);
|
||||
for (String secondaryRelation : concurrentRelations) {
|
||||
if (SB.toString().length() > randomLenghtPermit && !SB.toString().isEmpty()) {
|
||||
break;
|
||||
}
|
||||
System.out.println("relation secondary: " + secondaryRelation + "\n");
|
||||
SB.append(secondaryRelation).append(" ");
|
||||
boolean append = appendToString(firstRelation, secondaryRelation);
|
||||
if (append) {
|
||||
SB.append(secondaryRelation).append(" ");
|
||||
}
|
||||
}
|
||||
System.out.println("Reached end SB: " + SB.toString() + "\n");
|
||||
return SB.toString();
|
||||
}
|
||||
|
||||
private boolean appendToString(String firstRelation, String secondaryRelation) {
|
||||
if (firstRelation.equals(secondaryRelation)) {
|
||||
return true;
|
||||
}
|
||||
Double scoreRelationStrF = getScoreRelationStrF(firstRelation, secondaryRelation);
|
||||
if (scoreRelationStrF > 1900) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private double overAllOldScoreRelations(String strF) {
|
||||
if (!conversationUserMatchMap.keySet().contains(strF)) {
|
||||
conversationUserMatchMap.put(strF, conversationUserMatchMap.size());
|
||||
@ -520,13 +539,16 @@ public class Datahandler {
|
||||
|
||||
public void getSingularAnnotation(String str) {
|
||||
strAnno = new Annotation(str);
|
||||
strAnno.compact();
|
||||
pipeline.annotate(strAnno);
|
||||
strAnnoSentiment = new Annotation(str);
|
||||
strAnnoSentiment.compact();
|
||||
pipelineSentiment.annotate(strAnnoSentiment);
|
||||
List<String> notactualList = new ArrayList();
|
||||
notactualList.add(str);
|
||||
ConcurrentMap<String, Annotation> jmweAnnotation = PipelineJMWESingleton.INSTANCE.getJMWEAnnotation(notactualList);
|
||||
strAnnoJMWE = jmweAnnotation.values().iterator().next();
|
||||
strAnnoJMWE.compact();
|
||||
CoreDocument coreDocument = new CoreDocument(str);
|
||||
pipeline.annotate(coreDocument);
|
||||
coreDoc = coreDocument;
|
||||
@ -811,14 +833,12 @@ public class Datahandler {
|
||||
Logger.getLogger(Datahandler.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
ConcurrentMap<String, CoreDocument> annotationreturnMap = new MapMaker().concurrencyLevel(6).makeMap();
|
||||
int iterator = 0;
|
||||
for (Annotation ann : annCollector.annotationsT) {
|
||||
if (ann != null) {
|
||||
ann.compact();
|
||||
CoreDocument CD = new CoreDocument(ann);
|
||||
annotationreturnMap.put(CD.text(), CD);
|
||||
//System.out.println("CD text:" + CD.text() + "\niterator: " + iterator + "\nsize: " + annCollector.annotationsT.size());
|
||||
iterator++;
|
||||
}
|
||||
}
|
||||
return annotationreturnMap;
|
||||
|
@ -11,6 +11,8 @@ import edu.stanford.nlp.pipeline.CoreEntityMention;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -65,6 +67,7 @@ public class MessageResponseHandler {
|
||||
CoreDocument pipelineCoreDcoumentLastMsg = new CoreDocument(userLastMessage);
|
||||
Datahandler.getPipeline().annotate(pipelineCoreDcoument);
|
||||
Datahandler.getPipeline().annotate(pipelineCoreDcoumentLastMsg);
|
||||
String regex = "(.*?\\d){10,}";
|
||||
try {
|
||||
for (CoreEntityMention em : pipelineCoreDcoument.entityMentions()) {
|
||||
String entityType = em.entityType();
|
||||
@ -72,7 +75,10 @@ public class MessageResponseHandler {
|
||||
try {
|
||||
String str = strreturn;
|
||||
String emText = em.text();
|
||||
if (!emText.equals(personName)) {
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(personName);
|
||||
boolean isMatched = matcher.matches();
|
||||
if (!emText.equals(personName) && !isMatched) {
|
||||
for (CoreEntityMention emLastMsg : pipelineCoreDcoumentLastMsg.entityMentions()) {
|
||||
if (!emText.equals(emLastMsg.text())) {
|
||||
str = strreturn.replaceFirst(emText, emLastMsg.text());
|
||||
|
@ -449,7 +449,11 @@ public class SentimentAnalyzerTest implements Callable<SimilarityMatrix> {
|
||||
if (dotPrediction2 > 30 && dotPrediction2 < 60) {
|
||||
if (dotpredictionTransfer != 0.0 && (subtracter2 / dotPrediction2 < 1.3 || (subtracter2 / dotPrediction2 > 1.9
|
||||
&& subtracter2 / dotPrediction2 < 1.99))) {
|
||||
score += 4500;
|
||||
if (subtracter2 / dotPrediction2 < 1.248 && subtracter2 / dotPrediction2 > 1.238) {
|
||||
score -= 2500;
|
||||
} else {
|
||||
score += 4500;
|
||||
}
|
||||
} else if (dotpredictionTransfer != 0.0 && subtracter2 / dotPrediction2 > 1.6 && subtracter2 / dotPrediction2 < 1.95) {
|
||||
if (subtracter2 > 61.1 && subtracter2 < 61.9 && dotPrediction2 > 37.5 && dotPrediction2 < 38.2) {
|
||||
score += 4500;
|
||||
|
Loading…
Reference in New Issue
Block a user