update to using futures again for quicker processing
This commit is contained in:
@@ -20,11 +20,15 @@ import edu.stanford.nlp.util.CoreMap;
|
||||
import org.ejml.simple.SimpleMatrix;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
public class Datahandler {
|
||||
|
||||
private ExecutorService pool = Executors.newFixedThreadPool(7);
|
||||
private CompletionService completionService = new ExecutorCompletionService(pool);
|
||||
private HashMap<String, Annotation> pipelineAnnotationCache;
|
||||
private HashMap<String, Annotation> pipelineSentimentAnnotationCache;
|
||||
private HashMap<String, CoreDocument> coreDocumentAnnotationCache;
|
||||
@@ -278,7 +282,7 @@ public class Datahandler {
|
||||
ArrayList<String> stopWordLemma1 = stopWordLemmaHashMap.getOrDefault(str1, null);
|
||||
Integer PairCounter1 = PairCounterHashMap.getOrDefault(str1, null);
|
||||
|
||||
SentimentAnalyzerTest SMX = new SentimentAnalyzerTest(strF, str1, new SimilarityMatrix(strF, str1),
|
||||
SentimentAnalyzerTest SMX = new SentimentAnalyzerTest(strF, str1,
|
||||
coreMaps1, coreMaps2, strAnno,
|
||||
pipelineAnnotationCache.get(str1), strAnnoSentiment,
|
||||
pipelineSentimentAnnotationCache.get(str1), coreDocument, coreDocumentAnnotationCache.get(str1),
|
||||
@@ -405,6 +409,109 @@ public class Datahandler {
|
||||
return SMX;
|
||||
}
|
||||
|
||||
private class get_res implements Callable<SentimentAnalyzerTest> {
|
||||
private final String strF;
|
||||
private final String str1;
|
||||
private final StanfordCoreNLP stanfordCoreNLP;
|
||||
private final StanfordCoreNLP stanfordCoreNLPSentiment;
|
||||
private final List<CoreMap> coreMaps1;
|
||||
private final Annotation strAnno;
|
||||
private final Annotation strAnnoSentiment;
|
||||
private final CoreDocument coreDocument;
|
||||
private final Integer tokenizeCountingF;
|
||||
private final List<List<TaggedWord>> taggedWordListF;
|
||||
private final ArrayList<TypedDependency> typedDependenciesF;
|
||||
private final ArrayList<Integer> rnnCoreAnnotationsPredictedF;
|
||||
private final ArrayList<SimpleMatrix> simpleMatricesF;
|
||||
private final ArrayList<SimpleMatrix> simpleMatricesNodevectorsF;
|
||||
private final List<String> listF;
|
||||
private final Integer longestF;
|
||||
private final List<CoreMap> sentencesF;
|
||||
private final List<CoreMap> sentencesSentimentF;
|
||||
private final ArrayList<Tree> treesF;
|
||||
private final ArrayList<GrammaticalStructure> grammaticalStructuresF;
|
||||
private final Integer sentimentLongestF;
|
||||
private final List<IMWE<IToken>> imwesF;
|
||||
private final Integer inflectedCounterNegativeF;
|
||||
private final Integer inflectedCounterPositiveF;
|
||||
private final ArrayList<String> tokenEntryF;
|
||||
private final Integer unmarkedPatternCounterF;
|
||||
private final ArrayList<String> strTokensIpartFormF;
|
||||
private final ArrayList<String> tokenFormsF;
|
||||
private final ArrayList<Integer> intTokenEntyCountsF;
|
||||
private final Integer markedContinuousCounterF;
|
||||
private final ArrayList<String> iTokenTagsF;
|
||||
private final ArrayList<String> strTokenEntryGetPOSF;
|
||||
private final ArrayList<String> retrieveTGWListF;
|
||||
private final Integer pairCounterF;
|
||||
private final Integer tokensCounterF;
|
||||
private final ArrayList<String> stopWordLemmaF;
|
||||
private final ArrayList<String> nerEntitiesF;
|
||||
private final ArrayList<String> stopWordTokenF;
|
||||
private final ArrayList<String> entityTokenTagsF;
|
||||
private final ArrayList<String> nerEntitiesTypeF;
|
||||
private final Integer anotatorcounterF;
|
||||
private final ArrayList<String> strTokenStemsF;
|
||||
|
||||
public get_res(String strF, String str1, StanfordCoreNLP stanfordCoreNLP, StanfordCoreNLP stanfordCoreNLPSentiment, List<CoreMap> coreMaps1, Annotation strAnno, Annotation strAnnoSentiment, CoreDocument coreDocument, Integer tokenizeCountingF, List<List<TaggedWord>> taggedWordListF, ArrayList<TypedDependency> typedDependenciesF, ArrayList<Integer> rnnCoreAnnotationsPredictedF, ArrayList<SimpleMatrix> simpleMatricesF, ArrayList<SimpleMatrix> simpleMatricesNodevectorsF, List<String> listF, Integer longestF, List<CoreMap> sentencesF, List<CoreMap> sentencesSentimentF, ArrayList<Tree> treesF, ArrayList<GrammaticalStructure> grammaticalStructuresF, Integer sentimentLongestF, List<IMWE<IToken>> imwesF, Integer inflectedCounterNegativeF, Integer inflectedCounterPositiveF, ArrayList<String> tokenEntryF, Integer unmarkedPatternCounterF, ArrayList<String> strTokensIpartFormF, ArrayList<String> tokenFormsF, ArrayList<Integer> intTokenEntyCountsF, Integer markedContinuousCounterF, ArrayList<String> iTokenTagsF, ArrayList<String> strTokenEntryGetPOSF, ArrayList<String> retrieveTGWListF, Integer pairCounterF, Integer tokensCounterF, ArrayList<String> stopWordLemmaF, ArrayList<String> nerEntitiesF, ArrayList<String> stopWordTokenF, ArrayList<String> entityTokenTagsF, ArrayList<String> nerEntitiesTypeF, Integer anotatorcounterF, ArrayList<String> strTokenStemsF) {
|
||||
|
||||
this.strF = strF;
|
||||
this.str1 = str1;
|
||||
this.stanfordCoreNLP = stanfordCoreNLP;
|
||||
this.stanfordCoreNLPSentiment = stanfordCoreNLPSentiment;
|
||||
this.coreMaps1 = coreMaps1;
|
||||
this.strAnno = strAnno;
|
||||
this.strAnnoSentiment = strAnnoSentiment;
|
||||
this.coreDocument = coreDocument;
|
||||
this.tokenizeCountingF = tokenizeCountingF;
|
||||
this.taggedWordListF = taggedWordListF;
|
||||
this.typedDependenciesF = typedDependenciesF;
|
||||
this.rnnCoreAnnotationsPredictedF = rnnCoreAnnotationsPredictedF;
|
||||
this.simpleMatricesF = simpleMatricesF;
|
||||
this.simpleMatricesNodevectorsF = simpleMatricesNodevectorsF;
|
||||
this.listF = listF;
|
||||
this.longestF = longestF;
|
||||
this.sentencesF = sentencesF;
|
||||
this.sentencesSentimentF = sentencesSentimentF;
|
||||
this.treesF = treesF;
|
||||
this.grammaticalStructuresF = grammaticalStructuresF;
|
||||
this.sentimentLongestF = sentimentLongestF;
|
||||
this.imwesF = imwesF;
|
||||
this.inflectedCounterNegativeF = inflectedCounterNegativeF;
|
||||
this.inflectedCounterPositiveF = inflectedCounterPositiveF;
|
||||
this.tokenEntryF = tokenEntryF;
|
||||
this.unmarkedPatternCounterF = unmarkedPatternCounterF;
|
||||
this.strTokensIpartFormF = strTokensIpartFormF;
|
||||
this.tokenFormsF = tokenFormsF;
|
||||
this.intTokenEntyCountsF = intTokenEntyCountsF;
|
||||
this.markedContinuousCounterF = markedContinuousCounterF;
|
||||
this.iTokenTagsF = iTokenTagsF;
|
||||
this.strTokenEntryGetPOSF = strTokenEntryGetPOSF;
|
||||
this.retrieveTGWListF = retrieveTGWListF;
|
||||
this.pairCounterF = pairCounterF;
|
||||
this.tokensCounterF = tokensCounterF;
|
||||
this.stopWordLemmaF = stopWordLemmaF;
|
||||
this.nerEntitiesF = nerEntitiesF;
|
||||
this.stopWordTokenF = stopWordTokenF;
|
||||
this.entityTokenTagsF = entityTokenTagsF;
|
||||
this.nerEntitiesTypeF = nerEntitiesTypeF;
|
||||
this.anotatorcounterF = anotatorcounterF;
|
||||
this.strTokenStemsF = strTokenStemsF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SentimentAnalyzerTest call() throws Exception {
|
||||
return getReponseFuturesHelper(strF, str1, stanfordCoreNLP, stanfordCoreNLPSentiment,
|
||||
coreMaps1, strAnno, strAnnoSentiment, coreDocument, tokenizeCountingF, taggedWordListF
|
||||
, typedDependenciesF, rnnCoreAnnotationsPredictedF, simpleMatricesF, simpleMatricesNodevectorsF
|
||||
, listF, longestF, sentencesF, sentencesSentimentF, treesF, grammaticalStructuresF, sentimentLongestF
|
||||
, imwesF, inflectedCounterNegativeF, inflectedCounterPositiveF, tokenEntryF, unmarkedPatternCounterF
|
||||
, strTokensIpartFormF, tokenFormsF, intTokenEntyCountsF, markedContinuousCounterF, iTokenTagsF
|
||||
, strTokenEntryGetPOSF, retrieveTGWListF, pairCounterF, tokensCounterF, stopWordLemmaF, nerEntitiesF
|
||||
, stopWordTokenF, entityTokenTagsF, nerEntitiesTypeF, anotatorcounterF, strTokenStemsF);
|
||||
}
|
||||
}
|
||||
|
||||
public String getResponseFutures(String strF, StanfordCoreNLP stanfordCoreNLP, StanfordCoreNLP stanfordCoreNLPSentiment) {
|
||||
if (strResponses.getOrDefault(strF, null) == null) {
|
||||
strResponses.put(strF, new ArrayList<>());
|
||||
@@ -463,127 +570,152 @@ public class Datahandler {
|
||||
StringBuilder SB = new StringBuilder();
|
||||
List<String> ues_copy = new ArrayList(DataMapper.getAllStrings());
|
||||
double preRelationUserCounters = -155000.0;
|
||||
|
||||
//System.out.println(ues_copy.toString());
|
||||
ArrayList<Future<SentimentAnalyzerTest>> futures = new ArrayList<>();
|
||||
|
||||
for (String str1 : ues_copy) {
|
||||
if (strF != str1) {
|
||||
SentimentAnalyzerTest SMX = getReponseFuturesHelper(strF, str1, stanfordCoreNLP, stanfordCoreNLPSentiment,
|
||||
|
||||
//critical section
|
||||
Future<SentimentAnalyzerTest> submit = completionService.submit(new get_res(strF, str1, stanfordCoreNLP, stanfordCoreNLPSentiment,
|
||||
coreMaps1, strAnno, strAnnoSentiment, coreDocument, tokenizeCountingF, taggedWordListF
|
||||
, typedDependenciesF, rnnCoreAnnotationsPredictedF, simpleMatricesF, simpleMatricesNodevectorsF
|
||||
, listF, longestF, sentencesF, sentencesSentimentF, treesF, grammaticalStructuresF, sentimentLongestF
|
||||
, imwesF, InflectedCounterNegativeF, InflectedCounterPositiveF, tokenEntryF, UnmarkedPatternCounterF
|
||||
, strTokensIpartFormF, tokenFormsF, intTokenEntyCountsF, MarkedContinuousCounterF, ITokenTagsF
|
||||
, strTokenEntryGetPOSF, retrieveTGWListF, PairCounterF, TokensCounterF, stopWordLemmaF, nerEntitiesF
|
||||
, stopWordTokenF, entityTokenTagsF, nerEntitiesTypeF, AnotatorcounterF, strTokenStemsF);
|
||||
if (tokenizeCountingF == null) {
|
||||
tokenizeCountingF = SMX.getTokenizeCountingF();
|
||||
}
|
||||
if (taggedWordListF == null) {
|
||||
taggedWordListF = SMX.getTaggedWordListF();
|
||||
}
|
||||
if (typedDependenciesF == null) {
|
||||
typedDependenciesF = SMX.getTypedDependenciesF();
|
||||
}
|
||||
if (rnnCoreAnnotationsPredictedF == null) {
|
||||
rnnCoreAnnotationsPredictedF = SMX.getRnnCoreAnnotationsPredictedF();
|
||||
}
|
||||
if (simpleMatricesF == null) {
|
||||
simpleMatricesF = SMX.getSimpleMatricesF();
|
||||
}
|
||||
if (simpleMatricesNodevectorsF == null) {
|
||||
simpleMatricesNodevectorsF = SMX.getSimpleMatricesNodevectorsF();
|
||||
}
|
||||
if (listF == null) {
|
||||
listF = SMX.getListF();
|
||||
}
|
||||
if (longestF == null) {
|
||||
longestF = SMX.getLongestF();
|
||||
}
|
||||
if (sentencesF == null) {
|
||||
sentencesF = SMX.getSentencesF();
|
||||
}
|
||||
if (sentencesSentimentF == null) {
|
||||
sentencesSentimentF = SMX.getSentencesSentimentF();
|
||||
}
|
||||
if (treesF == null) {
|
||||
treesF = SMX.getTreesF();
|
||||
}
|
||||
if (grammaticalStructuresF == null) {
|
||||
grammaticalStructuresF = SMX.getGrammaticalStructuresF();
|
||||
}
|
||||
if (sentimentLongestF == null) {
|
||||
sentimentLongestF = SMX.getSentimentLongestF();
|
||||
}
|
||||
if (imwesF == null) {
|
||||
imwesF = SMX.getImwesF();
|
||||
}
|
||||
if (InflectedCounterNegativeF == null) {
|
||||
InflectedCounterNegativeF = SMX.getInflectedCounterNegativeF();
|
||||
}
|
||||
if (InflectedCounterPositiveF == null) {
|
||||
InflectedCounterPositiveF = SMX.getInflectedCounterPositiveF();
|
||||
}
|
||||
if (tokenEntryF == null) {
|
||||
tokenEntryF = SMX.getTokenEntryF();
|
||||
}
|
||||
if (UnmarkedPatternCounterF == null) {
|
||||
UnmarkedPatternCounterF = SMX.getUnmarkedPatternCounterF();
|
||||
}
|
||||
if (strTokensIpartFormF == null) {
|
||||
strTokensIpartFormF = SMX.getStrTokensIpartFormF();
|
||||
}
|
||||
if (tokenFormsF == null) {
|
||||
tokenFormsF = SMX.getTokenFormsF();
|
||||
}
|
||||
if (intTokenEntyCountsF == null) {
|
||||
intTokenEntyCountsF = SMX.getIntTokenEntyCountsF();
|
||||
}
|
||||
if (MarkedContinuousCounterF == null) {
|
||||
MarkedContinuousCounterF = SMX.getMarkedContinuousCounterF();
|
||||
}
|
||||
if (ITokenTagsF == null) {
|
||||
ITokenTagsF = SMX.getITokenTagsF();
|
||||
}
|
||||
if (strTokenEntryGetPOSF == null) {
|
||||
strTokenEntryGetPOSF = SMX.getStrTokenEntryGetPOSF();
|
||||
}
|
||||
if (retrieveTGWListF == null) {
|
||||
retrieveTGWListF = SMX.getRetrieveTGWListF();
|
||||
}
|
||||
if (PairCounterF == null) {
|
||||
PairCounterF = SMX.getPairCounterF();
|
||||
}
|
||||
if (TokensCounterF == null) {
|
||||
TokensCounterF = SMX.getTokensCounterF();
|
||||
}
|
||||
if (stopWordLemmaF == null) {
|
||||
stopWordLemmaF = SMX.getStopWordLemmaF();
|
||||
}
|
||||
if (nerEntitiesF == null) {
|
||||
nerEntitiesF = SMX.getNerEntitiesF();
|
||||
}
|
||||
if (stopWordTokenF == null) {
|
||||
stopWordTokenF = SMX.getStopWordTokenF();
|
||||
}
|
||||
if (entityTokenTagsF == null) {
|
||||
entityTokenTagsF = SMX.getEntityTokenTagsF();
|
||||
}
|
||||
if (nerEntitiesTypeF == null) {
|
||||
nerEntitiesTypeF = SMX.getNerEntitiesTypeF();
|
||||
}
|
||||
if (AnotatorcounterF == null) {
|
||||
AnotatorcounterF = SMX.getAnotatorcounterF();
|
||||
}
|
||||
if (strTokenStemsF == null) {
|
||||
strTokenStemsF = SMX.getStrTokenStemsF();
|
||||
}
|
||||
|
||||
SimilarityMatrix getSMX = SMX.callSMX();
|
||||
double scoreRelationLastUserMsg = getSMX.getDistance();
|
||||
if (scoreRelationLastUserMsg > preRelationUserCounters) {
|
||||
preRelationUserCounters = scoreRelationLastUserMsg;
|
||||
concurrentRelations.add(getSMX.getSecondaryString());
|
||||
}
|
||||
, stopWordTokenF, entityTokenTagsF, nerEntitiesTypeF, AnotatorcounterF, strTokenStemsF));
|
||||
futures.add(submit);
|
||||
//end of critical section, do the rest sequential.
|
||||
}
|
||||
}
|
||||
|
||||
int pending = futures.size();
|
||||
while (pending > 0) {
|
||||
try {
|
||||
Future<SentimentAnalyzerTest> completed = completionService.poll(100, TimeUnit.MILLISECONDS);
|
||||
if (completed != null) {
|
||||
--pending;
|
||||
SentimentAnalyzerTest SMX = completed.get();
|
||||
if (SMX == null) continue;
|
||||
double scoreRelationLastUserMsg = SMX.getScore();
|
||||
if (scoreRelationLastUserMsg > preRelationUserCounters) {
|
||||
preRelationUserCounters = scoreRelationLastUserMsg;
|
||||
concurrentRelations.add(SMX.getSecondaryString());
|
||||
}
|
||||
|
||||
//this part below should be sequential hopefully
|
||||
if (tokenizeCountingF == null) {
|
||||
tokenizeCountingF = SMX.getTokenizeCountingF();
|
||||
}
|
||||
if (taggedWordListF == null) {
|
||||
taggedWordListF = SMX.getTaggedWordListF();
|
||||
}
|
||||
if (typedDependenciesF == null) {
|
||||
typedDependenciesF = SMX.getTypedDependenciesF();
|
||||
}
|
||||
if (rnnCoreAnnotationsPredictedF == null) {
|
||||
rnnCoreAnnotationsPredictedF = SMX.getRnnCoreAnnotationsPredictedF();
|
||||
}
|
||||
if (simpleMatricesF == null) {
|
||||
simpleMatricesF = SMX.getSimpleMatricesF();
|
||||
}
|
||||
if (simpleMatricesNodevectorsF == null) {
|
||||
simpleMatricesNodevectorsF = SMX.getSimpleMatricesNodevectorsF();
|
||||
}
|
||||
if (listF == null) {
|
||||
listF = SMX.getListF();
|
||||
}
|
||||
if (longestF == null) {
|
||||
longestF = SMX.getLongestF();
|
||||
}
|
||||
if (sentencesF == null) {
|
||||
sentencesF = SMX.getSentencesF();
|
||||
}
|
||||
if (sentencesSentimentF == null) {
|
||||
sentencesSentimentF = SMX.getSentencesSentimentF();
|
||||
}
|
||||
if (treesF == null) {
|
||||
treesF = SMX.getTreesF();
|
||||
}
|
||||
if (grammaticalStructuresF == null) {
|
||||
grammaticalStructuresF = SMX.getGrammaticalStructuresF();
|
||||
}
|
||||
if (sentimentLongestF == null) {
|
||||
sentimentLongestF = SMX.getSentimentLongestF();
|
||||
}
|
||||
if (imwesF == null) {
|
||||
imwesF = SMX.getImwesF();
|
||||
}
|
||||
if (InflectedCounterNegativeF == null) {
|
||||
InflectedCounterNegativeF = SMX.getInflectedCounterNegativeF();
|
||||
}
|
||||
if (InflectedCounterPositiveF == null) {
|
||||
InflectedCounterPositiveF = SMX.getInflectedCounterPositiveF();
|
||||
}
|
||||
if (tokenEntryF == null) {
|
||||
tokenEntryF = SMX.getTokenEntryF();
|
||||
}
|
||||
if (UnmarkedPatternCounterF == null) {
|
||||
UnmarkedPatternCounterF = SMX.getUnmarkedPatternCounterF();
|
||||
}
|
||||
if (strTokensIpartFormF == null) {
|
||||
strTokensIpartFormF = SMX.getStrTokensIpartFormF();
|
||||
}
|
||||
if (tokenFormsF == null) {
|
||||
tokenFormsF = SMX.getTokenFormsF();
|
||||
}
|
||||
if (intTokenEntyCountsF == null) {
|
||||
intTokenEntyCountsF = SMX.getIntTokenEntyCountsF();
|
||||
}
|
||||
if (MarkedContinuousCounterF == null) {
|
||||
MarkedContinuousCounterF = SMX.getMarkedContinuousCounterF();
|
||||
}
|
||||
if (ITokenTagsF == null) {
|
||||
ITokenTagsF = SMX.getITokenTagsF();
|
||||
}
|
||||
if (strTokenEntryGetPOSF == null) {
|
||||
strTokenEntryGetPOSF = SMX.getStrTokenEntryGetPOSF();
|
||||
}
|
||||
if (retrieveTGWListF == null) {
|
||||
retrieveTGWListF = SMX.getRetrieveTGWListF();
|
||||
}
|
||||
if (PairCounterF == null) {
|
||||
PairCounterF = SMX.getPairCounterF();
|
||||
}
|
||||
if (TokensCounterF == null) {
|
||||
TokensCounterF = SMX.getTokensCounterF();
|
||||
}
|
||||
if (stopWordLemmaF == null) {
|
||||
stopWordLemmaF = SMX.getStopWordLemmaF();
|
||||
}
|
||||
if (nerEntitiesF == null) {
|
||||
nerEntitiesF = SMX.getNerEntitiesF();
|
||||
}
|
||||
if (stopWordTokenF == null) {
|
||||
stopWordTokenF = SMX.getStopWordTokenF();
|
||||
}
|
||||
if (entityTokenTagsF == null) {
|
||||
entityTokenTagsF = SMX.getEntityTokenTagsF();
|
||||
}
|
||||
if (nerEntitiesTypeF == null) {
|
||||
nerEntitiesTypeF = SMX.getNerEntitiesTypeF();
|
||||
}
|
||||
if (AnotatorcounterF == null) {
|
||||
AnotatorcounterF = SMX.getAnotatorcounterF();
|
||||
}
|
||||
if (strTokenStemsF == null) {
|
||||
strTokenStemsF = SMX.getStrTokenStemsF();
|
||||
}
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
int cacheRequirement = 8500;
|
||||
if (preRelationUserCounters > cacheRequirement && !ues_copy.contains(strF) && filterContent(strF)) {
|
||||
DataMapper.InsertMYSQLStrings(strF);
|
||||
@@ -608,7 +740,7 @@ public class Datahandler {
|
||||
strResponses.put(strF, orDefault);
|
||||
} else if (orDefault.size() > 5) {
|
||||
double v = Math.random() * 10;
|
||||
if (v > 8.6) {
|
||||
if (v > 5.6) {
|
||||
orDefault = new ArrayList<>();
|
||||
strResponses.put(strF, orDefault);
|
||||
}
|
||||
@@ -628,8 +760,7 @@ public class Datahandler {
|
||||
, strTokensIpartFormF, tokenFormsF, intTokenEntyCountsF, MarkedContinuousCounterF, ITokenTagsF
|
||||
, strTokenEntryGetPOSF, retrieveTGWListF, PairCounterF, TokensCounterF, stopWordLemmaF, nerEntitiesF
|
||||
, stopWordTokenF, entityTokenTagsF, nerEntitiesTypeF, AnotatorcounterF, strTokenStemsF);
|
||||
SimilarityMatrix getSMX = SMX.callSMX();
|
||||
double scoreRelationLastUserMsg = getSMX.getDistance();
|
||||
double scoreRelationLastUserMsg = SMX.getScore();
|
||||
if (preRelationUserCounters > scoreRelationLastUserMsg) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -14,14 +14,6 @@ public class SimilarityMatrix {
|
||||
private String SecondaryString;
|
||||
private double distance;
|
||||
|
||||
public final double getDistance() {
|
||||
return distance;
|
||||
}
|
||||
|
||||
public final void setDistance(double distance) {
|
||||
this.distance = distance;
|
||||
}
|
||||
|
||||
public SimilarityMatrix(String str1, String str2) {
|
||||
this.PrimaryString = str1;
|
||||
this.SecondaryString = str2;
|
||||
|
||||
+36
-20
@@ -38,6 +38,7 @@ import edu.stanford.nlp.util.Pair;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.logging.FileHandler;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.SimpleFormatter;
|
||||
@@ -56,20 +57,19 @@ import org.ejml.simple.SimpleMatrix;
|
||||
*/
|
||||
public class SentimentAnalyzerTest {
|
||||
|
||||
private final SimilarityMatrix smxParam;
|
||||
private final String str;
|
||||
private final String str1;
|
||||
private final MaxentTagger tagger;
|
||||
private final GrammaticalStructureFactory gsf;
|
||||
private final AbstractSequenceClassifier classifier;
|
||||
private final List<CoreMap> coreMaps1;
|
||||
private final List<CoreMap> coreMaps2;
|
||||
private final Annotation pipelineAnnotation1;
|
||||
private final Annotation pipelineAnnotation2;
|
||||
private final Annotation pipelineAnnotation1Sentiment;
|
||||
private final Annotation pipelineAnnotation2Sentiment;
|
||||
private final CoreDocument pipelineCoreDcoument1;
|
||||
private final CoreDocument pipelineCoreDcoument2;
|
||||
private String str;
|
||||
private String str1;
|
||||
private MaxentTagger tagger;
|
||||
private GrammaticalStructureFactory gsf;
|
||||
private AbstractSequenceClassifier classifier;
|
||||
private List<CoreMap> coreMaps1;
|
||||
private List<CoreMap> coreMaps2;
|
||||
private Annotation pipelineAnnotation1;
|
||||
private Annotation pipelineAnnotation2;
|
||||
private Annotation pipelineAnnotation1Sentiment;
|
||||
private Annotation pipelineAnnotation2Sentiment;
|
||||
private CoreDocument pipelineCoreDcoument1;
|
||||
private CoreDocument pipelineCoreDcoument2;
|
||||
//private loggerlogger =logger.getLogger("autismlog");
|
||||
private FileHandler fh;
|
||||
|
||||
@@ -415,8 +415,17 @@ public class SentimentAnalyzerTest {
|
||||
private ArrayList<String> stopWordLemma1;
|
||||
private Integer PairCounterF;
|
||||
private Integer PairCounter1;
|
||||
private Double score_res;
|
||||
|
||||
public SentimentAnalyzerTest(String str, String str1, SimilarityMatrix smxParam, List<CoreMap> coreMaps1, List<CoreMap> coreMaps2,
|
||||
public Double getScore(){
|
||||
return score_res;
|
||||
}
|
||||
|
||||
public String getSecondaryString(){
|
||||
return this.str1;
|
||||
}
|
||||
|
||||
public SentimentAnalyzerTest(String str, String str1, List<CoreMap> coreMaps1, List<CoreMap> coreMaps2,
|
||||
Annotation strPipeline1, Annotation strPipeline2, Annotation strPipeSentiment1, Annotation strPipeSentiment2,
|
||||
CoreDocument pipelineCoreDcoument1, CoreDocument pipelineCoreDcoument2,
|
||||
MaxentTagger tagger, GrammaticalStructureFactory gsf,
|
||||
@@ -462,7 +471,6 @@ public class SentimentAnalyzerTest {
|
||||
Integer PairCounter1) {
|
||||
this.str = str;
|
||||
this.str1 = str1;
|
||||
this.smxParam = smxParam;
|
||||
this.tagger = tagger;
|
||||
this.gsf = gsf;
|
||||
this.classifier = classifier;
|
||||
@@ -542,6 +550,7 @@ public class SentimentAnalyzerTest {
|
||||
this.stopWordLemma1 = stopWordLemma1;
|
||||
this.PairCounterF = PairCounterF;
|
||||
this.PairCounter1 = PairCounter1;
|
||||
this.score_res = callSMX();
|
||||
}
|
||||
|
||||
private List<List<TaggedWord>> getTaggedWordList(String message) {
|
||||
@@ -550,7 +559,11 @@ public class SentimentAnalyzerTest {
|
||||
TokenizerFactory<CoreLabel> ptbTokenizerFactory = PTBTokenizer.factory(new CoreLabelTokenFactory(), "untokenizable=noneDelete"); //noneDelete //firstDelete
|
||||
tokenizer.setTokenizerFactory(ptbTokenizerFactory);
|
||||
for (final List<HasWord> sentence : tokenizer) {
|
||||
taggedwordlist.add(tagger.tagSentence(sentence));
|
||||
try {
|
||||
taggedwordlist.add(tagger.tagSentence(sentence));
|
||||
} catch (Exception ex) {
|
||||
System.out.println("crashed in tagger.tagsentence");
|
||||
}
|
||||
}
|
||||
return taggedwordlist;
|
||||
}
|
||||
@@ -2257,6 +2270,7 @@ public class SentimentAnalyzerTest {
|
||||
|
||||
|
||||
public void validateStringCaches() {
|
||||
|
||||
Class<SentimentCoreAnnotations.SentimentAnnotatedTree> sentimentAnnotatedTreeClass =
|
||||
SentimentCoreAnnotations.SentimentAnnotatedTree.class;
|
||||
|
||||
@@ -2471,7 +2485,8 @@ public class SentimentAnalyzerTest {
|
||||
}
|
||||
|
||||
|
||||
public SimilarityMatrix callSMX() {
|
||||
public Double callSMX() {
|
||||
|
||||
Double score = -100.0;
|
||||
|
||||
/*
|
||||
@@ -2566,7 +2581,8 @@ public class SentimentAnalyzerTest {
|
||||
score = stopwordTokenPairCounterScoring(score, this.stopWordTokenF, this.stopWordToken1,
|
||||
this.PairCounterF, this.PairCounter1);
|
||||
//logger.info("score post stopwordTokenPairCounterScoring " + score);
|
||||
smxParam.setDistance(score);
|
||||
return smxParam;
|
||||
|
||||
return score;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user