calculation updates

This commit is contained in:
jenzur 2019-04-02 00:59:23 +02:00
parent d788d76ac6
commit 276730418d

View File

@ -171,6 +171,8 @@ public class SentimentAnalyzerTest implements Callable<SimilarityMatrix> {
}
GrammaticalStructure gs1 = gsf.newGrammaticalStructure(sentenceConstituencyParse1);
Collection<TypedDependency> allTypedDependencies1 = gs1.allTypedDependencies();
int relationApplicable1 = 0;
int relationApplicable2 = 0;
for (TypedDependency TDY1 : allTypedDependencies1) {
IndexedWord dep = TDY1.dep();
IndexedWord gov = TDY1.gov();
@ -181,6 +183,7 @@ public class SentimentAnalyzerTest implements Callable<SimilarityMatrix> {
GrammaticalRelation reln = TDY1.reln();
if (reln.isApplicable(sentenceConstituencyParse)) {
score += 525;
relationApplicable1++;
}
}
for (TypedDependency TDY : allTypedDependencies) {
@ -193,6 +196,16 @@ public class SentimentAnalyzerTest implements Callable<SimilarityMatrix> {
GrammaticalRelation reln = TDY.reln();
if (reln.isApplicable(sentenceConstituencyParse1)) {
score += 525;
relationApplicable2++;
}
}
if (!allTypedDependencies.isEmpty() || !allTypedDependencies1.isEmpty()) {
if (relationApplicable1 > 0 && relationApplicable2 > 0) {
score += 3500;
} else {
score -= allTypedDependencies.size() > allTypedDependencies1.size()
? (allTypedDependencies.size() - allTypedDependencies1.size()) * (allTypedDependencies.size() * 160)
: (allTypedDependencies1.size() - allTypedDependencies.size()) * (allTypedDependencies1.size() * 160);
}
}
AtomicInteger runCount1 = new AtomicInteger(0);
@ -233,37 +246,37 @@ public class SentimentAnalyzerTest implements Callable<SimilarityMatrix> {
SimpleMatrix nodeVector = RNNCoreAnnotations.getNodeVector(tree);
ConcurrentMap<Integer, Double> AccumulateDotMap = new MapMaker().concurrencyLevel(2).makeMap();
ConcurrentMap<Integer, Double> subtractorMap = new MapMaker().concurrencyLevel(2).makeMap();
score += simpleSMXlist.values().stream().map(new Function<SimpleMatrix, Double>() {
@Override
public Double apply(SimpleMatrix simpleSMX) {
return predictions.dot(simpleSMX) * 100;
}
}).map(new Function<Double, Double>() {
@Override
public Double apply(Double dot) {
AccumulateDotMap.put(AccumulateDotMap.size() + 1, dot);
return dot > 50 ? dot - 100 : dot > 0 ? 100 - dot : 0;
}
}).map((subtracter) -> {
ConcurrentMap<Integer, Double> dotPredictions = new MapMaker().concurrencyLevel(2).makeMap();
Double largest = 10.0;
Double shortest = 100.0;
for (SimpleMatrix simpleSMX : simpleSMXlist.values()) {
double dotPrediction = predictions.dot(simpleSMX) * 100;
AccumulateDotMap.put(AccumulateDotMap.size() + 1, dotPrediction);
double subtracter = dotPrediction > 50 ? dotPrediction - 100 : dotPrediction > 0 ? 100 - dotPrediction : 0;
subtractorMap.put(subtractorMap.size() + 1, subtracter);
subtracter *= 25; //25
return subtracter;
}).map(new Function<Double, Double>() {
@Override
public Double apply(Double subtracter) {
return subtracter;
}
}).reduce(score, new BinaryOperator<Double>() {
@Override
public Double apply(Double accumulator, Double _item) {
int accumulator1 = 0;
while (accumulator < 0) {
accumulator++;
accumulator1++;
if (!dotPredictions.values().contains(dotPrediction)) {
if (dotPrediction > largest) {
largest = dotPrediction;
}
return accumulator1 + _item;
if (dotPrediction < shortest) {
shortest = dotPrediction;
}
Double dotPredictionIntervalDifference = largest - shortest;
subtracter *= 25;
if (dotPredictionIntervalDifference < 5.0) {
if (dotPredictions.values().size() > 0) {
score += subtracter;
}
} else {
score -= subtracter;
}
} else {
subtracter -= 100;
subtracter *= 25;
score += subtracter * dotPrediction;
}
});
dotPredictions.put(dotPredictions.size() + 1, dotPrediction);
}
Double subTracPre = 0.0;
for (Double subtractors : subtractorMap.values()) {
if (Objects.equals(subTracPre, subtractors)) {
@ -271,41 +284,37 @@ public class SentimentAnalyzerTest implements Callable<SimilarityMatrix> {
}
subTracPre = subtractors;
}
score += simpleSMXlist.values().stream().map(new Function<SimpleMatrix, Double>() {
@Override
public Double apply(SimpleMatrix simpleSMX) {
return simpleSMX.dot(predictions) * 100;
}
}).map(new Function<Double, Double>() {
@Override
public Double apply(Double dot) {
AccumulateDotMap.put(AccumulateDotMap.size() + 1, dot);
return dot > 50 ? dot - 50 : dot > 0 ? 50 - dot : 0;
}
}).map((subtracter) -> {
subtracter *= 25; //25
return subtracter;
}).map(new Function<Double, Double>() {
@Override
public Double apply(Double subtracter) {
return subtracter;
}
}).reduce(score, new BinaryOperator<Double>() {
@Override
public Double apply(Double accumulator, Double _item) {
int accumulator1 = 0;
while (accumulator < 0) {
accumulator++;
accumulator1++;
ConcurrentMap<Integer, Double> DotOverTransfer = dotPredictions;
dotPredictions = new MapMaker().concurrencyLevel(2).makeMap();
for (SimpleMatrix simpleSMX : simpleSMXlist.values()) {
double dotPrediction = simpleSMX.dot(predictions) * 100;
AccumulateDotMap.put(AccumulateDotMap.size() + 1, dotPrediction);
double subtracter = dotPrediction > 50 ? dotPrediction - 100 : dotPrediction > 0 ? 100 - dotPrediction : 0;
subtractorMap.put(subtractorMap.size() + 1, subtracter);
if (!dotPredictions.values().contains(dotPrediction)) {
subtracter *= 25;
int match = 0;
for (Double transferDots : DotOverTransfer.values()) {
if (transferDots == dotPrediction) {
score += subtracter;
match++;
}
}
return accumulator1 + _item;
if (match == 0) {
score -= subtracter;
}
} else {
subtracter -= 100;
subtracter *= 25;
score += subtracter * dotPrediction;
}
});
dotPredictions.put(dotPredictions.size() + 1, dotPrediction);
}
Double preAccumulatorDot = 0.0;
Double postAccumulatorDot = 0.0;
for (Double accumulators : AccumulateDotMap.values()) {
if (preAccumulatorDot == accumulators) {
if (postAccumulatorDot == accumulators) {
if (Objects.equals(preAccumulatorDot, accumulators)) {
if (Objects.equals(postAccumulatorDot, accumulators)) {
score -= 4000;
}
postAccumulatorDot = accumulators;
@ -334,7 +343,9 @@ public class SentimentAnalyzerTest implements Callable<SimilarityMatrix> {
elementSum = Math.round(elementSum * 100.0) / 100.0;
elementSumCounter.put(elementSumCounter.size() + 1, elementSum);
dotMap.put(dotMap.size() + 1, dot);
if (dot < 0.1) {
if (dot < 0.000) {
score += dot * 1500;
} else if (dot < 0.1) {
score += 256;
}
if (dot > 0.50) {
@ -438,11 +449,13 @@ public class SentimentAnalyzerTest implements Callable<SimilarityMatrix> {
if (deffLongest > deffshorter * 5) {
score -= 5500;
} else if (deffLongest < (deffshorter * 2) - 1 && deffLongest - deffshorter <= 45) {
score += (deffLongest - deffshorter) * 120;
score += (deffLongest - deffshorter) * 60;
} else if (mainSentiment1 != mainSentiment2 && deffLongest - deffshorter > 20 && deffLongest - deffshorter < 45) {
score += (deffLongest - deffshorter) * 120;
} else if (deffLongest - deffshorter < 2) {
score += (deffLongest + deffshorter) * 40;
} else if (deffshorter * 2 >= deffLongest && deffshorter * 2 < deffLongest + 5) {
score += deffLongest * 160;
} else {
score -= (deffLongest - deffshorter) * 50;
}
@ -459,6 +472,8 @@ public class SentimentAnalyzerTest implements Callable<SimilarityMatrix> {
int inflectedCounterNegative = 0;
int MarkedContinuousCounter1 = 0;
int MarkedContinuousCounter2 = 0;
Integer MarkedContiniousCounter1Entries = 0;
Integer MarkedContiniousCounter2Entries = 0;
int UnmarkedPatternCounter = 0;
ConcurrentMap<Integer, String> ITokenMapTag1 = new MapMaker().concurrencyLevel(2).makeMap();
ConcurrentMap<Integer, String> ITokenMapTag2 = new MapMaker().concurrencyLevel(2).makeMap();
@ -497,6 +512,7 @@ public class SentimentAnalyzerTest implements Callable<SimilarityMatrix> {
ITokenMapTag1.put(ITokenMapTag1.size() + 1, tokens.getTag());
for (String strtoken : tokens.getStems()) {
strTokenStems1.put(strTokenStems1.size() + 1, strtoken);
MarkedContiniousCounter1Entries++;
}
}
tokensCounter1++;
@ -527,6 +543,7 @@ public class SentimentAnalyzerTest implements Callable<SimilarityMatrix> {
ITokenMapTag2.put(ITokenMapTag2.size() + 1, tokens.getTag());
for (String strtoken : tokens.getStems()) {
strTokenStems2.put(strTokenStems2.size() + 1, strtoken);
MarkedContiniousCounter2Entries++;
}
}
tokensCounter2++;
@ -544,11 +561,18 @@ public class SentimentAnalyzerTest implements Callable<SimilarityMatrix> {
}
}
if (UnmarkedPatternCounter > 0 && UnmarkedPatternCounter < 5) {
score += UnmarkedPatternCounter * 1600;
score -= UnmarkedPatternCounter * 1600;
}
if (MarkedContinuousCounter1 > 0 && MarkedContinuousCounter2 > 0) {
score += MarkedContinuousCounter1 > MarkedContinuousCounter2 ? (MarkedContinuousCounter1 - MarkedContinuousCounter2) * 500
: (MarkedContinuousCounter2 - MarkedContinuousCounter1) * 500;
if (!Objects.equals(MarkedContiniousCounter1Entries, MarkedContiniousCounter2Entries)
&& (MarkedContinuousCounter1 * 2 >= MarkedContinuousCounter2 * MarkedContinuousCounter1)
|| (MarkedContinuousCounter2 * 2 >= MarkedContinuousCounter1 * MarkedContinuousCounter2)) {
score += MarkedContinuousCounter1 > MarkedContinuousCounter2 ? (MarkedContinuousCounter1 - MarkedContinuousCounter2) * 500
: (MarkedContinuousCounter2 - MarkedContinuousCounter1) * 500;
} else {
score += MarkedContinuousCounter1 > MarkedContinuousCounter2 ? (MarkedContinuousCounter2 - MarkedContinuousCounter1) * 500
: (MarkedContinuousCounter1 - MarkedContinuousCounter2) * 500;
}
}
for (String strTokeniPart1 : strTokenGetiPart1.values()) {
for (String strTokeniPart2 : strTokenGetiPart2.values()) {
@ -602,8 +626,6 @@ public class SentimentAnalyzerTest implements Callable<SimilarityMatrix> {
int elseint = tokensCounter1 >= tokensCounter2 ? (tokensCounter1 - tokensCounter2) * 500 : (tokensCounter2 - tokensCounter1) * 500;
if (elseint > 0) {
score -= elseint * 2;
} else {
score -= 1500;
}
}
LevenshteinDistance leven = new LevenshteinDistance(str, str1);