package FunctionLayer.StanfordParser;

import FunctionLayer.LevenshteinDistance;
import FunctionLayer.SimilarityMatrix;
import FunctionLayer.StopwordAnnotator;
import edu.mit.jmwe.data.IMWE;
import edu.mit.jmwe.data.IMWEDesc;
import edu.mit.jmwe.data.IToken;
import edu.stanford.nlp.ie.AbstractSequenceClassifier;
import edu.stanford.nlp.ling.CoreAnnotations;
import edu.stanford.nlp.ling.CoreLabel;
import edu.stanford.nlp.ling.HasWord;
import edu.stanford.nlp.ling.IndexedWord;
import edu.stanford.nlp.ling.JMWEAnnotation;
import edu.stanford.nlp.ling.TaggedWord;
import edu.stanford.nlp.neural.rnn.RNNCoreAnnotations;
import edu.stanford.nlp.pipeline.Annotation;
import edu.stanford.nlp.pipeline.CoreDocument;
import edu.stanford.nlp.pipeline.CoreEntityMention;
import edu.stanford.nlp.process.CoreLabelTokenFactory;
import edu.stanford.nlp.process.DocumentPreprocessor;
import edu.stanford.nlp.process.PTBTokenizer;
import edu.stanford.nlp.process.TokenizerFactory;
import edu.stanford.nlp.sentiment.SentimentCoreAnnotations;
import edu.stanford.nlp.sequences.DocumentReaderAndWriter;
import edu.stanford.nlp.tagger.maxent.MaxentTagger;
import edu.stanford.nlp.trees.Constituent;
import edu.stanford.nlp.trees.GrammaticalRelation;
import edu.stanford.nlp.trees.GrammaticalStructure;
import edu.stanford.nlp.trees.GrammaticalStructureFactory;
import edu.stanford.nlp.trees.Tree;
import edu.stanford.nlp.trees.TreeCoreAnnotations;
import edu.stanford.nlp.trees.TypedDependency;
import edu.stanford.nlp.trees.tregex.gui.Tdiff;
import edu.stanford.nlp.util.CoreMap;
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;

import org.apache.lucene.analysis.core.StopAnalyzer;
import org.ejml.simple.SimpleMatrix;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * @author install1
 */
public class SentimentAnalyzerTest {

    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;

    public Integer getTokenizeCounting() {
        return tokenizeCounting;
    }

    public List<List<TaggedWord>> getTaggedWordListF() {
        return taggedWordListF;
    }

    public List<List<TaggedWord>> getTaggedWordList1() {
        return taggedWordList1;
    }

    public ArrayList<String> getRetrieveTGWList1() {
        return retrieveTGWList1;
    }

    public List<CoreMap> getSentencesF() {
        return sentencesF;
    }

    public Integer getTokenizeCountingF() {
        return tokenizeCountingF;
    }

    public ArrayList<String> getRetrieveTGWListF() {
        return retrieveTGWListF;
    }

    public List<CoreMap> getSentences1() {
        return sentences1;
    }

    public List<CoreMap> getSentencesSentimentF() {
        return sentencesSentimentF;
    }

    public List<CoreMap> getSentencesSentiment1() {
        return sentencesSentiment1;
    }

    public ArrayList<Tree> getTreesF() {
        return treesF;
    }

    public ArrayList<Tree> getTrees1() {
        return trees1;
    }


    public ArrayList<GrammaticalStructure> getGrammaticalStructuresF() {
        return grammaticalStructuresF;
    }

    public ArrayList<GrammaticalStructure> getGrammaticalStructures1() {
        return grammaticalStructures1;
    }

    public ArrayList<TypedDependency> getTypedDependenciesF() {
        return typedDependenciesF;
    }

    public ArrayList<TypedDependency> getTypedDependencies1() {
        return typedDependencies1;
    }

    public ArrayList<Integer> getRnnCoreAnnotationsPredictedF() {
        return rnnCoreAnnotationsPredictedF;
    }

    public ArrayList<Integer> getRnnCoreAnnotationsPredicted1() {
        return rnnCoreAnnotationsPredicted1;
    }

    public ArrayList<SimpleMatrix> getSimpleMatricesF() {
        return simpleMatricesF;
    }

    public ArrayList<SimpleMatrix> getSimpleMatrices1() {
        return simpleMatrices1;
    }

    public ArrayList<SimpleMatrix> getSimpleMatricesNodevectorsF() {
        return simpleMatricesNodevectorsF;
    }

    public List getListF() {
        return listF;
    }

    public List getList1() {
        return list1;
    }

    public ArrayList<SimpleMatrix> getSimpleMatricesNodevectors1() {
        return simpleMatricesNodevectors1;
    }

    public Integer getLongestF() {
        return longestF;
    }

    public Integer getSentimentLongestF() {
        return sentimentLongestF;
    }

    public Integer getSentimentLongest1() {
        return sentimentLongest1;
    }

    public List<IMWE<IToken>> getImwesF() {
        return imwesF;
    }

    public List<IMWE<IToken>> getImwes1() {
        return imwes1;
    }

    public Integer getLongest1() {
        return longest1;
    }

    public Integer getInflectedCounterNegativeF() {
        return InflectedCounterNegativeF;
    }

    public Integer getInflectedCounterPositiveF() {
        return InflectedCounterPositiveF;
    }

    public Integer getInflectedCounterPositive1() {
        return InflectedCounterPositive1;
    }

    public Integer getInflectedCounterNegative1() {
        return InflectedCounterNegative1;
    }

    public ArrayList<String> getTokenEntryF() {
        return tokenEntryF;
    }

    public ArrayList<String> getTokenEntry1() {
        return tokenEntry1;
    }

    public Integer getMarkedContinuousCounterF() {
        return MarkedContinuousCounterF;
    }

    public Integer getMarkedContinuousCounter1() {
        return MarkedContinuousCounter1;
    }

    public Integer getUnmarkedPatternCounterF() {
        return UnmarkedPatternCounterF;
    }

    public Integer getUnmarkedPatternCounter1() {
        return UnmarkedPatternCounter1;
    }

    public ArrayList<String> getStrTokensIpartFormF() {
        return strTokensIpartFormF;
    }

    public ArrayList<String> getStrTokensIpartForm1() {
        return strTokensIpartForm1;
    }

    public ArrayList<String> getTokenFormsF() {
        return tokenFormsF;
    }

    public ArrayList<String> getTokenForms1() {
        return tokenForms1;
    }

    public ArrayList<String> getStrTokenEntryGetPOSF() {
        return strTokenEntryGetPOSF;
    }

    public ArrayList<String> getStrTokenEntryGetPOS1() {
        return strTokenEntryGetPOS1;
    }

    public ArrayList<Integer> getIntTokenEntyCountsF() {
        return intTokenEntyCountsF;
    }

    public ArrayList<Integer> getIntTokenEntyCounts1() {
        return intTokenEntyCounts1;
    }

    public ArrayList<String> getITokenTagsF() {
        return ITokenTagsF;
    }

    public ArrayList<String> getITokenTags1() {
        return ITokenTags1;
    }

    public ArrayList<String> getStrTokenStemsF() {
        return strTokenStemsF;
    }

    public ArrayList<String> getStrTokenStems1() {
        return strTokenStems1;
    }

    public Integer getAnotatorcounterF() {
        return AnotatorcounterF;
    }

    public Integer getAnotatorcounter1() {
        return Anotatorcounter1;
    }

    public Integer getTokensCounterF() {
        return TokensCounterF;
    }

    public Integer getTokensCounter1() {
        return TokensCounter1;
    }

    public ArrayList<String> getEntityTokenTagsF() {
        return entityTokenTagsF;
    }

    public ArrayList<String> getEntityTokenTags1() {
        return entityTokenTags1;
    }

    public ArrayList<String> getNerEntitiesF() {
        return nerEntitiesF;
    }

    public ArrayList<String> getNerEntities1() {
        return nerEntities1;
    }

    public ArrayList<String> getNerEntitiesTypeF() {
        return nerEntitiesTypeF;
    }

    public ArrayList<String> getNerEntitiesType1() {
        return nerEntitiesType1;
    }

    public ArrayList<String> getStopWordTokenF() {
        return stopWordTokenF;
    }

    public ArrayList<String> getStopWordToken1() {
        return stopWordToken1;
    }

    public ArrayList<String> getStopWordLemmaF() {
        return stopWordLemmaF;
    }

    public ArrayList<String> getStopWordLemma1() {
        return stopWordLemma1;
    }

    public Integer getPairCounterF() {
        return PairCounterF;
    }

    public Integer getPairCounter1() {
        return PairCounter1;
    }

    //caches
    private Integer tokenizeCounting;
    private Integer tokenizeCountingF;
    private List<List<TaggedWord>> taggedWordListF;
    private List<List<TaggedWord>> taggedWordList1;
    private ArrayList<String> retrieveTGWList1;
    private ArrayList<String> retrieveTGWListF;
    private List<CoreMap> sentencesF;
    private List<CoreMap> sentences1;
    private List<CoreMap> sentencesSentimentF;
    private List<CoreMap> sentencesSentiment1;
    private ArrayList<Tree> treesF;
    private ArrayList<Tree> trees1;
    private ArrayList<GrammaticalStructure> grammaticalStructuresF;
    private ArrayList<GrammaticalStructure> grammaticalStructures1;
    private ArrayList<TypedDependency> typedDependenciesF;
    private ArrayList<TypedDependency> typedDependencies1;
    private ArrayList<Integer> rnnCoreAnnotationsPredictedF;
    private ArrayList<Integer> rnnCoreAnnotationsPredicted1;
    private ArrayList<SimpleMatrix> simpleMatricesF;
    private ArrayList<SimpleMatrix> simpleMatrices1;
    private ArrayList<SimpleMatrix> simpleMatricesNodevectorsF;
    private ArrayList<SimpleMatrix> simpleMatricesNodevectors1;
    private List listF;
    private List list1;
    private Integer longestF;
    private Integer longest1;
    private Integer sentimentLongestF;
    private Integer sentimentLongest1;
    private List<IMWE<IToken>> imwesF;
    private List<IMWE<IToken>> imwes1;
    private Integer InflectedCounterNegativeF;
    private Integer InflectedCounterNegative1;
    private Integer InflectedCounterPositiveF;
    private Integer InflectedCounterPositive1;
    private ArrayList<String> tokenEntryF;
    private ArrayList<String> tokenEntry1;
    private Integer MarkedContinuousCounterF;
    private Integer MarkedContinuousCounter1;
    private Integer UnmarkedPatternCounterF;
    private Integer UnmarkedPatternCounter1;
    private ArrayList<String> strTokensIpartFormF;
    private ArrayList<String> strTokensIpartForm1;
    private ArrayList<String> tokenFormsF;
    private ArrayList<String> tokenForms1;
    private ArrayList<String> strTokenEntryGetPOSF;
    private ArrayList<String> strTokenEntryGetPOS1;
    private ArrayList<Integer> intTokenEntyCountsF;
    private ArrayList<Integer> intTokenEntyCounts1;
    private ArrayList<String> ITokenTagsF;
    private ArrayList<String> ITokenTags1;
    private ArrayList<String> strTokenStemsF;
    private ArrayList<String> strTokenStems1;
    private Integer AnotatorcounterF;
    private Integer Anotatorcounter1;
    private Integer TokensCounterF;
    private Integer TokensCounter1;
    private ArrayList<String> entityTokenTagsF;
    private ArrayList<String> entityTokenTags1;
    private ArrayList<String> nerEntitiesF;
    private ArrayList<String> nerEntities1;
    private ArrayList<String> nerEntitiesTypeF;
    private ArrayList<String> nerEntitiesType1;
    private ArrayList<String> stopWordTokenF;
    private ArrayList<String> stopWordToken1;
    private ArrayList<String> stopWordLemmaF;
    private ArrayList<String> stopWordLemma1;
    private Integer PairCounterF;
    private Integer PairCounter1;
    private Double score_res;

    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,
                                 AbstractSequenceClassifier classifier, Integer tokenizeCounting,
                                 Integer tokenizeCountingF, List<List<TaggedWord>> taggedWordListF,
                                 List<List<TaggedWord>> taggedWordList1, ArrayList<String>
                                         retrieveTGWListF, ArrayList<String> retrieveTGWList1,
                                 List<CoreMap> sentencesF, List<CoreMap> sentences1,
                                 List<CoreMap> sentencesSentimentF, List<CoreMap> sentencesSentiment1,
                                 ArrayList<Tree> treesF, ArrayList<Tree> trees1,
                                 ArrayList<GrammaticalStructure> grammaticalStructuresF,
                                 ArrayList<GrammaticalStructure> grammaticalStructures1,
                                 ArrayList<TypedDependency> typedDependenciesF,
                                 ArrayList<TypedDependency> typedDependencies1,
                                 ArrayList<Integer> rnnCoreAnnotationsPredictedF,
                                 ArrayList<Integer> rnnCoreAnnotationsPredicted1,
                                 ArrayList<SimpleMatrix> simpleMatricesF,
                                 ArrayList<SimpleMatrix> simpleMatrices1,
                                 ArrayList<SimpleMatrix> simpleMatricesNodevectorsF,
                                 ArrayList<SimpleMatrix> simpleMatricesNodevectors1,
                                 List listF, List list1, Integer longestF, Integer longest1,
                                 Integer sentimentLongestF, Integer sentimentLongest1,
                                 List<IMWE<IToken>> imwesF, List<IMWE<IToken>> imwes1,
                                 Integer InflectedCounterNegativeF,
                                 Integer InflectedCounterNegative1, Integer InflectedCounterPositiveF,
                                 Integer InflectedCounterPositive1, ArrayList<String> tokenEntryF,
                                 ArrayList<String> tokenEntry1, Integer MarkedContinuousCounterF,
                                 Integer MarkedContinuousCounter1, Integer UnmarkedPatternCounterF,
                                 Integer UnmarkedPatternCounter1, ArrayList<String> strTokensIpartFormF,
                                 ArrayList<String> strTokensIpartForm1, ArrayList<String> tokenFormsF,
                                 ArrayList<String> tokenForms1, ArrayList<String> strTokenEntryGetPOSF,
                                 ArrayList<String> strTokenEntryGetPOS1, ArrayList<Integer> intTokenEntyCountsF,
                                 ArrayList<Integer> intTokenEntyCounts1, ArrayList<String> ITokenTagsF,
                                 ArrayList<String> ITokenTags1, ArrayList<String> strTokenStemsF,
                                 ArrayList<String> strTokenStems1, Integer AnotatorcounterF,
                                 Integer Anotatorcounter1, Integer TokensCounterF,
                                 Integer TokensCounter1, ArrayList<String> entityTokenTagsF,
                                 ArrayList<String> entityTokenTags1, ArrayList<String> nerEntitiesF,
                                 ArrayList<String> nerEntities1, ArrayList<String> nerEntitiesTypeF,
                                 ArrayList<String> nerEntitiesType1, ArrayList<String> stopWordTokenF,
                                 ArrayList<String> stopWordToken1, ArrayList<String> stopWordLemmaF,
                                 ArrayList<String> stopWordLemma1, Integer PairCounterF,
                                 Integer PairCounter1) {
        this.str = str;
        this.str1 = str1;
        this.tagger = tagger;
        this.gsf = gsf;
        this.classifier = classifier;
        this.coreMaps1 = coreMaps1;
        this.coreMaps2 = coreMaps2;
        this.pipelineAnnotation1 = strPipeline1;
        this.pipelineAnnotation2 = strPipeline2;
        this.pipelineAnnotation1Sentiment = strPipeSentiment1;
        this.pipelineAnnotation2Sentiment = strPipeSentiment2;
        this.pipelineCoreDcoument1 = pipelineCoreDcoument1;
        this.pipelineCoreDcoument2 = pipelineCoreDcoument2;
        this.tokenizeCounting = tokenizeCounting;
        this.tokenizeCountingF = tokenizeCountingF;
        this.taggedWordListF = taggedWordListF;
        this.taggedWordList1 = taggedWordList1;
        this.retrieveTGWListF = retrieveTGWListF;
        this.retrieveTGWList1 = retrieveTGWList1;
        this.sentencesF = sentencesF;
        this.sentences1 = sentences1;
        this.sentencesSentimentF = sentencesSentimentF;
        this.sentencesSentiment1 = sentencesSentiment1;
        this.treesF = treesF;
        this.trees1 = trees1;
        this.grammaticalStructuresF = grammaticalStructuresF;
        this.grammaticalStructures1 = grammaticalStructures1;
        this.typedDependenciesF = typedDependenciesF;
        this.typedDependencies1 = typedDependencies1;
        this.rnnCoreAnnotationsPredictedF = rnnCoreAnnotationsPredictedF;
        this.rnnCoreAnnotationsPredicted1 = rnnCoreAnnotationsPredicted1;
        this.simpleMatricesF = simpleMatricesF;
        this.simpleMatrices1 = simpleMatrices1;
        this.simpleMatricesNodevectorsF = simpleMatricesNodevectorsF;
        this.simpleMatricesNodevectors1 = simpleMatricesNodevectors1;
        this.listF = listF;
        this.list1 = list1;
        this.longestF = longestF;
        this.longest1 = longest1;
        this.sentimentLongestF = sentimentLongestF;
        this.sentimentLongest1 = sentimentLongest1;
        this.imwesF = imwesF;
        this.imwes1 = imwes1;
        this.InflectedCounterNegativeF = InflectedCounterNegativeF;
        this.InflectedCounterNegative1 = InflectedCounterNegative1;
        this.InflectedCounterPositiveF = InflectedCounterPositiveF;
        this.InflectedCounterPositive1 = InflectedCounterPositive1;
        this.tokenEntryF = tokenEntryF;
        this.tokenEntry1 = tokenEntry1;
        this.MarkedContinuousCounterF = MarkedContinuousCounterF;
        this.MarkedContinuousCounter1 = MarkedContinuousCounter1;
        this.UnmarkedPatternCounterF = UnmarkedPatternCounterF;
        this.UnmarkedPatternCounter1 = UnmarkedPatternCounter1;
        this.strTokensIpartFormF = strTokensIpartFormF;
        this.strTokensIpartForm1 = strTokensIpartForm1;
        this.tokenFormsF = tokenFormsF;
        this.tokenForms1 = tokenForms1;
        this.strTokenEntryGetPOSF = strTokenEntryGetPOSF;
        this.strTokenEntryGetPOS1 = strTokenEntryGetPOS1;
        this.intTokenEntyCountsF = intTokenEntyCountsF;
        this.intTokenEntyCounts1 = intTokenEntyCounts1;
        this.ITokenTagsF = ITokenTagsF;
        this.ITokenTags1 = ITokenTags1;
        this.strTokenStemsF = strTokenStemsF;
        this.strTokenStems1 = strTokenStems1;
        this.AnotatorcounterF = AnotatorcounterF;
        this.Anotatorcounter1 = Anotatorcounter1;
        this.TokensCounterF = TokensCounterF;
        this.TokensCounter1 = TokensCounter1;
        this.entityTokenTagsF = entityTokenTagsF;
        this.entityTokenTags1 = entityTokenTags1;
        this.nerEntitiesF = nerEntitiesF;
        this.nerEntities1 = nerEntities1;
        this.nerEntitiesTypeF = nerEntitiesTypeF;
        this.nerEntitiesType1 = nerEntitiesType1;
        this.stopWordTokenF = stopWordTokenF;
        this.stopWordToken1 = stopWordToken1;
        this.stopWordLemmaF = stopWordLemmaF;
        this.stopWordLemma1 = stopWordLemma1;
        this.PairCounterF = PairCounterF;
        this.PairCounter1 = PairCounter1;
        this.score_res = callSMX();
    }

    private List<List<TaggedWord>> getTaggedWordList(String message) {
        List<List<TaggedWord>> taggedwordlist = new ArrayList();
        DocumentPreprocessor tokenizer = new DocumentPreprocessor(new StringReader(message));
        TokenizerFactory<CoreLabel> ptbTokenizerFactory = PTBTokenizer.factory(new CoreLabelTokenFactory(), "untokenizable=noneDelete"); //noneDelete //firstDelete
        tokenizer.setTokenizerFactory(ptbTokenizerFactory);
        for (final List<HasWord> sentence : tokenizer) {
            try {
                taggedwordlist.add(tagger.tagSentence(sentence));
            } catch (Exception ex) {
                System.out.println("crashed in tagger.tagsentence");
            }
        }
        return taggedwordlist;
    }

    private int tokenizeCounting(List<List<TaggedWord>> taggedwordlist) {
        int counter = 0;
        for (List<TaggedWord> taggedList : taggedwordlist) {
            counter += taggedList.size();
        }
        return counter;
    }

    private ArrayList<String> retrieveTGWListIndex(List<List<TaggedWord>> taggedwordlist) {
        ArrayList<String> tgwlistIndex = new ArrayList<String>();
        for (List<TaggedWord> tGWList : taggedwordlist) {
            for (TaggedWord taggedWord : tGWList) {
                for (String str : tgwlistIndex) {
                    if (!taggedWord.tag().equals(str) && !taggedWord.tag().equals(":")) {
                        tgwlistIndex.add(taggedWord.tag());
                        tGWList.remove(taggedWord);
                    }
                }
            }
        }
        return tgwlistIndex;
    }

    private Double iterateTrees(ArrayList<Tree> sentenceConstituencyParseList2, ArrayList<Tree> sentenceConstituencyParseList1,
                                Double score) {
        double preConstituentsScore = score;
        ArrayList<Integer> constituentsMap = new ArrayList<Integer>();
        int constituencySize = sentenceConstituencyParseList1.size() + sentenceConstituencyParseList2.size();
        for (final Tree sentenceConstituencyParse2 : sentenceConstituencyParseList2) {
            int constiRelationsize = 0;
            try {
                if (sentenceConstituencyParse2 != null && !sentenceConstituencyParse2.isEmpty()) {
                    for (final Tree sentenceConstituencyParse1 : sentenceConstituencyParseList1) {
                        try {
                            if (sentenceConstituencyParse1 != null && !sentenceConstituencyParse1.isEmpty()) {

                                Set<Constituent> constinuent1 = null;
                                Set<Constituent> constinuent2 = null;
                                try {
                                    constinuent1 = Tdiff.markDiff(sentenceConstituencyParse1, sentenceConstituencyParse2);
                                    constinuent2 = Tdiff.markDiff(sentenceConstituencyParse2, sentenceConstituencyParse1);
                                } catch (Exception e) {
                                    continue;
                                }
                                ArrayList<String> constiLabels = new ArrayList<String>();
                                for (final Constituent consti : constinuent1) {
                                    for (final Constituent consti1 : constinuent2) {
                                        if (consti.value().equals(consti1.value()) && !constiLabels.contains(consti.value())) {
                                            constiLabels.add(consti.value());
                                            constiRelationsize++;
                                        }
                                    }
                                }
                                int constituents1 = constinuent1.size() - constiRelationsize;
                                int constituents2 = constinuent2.size() - constiRelationsize;
                                constituentsMap.add(constituents1);
                                constituentsMap.add(constituents2);
                                constituentsMap.add(constiRelationsize);
                                if (constituentsMap.size() < 4) {
                                    if ((constituents1 * 5 < constituents2 || constituents2 * 5 < constituents1) && constituents1 > 0 && constituents2 > 0) {
                                        score -= (constituents1 + constituents2) * 200;
                                        //logger.info("score post score -= (constituents1 + constituents2) * 200;: " + score);
                                    } else if ((constituents1 == 0 || constituents2 == 0) && (constituents1 >= constituents2 + 4 || constituents2 >= constituents1 + 4)) {
                                        score -= constituents1 > constituents2 ? constituents1 * 500 : constituents2 * 500;
                                        //logger.info("score post  score -= constituents1 > constituents2 ? constituents1 * 500 : constituents2 * 500;: " + score);
                                    } else if (constiRelationsize >= constituents1 + constituents2 && (constituents1 > 2 && constituents2 > 2)) {
                                        score += (constiRelationsize + constituents1 + constituents2) * 350;
                                        //logger.info("score post  score += (constiRelationsize + constituents1 + constituents2) * 350;: " + score);
                                    } else if (constituents1 >= 2 && constituents2 >= 2 && constituents1 * 1.5 > constituents2 && constituents2 * 1.5 > constituents1) {
                                        //logger.info("constituents1: " + constituents1);
                                        //logger.info("constituents2: " + constituents2);
                                        if (constituents2 == 3) {
                                            score += 8745;
                                            //logger.info("score post score += 8745;: " + score);
                                        }
                                        if (constituents1 == constituents2 && constiRelationsize - constituents1 >= 5) {
                                            score += (constiRelationsize + constituents1 + constituents2) * 1550;
                                            //logger.info("score post  score += (constiRelationsize + constituents1 + constituents2) * 1550;: " + score);
                                        } else if (constituents1 == 3 && constituents2 == 3) {
                                            score -= 3949;
                                            //logger.info("score post  score -= 3949;: " + score);
                                        } else if (constiRelationsize >= constituents1 && constituents1 == constituents2) {
                                            score -= (constiRelationsize + constituents1 + constituents2) * 550;
                                            //logger.info("score post  score -= (constiRelationsize + constituents1 + constituents2) * 550;: " + score);
                                        } else if (constiRelationsize < constituents1 && constiRelationsize < constituents2) {
                                            score += 800;
                                            //logger.info("score post  score += 800;: " + score);
                                        } else if ((constiRelationsize == constituents1 || constiRelationsize == constituents2) && constituents1 * 1.5 > constituents2
                                                && constituents2 * 1.5 > constituents1) {
                                            score += (constiRelationsize + constituents1 + constituents2) * 350;
                                            //logger.info("score post score += (constiRelationsize + constituents1 + constituents2) * 350;: " + score);
                                        }
                                    } else if (constiRelationsize > constituents1 + constituents2) {
                                        //logger.info("constiRelationsize: " + constiRelationsize);
                                        //logger.info("constituents1: " + constituents1);
                                        //logger.info("constituents2: " + constituents2);
                                        score -= 2826;
                                        //logger.info("score score score -= 2826; " + score);
                                    } else if (constiRelationsize * 5 < constituents1 || constiRelationsize * 5 < constituents2) {
                                        score -= (constituents1 + constituents2) * 1923;
                                        //logger.info("score post  score -= (constituents1 + constituents2) * 1923;: " + score);
                                    }
                                } else {
                                    //score = preConstituentsScore;
                                    //logger.info("score post  score = preConstituentsScore;: " + score);
                                    int n1 = constituentsMap.get(0);
                                    int n2 = constituentsMap.get(1);
                                    int n3 = constituentsMap.get(2);
                                    int cap = 0;
                                    if (n1 > n2 && n1 > n3) {
                                        cap = n1;
                                    } else if (n2 > n3 && n2 > n1) {
                                        cap = n2;
                                    } else {
                                        cap = n3;
                                    }
                                    int overheat = 0;
                                    for (int iterator = 3; iterator < constituentsMap.size(); iterator++) {
                                        Integer getConstituent = constituentsMap.get(iterator);
                                        if (getConstituent > cap) {
                                            overheat++;
                                        }
                                    }
                                    //logger.info("cap: " + cap);
                                    //logger.info("overheat: " + overheat);
                                    if (overheat == 2) {
                                        score -= 12985;
                                        //logger.info("score post score -= 12985;: " + score);
                                    }
                                    if (overheat >= 1) {
                                        score -= overheat * 2803;
                                        //logger.info("score post score -= overheat * 2803;: " + score);
                                    } else {
                                        score -= 553;
                                        //logger.info("score post score -= 553; " + score);
                                    }
                                }
                            }
                        } catch (NoSuchElementException e) {
                        }
                    }
                    if (constituencySize > 10) {
                        score -= constituencySize * 400;
                        //logger.info("score post  score -= constituencySize * 400;: " + score);
                    }
                }

            } catch (NoSuchElementException e) {

            }
        }
        return score;
    }

    private Double typeDependenciesGrammaticalRelation
            (Collection<TypedDependency> allTypedDependencies1, Collection<TypedDependency> allTypedDependencies2,
             Double score, ArrayList<GrammaticalStructure> grammaticalMap1,
             ArrayList<GrammaticalStructure> grammaticalMap2,
             ArrayList<Tree> sentenceConstituencyParseList1, ArrayList<Tree> sentenceConstituencyParseList2) {
        ArrayList<Integer> alltypeDepsSize1 = new ArrayList<Integer>();
        ArrayList<Integer> summationList = new ArrayList<Integer>();
        int relationApplicable1 = 0;
        int relationApplicable2 = 0;
        int grammaticalRelation1 = 0;
        int grammaticalRelation2 = 0;
        List<Tree> treeCollectionGramatical = new ArrayList();
        List<Tree> treeCollectionReln = new ArrayList();
        for (TypedDependency TDY1 : allTypedDependencies1) {
            IndexedWord dep = TDY1.dep();
            IndexedWord gov = TDY1.gov();
            for (GrammaticalStructure gs : grammaticalMap1) {
                GrammaticalRelation grammaticalRelation = gs.getGrammaticalRelation(gov, dep);
                for (Tree sentenceConstituencyParse2 : sentenceConstituencyParseList2) {
                    try {
                        if (sentenceConstituencyParse2 != null && !sentenceConstituencyParse2.isEmpty()) {
                            if (grammaticalRelation.isApplicable(sentenceConstituencyParse2) && !treeCollectionGramatical.contains(sentenceConstituencyParse2)) {
                                score += 701;
                                //logger.info("score post score += 701; :" + score);
                                grammaticalRelation1++;
                                treeCollectionGramatical.add(sentenceConstituencyParse2);
                            }
                            GrammaticalRelation reln = TDY1.reln();
                            if (reln.isApplicable(sentenceConstituencyParse2) && !treeCollectionReln.contains(sentenceConstituencyParse2)) {
                                score += 528;
                                //logger.info("score post score += 528; :" + score);
                                relationApplicable1++;
                                treeCollectionReln.add(sentenceConstituencyParse2);
                            }
                        }
                    } catch (NoSuchElementException e) {

                    }
                }
            }
        }
        treeCollectionGramatical = new ArrayList();
        treeCollectionReln = new ArrayList();
        for (TypedDependency TDY : allTypedDependencies2) {
            IndexedWord dep = TDY.dep();
            IndexedWord gov = TDY.gov();
            for (GrammaticalStructure gs : grammaticalMap2) {
                GrammaticalRelation grammaticalRelation = gs.getGrammaticalRelation(gov, dep);
                for (Tree sentenceConstituencyParse1 : sentenceConstituencyParseList1) {
                    try {
                        if (sentenceConstituencyParse1 != null && !sentenceConstituencyParse1.isEmpty()) {
                            if (grammaticalRelation.isApplicable(sentenceConstituencyParse1) && !treeCollectionGramatical.contains(sentenceConstituencyParse1)) {
                                score += 700;
                                //logger.info("score post score += 700;  :" + score);
                                grammaticalRelation2++;
                                treeCollectionGramatical.add(sentenceConstituencyParse1);
                            }
                            GrammaticalRelation reln = TDY.reln();
                            //sentenceConstituencyParse1
                            if (reln.isApplicable(sentenceConstituencyParse1) && !treeCollectionReln.contains(sentenceConstituencyParse1)) {
                                score += 527;
                                //logger.info("score post score += 527; :" + score);
                                relationApplicable2++;
                                treeCollectionReln.add(sentenceConstituencyParse1);
                            }
                        }
                    } catch (NoSuchElementException r) {

                    }
                }
            }
        }
        if ((grammaticalRelation1 == 0 && grammaticalRelation2 > 4) || (grammaticalRelation2 == 0 && grammaticalRelation1 > 4)) {
            score -= 3450;
            //logger.info("score post score -= 3450; :" + score);
        }
        if (!allTypedDependencies1.isEmpty() || !allTypedDependencies2.isEmpty()) {
            int allTypeDep1 = allTypedDependencies1.size();
            int allTypeDep2 = allTypedDependencies2.size();
            if (allTypeDep1 <= allTypeDep2 * 5 && allTypeDep2 <= allTypeDep1 * 5) {
                if (allTypeDep1 > 0 && allTypeDep2 > 0 && (allTypeDep1 >= 5 || allTypeDep2 >= 5)) {
                    if ((allTypeDep1 + 1 == allTypeDep2 || allTypeDep2 + 1 == allTypeDep1)) {
                        score -= allTypeDep1 > allTypeDep2 ? (allTypeDep1 - allTypeDep2) * 160 : (allTypeDep2 - allTypeDep1) * 160;
                        //logger.info("score post score -= allTypeDep1 > allTypeDep2 ? (allTypeDep1 - allTypeDep2) * 160 : (allTypeDep2 - allTypeDep1) * 160; :" + score);
                    } else if (allTypeDep1 * 2.5 >= allTypeDep2 && allTypeDep2 * 2.5 >= allTypeDep1) {
                        score += allTypeDep1 > allTypeDep2 ? (allTypeDep1 - allTypeDep2) * 260 : (allTypeDep2 - allTypeDep1) * 260;
                        //logger.info("score post  score += allTypeDep1 > allTypeDep2 ? (allTypeDep1 - allTypeDep2) * 260 : (allTypeDep2 - allTypeDep1) * 260; :" + score);
                    } else if (allTypeDep1 >= 5 && allTypeDep1 <= 10 && allTypeDep2 >= 5 && allTypeDep2 <= 10) {
                        score += allTypeDep1 > allTypeDep2 ? (allTypeDep1 - allTypeDep2) * 260 : (allTypeDep2 - allTypeDep1) * 260;
                        //logger.info("score post score += allTypeDep1 > allTypeDep2 ? (allTypeDep1 - allTypeDep2) * 260 : (allTypeDep2 - allTypeDep1) * 260; :" + score);
                    } else {
                        score -= allTypeDep1 > allTypeDep2 ? (allTypeDep1 - allTypeDep2) * 600 : (allTypeDep2 - allTypeDep1) * 600;
                        //logger.info("score post  score -= allTypeDep1 > allTypeDep2 ? (allTypeDep1 - allTypeDep2) * 600 : (allTypeDep2 - allTypeDep1) * 600; :" + score);
                    }
                    alltypeDepsSize1.add(allTypeDep1);
                    alltypeDepsSize1.add(allTypeDep2);
                }
            }
            if (allTypeDep1 >= 5 && allTypeDep2 >= 5) {
                int largerTypeDep = allTypeDep1 > allTypeDep2 ? allTypeDep1 : allTypeDep2;
                int smallerTypeDep = allTypeDep1 < allTypeDep2 ? allTypeDep1 : allTypeDep2;
                int summation = (largerTypeDep * largerTypeDep) - (smallerTypeDep * smallerTypeDep);
                //logger.info("largerTypeDep: " + largerTypeDep);
                //logger.info("smallerTypeDep: " + smallerTypeDep);
                //logger.info("summation: " + summation);
                if (largerTypeDep > 8 && largerTypeDep < 10 && summation < 50) {
                    score += 23435;
                    //logger.info("score post  score += 23435; " + score);
                }
                if (summation >= 180 && summation <= 480) {
                    score -= 10522;
                    //logger.info("score post score -= 10522" + score);
                }
                if (summation >= 35 && summation < 45) {
                    score -= 4021;
                    //logger.info("score post score -= 4021;" + score);
                }
                if (largerTypeDep == 6 && smallerTypeDep == 6) {
                    score += 9340;
                    //logger.info("score post  score += 9340;: " + score);
                }
                if (summation / largerTypeDep < 15.0 && summation / largerTypeDep > 10.0 && smallerTypeDep * 2 > largerTypeDep
                        && !summationList.contains(summation)) {
                    score += summation * 80;
                    //logger.info("score post score += summation * 80; :" + score);
                    summationList.add(summation);
                } else if (largerTypeDep == smallerTypeDep) {
                    score += 2502;
                    //logger.info("score post score += 2502; :" + score);
                }
            }
            if (relationApplicable1 > 0 && relationApplicable2 > 0 && relationApplicable1 != relationApplicable2) {
                score -= 4101;
                //logger.info("score post score -= 4101; :" + score);
            } else if (allTypeDep1 * 5 < allTypeDep2 || allTypeDep2 * 5 < allTypeDep1) {
                score -= allTypeDep1 > allTypeDep2 ? (allTypeDep1 - allTypeDep2) * (allTypeDep2 * 450)
                        : (allTypeDep2 - allTypeDep1) * (allTypeDep1 * 450);
                //logger.info("score post score -= allTypeDep1 > allTypeDep2 ? (allTypeDep1 - allTypeDep2) * (allTypeDep2 * 450)\n" +
                // "                        : (allTypeDep2 - allTypeDep1) * (allTypeDep1 * 450); :" + score);
            }
            if (relationApplicable1 > 1 && relationApplicable2 > 1 && relationApplicable1 * 3 > relationApplicable2
                    && relationApplicable2 * 3 > relationApplicable1) {
                score += relationApplicable1 > relationApplicable2 ? (relationApplicable1 - relationApplicable2) * 1500
                        : (relationApplicable2 - relationApplicable1) * 1500;
                //logger.info("score post  score += relationApplicable1 > relationApplicable2 ? (relationApplicable1 - relationApplicable2) * 1500\n" +
                // "                        : (relationApplicable2 - relationApplicable1) * 1500; :" + score);
            } else if (relationApplicable1 * 5 < relationApplicable2 || relationApplicable2 * 5 < relationApplicable1) {
                score -= relationApplicable1 > relationApplicable2 ? (relationApplicable1 - relationApplicable2) * 500
                        : (relationApplicable2 - relationApplicable1) * 500;
                //logger.info("score post score -= relationApplicable1 > relationApplicable2 ? (relationApplicable1 - relationApplicable2) * 500\n" +
                // "  : (relationApplicable2 - relationApplicable1) * 500; :" + score);

                //logger.info("relationApplicable1: " + relationApplicable1);
                //logger.info("relationApplicable2: " + relationApplicable2);

                //logger.info("grammaticalRelation1: " + grammaticalRelation1);
                //logger.info("grammaticalRelation2: " + grammaticalRelation2);
                if (grammaticalRelation1 == 1) {
                    score -= 3431;
                    //logger.info("score post score -= 3431;: " + score);
                }
            }
            if (grammaticalRelation1 > 0 && grammaticalRelation2 > 0 && grammaticalRelation1 * 3 > grammaticalRelation2
                    && grammaticalRelation2 * 3 > grammaticalRelation1) {
                score += grammaticalRelation1 > grammaticalRelation2 ? (grammaticalRelation1 - grammaticalRelation2) * 4500
                        : (grammaticalRelation2 - grammaticalRelation1) * 4500;
                //logger.info("score post score += grammaticalRelation1 > grammaticalRelation2 ? (grammaticalRelation1 - grammaticalRelation2) * 4500\n" +
                //"                        : (grammaticalRelation2 - grammaticalRelation1) * 4500; :" + score);
            } else if (grammaticalRelation1 * 5 < grammaticalRelation2 || grammaticalRelation2 * 5 < grammaticalRelation1) {
                score -= grammaticalRelation1 > grammaticalRelation2 ? (grammaticalRelation1 - grammaticalRelation2) * 500
                        : (grammaticalRelation2 - grammaticalRelation1) * 6500;
                //logger.info("score post  score -= grammaticalRelation1 > grammaticalRelation2 ? (grammaticalRelation1 - grammaticalRelation2) * 500\n" +
                //"                        : (grammaticalRelation2 - grammaticalRelation1) * 500; :" + score);
            }
        }
        ArrayList<String> filerTreeContent = new ArrayList<String>();
        int runCount1 = 0;
        for (Tree sentenceConstituencyParse1 : sentenceConstituencyParseList1) {
            try {
                if (sentenceConstituencyParse1 != null && !sentenceConstituencyParse1.isEmpty()) {
                    for (Tree sentenceConstituencyParse2 : sentenceConstituencyParseList2) {
                        try {
                            if (sentenceConstituencyParse2 != null && !sentenceConstituencyParse2.isEmpty()) {
                                for (CoreLabel LBW : sentenceConstituencyParse1.taggedLabeledYield()) {
                                    for (CoreLabel LBW1 : sentenceConstituencyParse2.taggedLabeledYield()) {
                                        if (LBW.lemma() != null && LBW1.lemma() != null && LBW.lemma().equals(LBW1.lemma())) {
                                            boolean found = false;
                                            for (String str : filerTreeContent) {
                                                if (str.equals(LBW.lemma())) {
                                                    found = true;
                                                    break;
                                                }
                                            }
                                            if (!found && LBW.lemma() != null) {
                                                filerTreeContent.add(LBW.lemma());
                                                runCount1++;
                                            }
                                        }
                                    }
                                }
                            }
                        } catch (NoSuchElementException e) {

                        }
                    }
                }
            } catch (NoSuchElementException e) {

            }
        }
        score += runCount1 * 250;
        //logger.info("score post score += runCount1 * 250; :" + score);
        int typeSizeSmallest = 100;
        int typeSizeLargest = 0;
        for (Integer i : alltypeDepsSize1) {
            if (i > typeSizeLargest) {
                typeSizeLargest = i;
            }
            if (i < typeSizeSmallest) {
                typeSizeSmallest = i;
            }
        }
        if (typeSizeLargest >= typeSizeSmallest * 3) {
            score -= typeSizeLargest * 160;
            //logger.info("score post  score -= typeSizeLargest * 160; :" + score);
        }
        typeSizeLargest = 0;
        typeSizeSmallest = 100;
        for (int i : summationList) {
            if (i > typeSizeLargest) {
                typeSizeLargest = i;
            }
            if (i < typeSizeSmallest) {
                typeSizeSmallest = i;
            }
        }
        if (typeSizeLargest >= typeSizeSmallest * 3) {
            score -= typeSizeLargest * 160;
            //logger.info("score post score -= typeSizeLargest * 160; :" + score);
        }
        return score;
    }

    private Double simpleRNNMatrixCalculations(Double score, ArrayList<SimpleMatrix> simpleSMXlist1,
                                               ArrayList<SimpleMatrix> simpleSMXlist2) {
        List<Double> iteratedDoubleList = new ArrayList();
        List<Double> iterateddotPredictions = new ArrayList();
        double dotpredictionTransfer = 0.0;
        int iterationOverHeat = 0;
        double scoreFallback = score;
        for (SimpleMatrix simpleSMX2 : simpleSMXlist2) {
            ArrayList<Double> AccumulateDotList = new ArrayList<>();
            ArrayList<Double> subtractorList = new ArrayList<Double>();
            ArrayList<Double> dotPredictions = new ArrayList<Double>();
            ArrayList<Double> DotOverTransfer = new ArrayList<Double>();
            Double totalSubtraction = 0.0;
            Double largest = 10.0;
            Double shortest = 100.0;
            for (SimpleMatrix simpleSMX1 : simpleSMXlist1) {
                double dotPrediction2 = simpleSMX2.dot(simpleSMX1) * 100;
                double dotPrediction1 = simpleSMX1.dot(simpleSMX2) * 100;
                AccumulateDotList.add(dotPrediction1);
                AccumulateDotList.add(dotPrediction2);
                double subtracter1 = dotPrediction1 > 50 ? dotPrediction1 - 100 : dotPrediction1 > 0 ? 100 - dotPrediction1 : 0;
                double subtracter2 = dotPrediction2 > 50 ? dotPrediction2 - 100 : dotPrediction2 > 0 ? 100 - dotPrediction2 : 0;
                subtractorList.add(subtracter1);
                subtractorList.add(subtracter2);
                dotpredictionTransfer = dotPrediction1;
                if (!dotPredictions.contains(dotPrediction1)) {
                    for (Double transferDots : DotOverTransfer) {
                        if (transferDots == dotPrediction1) {
                            totalSubtraction += transferDots;
                        } else {
                            score -= subtracter1 * 25;
                            //logger.info("score  score -= subtracter1 * 25;  : " + score);
                        }
                    }
                    DotOverTransfer.add(dotPrediction1);
                } else {
                    subtracter1 -= 100;
                    subtracter1 *= 25;
                    score += subtracter1 * dotPrediction1;
                    //logger.info("score  score += subtracter1 * dotPrediction1;  : " + score);
                }
                dotPredictions.add(dotPrediction1);
                if (!dotPredictions.contains(dotPrediction2)) {
                    for (Double transferDots : DotOverTransfer) {
                        if (transferDots == dotPrediction2) {
                            totalSubtraction += transferDots;
                        } else {
                            score -= subtracter1 * 25;
                            //logger.info("score  score -= subtracter1 * 25;  : " + score);
                        }
                    }
                    DotOverTransfer.add(dotPrediction2);
                    if (dotPrediction2 > largest) {
                        largest = dotPrediction2;
                    }
                    if (dotPrediction2 < shortest) {
                        shortest = dotPrediction2;
                    }
                    Double dotPredictionIntervalDifference = largest - shortest;
                    subtracter2 *= 25;
                    if (dotPredictionIntervalDifference < 5.0) {
                        if (dotPredictions.size() > 0) {
                            if (subtracter2 > 0) {
                                score -= subtracter2;
                                //logger.info("score  score -= subtracter2;  : " + score);
                            } else {
                                score += subtracter2;
                                //logger.info("score  score += subtracter2;  : " + score);
                            }
                        }
                    } else {
                        score -= subtracter2 / 10;
                        //logger.info("score  score -= subtracter2 / 10;  : " + score);
                    }
                } else {
                    if (subtracter2 > 55.0 && subtracter2 < 82.0) {
                        if (dotPrediction2 > 30 && dotPrediction2 < 60) {
                            if (dotpredictionTransfer != 0.0 && (subtracter2 / dotPrediction2 < 1.3 || (subtracter2 / dotPrediction2 > 1.9
                                    && subtracter2 / dotPrediction2 < 1.99))) {
                                //logger.info("subtracter2: " + subtracter2);
                                //logger.info("dotpredictionTransfer: " + dotpredictionTransfer);
                                //logger.info("dotPrediction2: " + dotPrediction2);
                                //logger.info("dotPrediction1: " + dotPrediction1);
                                if (subtracter2 / dotPrediction2 < 1.248 && subtracter2 / dotPrediction2 > 1.238) {
                                    score -= 2502;
                                    //logger.info("score  score -= 2502;  : " + score);
                                } else if (dotPrediction2 < 34 && dotPrediction2 > 28) {
                                    score += 7948;
                                    //logger.info("score post score += 7948; " + score);
                                } else if (subtracter2 > 55.5) {
                                    score -= 7530;
                                    //logger.info("score score -= 7530;   : " + score);
                                }
                            } 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;
                                    //logger.info("score score += 4500;   : " + score);
                                } else {
                                    score -= 4500;
                                    //logger.info("score  score -= 4500;  : " + score);
                                }
                            } else if (!iterateddotPredictions.contains(dotPrediction2)) {
                                score += subtracter2 * dotPrediction2; // +=
                                //logger.info("score   score += subtracter2 * dotPrediction2;   : " + score);
                                iterateddotPredictions.add(dotPrediction2);
                            } else {
                                score -= 550;
                                //logger.info("score    score -= 550; : " + score);
                            }
                        } else if (dotPrediction2 < 25 && subtracter2 < 75) {
                            score -= dotPrediction2 * 250;
                            //logger.info("score   score -= dotPrediction2 * 250;  : " + score);
                        } else if (subtracter2 > 75.0) {
                            if (dotPrediction2 > 20.0 && dotPrediction2 < 23.0) {
                                score += 3500;
                                //logger.info("score   score += 3500;  : " + score);
                            } else {
                                if (subtracter2 < 75.9 && dotPrediction2 > 24.0 && dotPrediction2 < 24.9) {
                                    score -= (subtracter2 * dotPrediction2) * 85;
                                    //logger.info("score score -= (subtracter2 * dotPrediction2) * 85;   : " + score);
                                } else {
                                    score -= 4500;
                                    //logger.info("score  score -= 4500;  : " + score);
                                }
                            }
                        }
                    }
                }
                dotPredictions.add(dotPrediction2);
                iterationOverHeat++;
            }
            Double subTracPre = 0.0;
            for (Double subtractors : subtractorList) {
                if (Objects.equals(subTracPre, subtractors)) {
                    if (subTracPre > 43.5 && subTracPre < 50.0) {
                        score += (subTracPre * 55) / subtractorList.size();
                        //logger.info("score  score += (subTracPre * 55) / subtractorList.size();  : " + score);
                    } else if (subTracPre > 60.0 && subTracPre < 66.5) {
                        score += (subTracPre * 55) / subtractorList.size();
                        //logger.info("score   score += (subTracPre * 55) / subtractorList.size();  : " + score);
                    }
                } else if (subTracPre > 75.0 && subTracPre < 90.0) {
                    score += (subTracPre * 50) / subtractorList.size();
                    //logger.info("score   score += (subTracPre * 50) / subtractorList.size();  : " + score);
                } else if (subTracPre >= 55.0) {
                    score -= 2800;
                    //logger.info("score   score -= 2800;  : " + score);
                } else if (subTracPre < -25.0 && subTracPre > -45.0) {
                    score += subTracPre * 100;
                    //logger.info("score score += subTracPre * 100;   : " + score);
                }
                subTracPre = subtractors;
            }
            //logger.info("totalSubtraction: " + totalSubtraction);
            if (totalSubtraction > 45.0) {
                score -= totalSubtraction * 25;
                //logger.info("score   score -= totalSubtraction * 25;  : " + score);
            } else {
                score += totalSubtraction * 25;
                //logger.info("score  score += totalSubtraction * 25;  : " + score);
            }
            Double preAccumulatorDot = 0.0;
            Double postAccumulatorDot = 0.0;
            for (Double accumulators : AccumulateDotList) {
                if (Objects.equals(preAccumulatorDot, accumulators)) {
                    if (Objects.equals(postAccumulatorDot, accumulators)) {
                        score -= 1400;
                        //logger.info("score  score -= 1400;  : " + score);
                    }
                    postAccumulatorDot = accumulators;
                }
                preAccumulatorDot = accumulators;
            }
            subTracPre = 0.0;
            for (Double subtractors : subtractorList) {
                if (Objects.equals(subTracPre, subtractors) && subTracPre != 0.0) {
                    if (!iteratedDoubleList.contains(subTracPre)) {
                        score += 500;
                        //logger.info("score  score += 500;  : " + score);
                        iteratedDoubleList.add(subTracPre);
                    } else {
                        score -= 150;
                        //logger.info("score  score -= 150;  : " + score);
                    }
                }
                subTracPre = subtractors;
            }
        }
        if (iterationOverHeat > 12) {
            score = scoreFallback;
            score -= 2501;
            //logger.info("score  score -= 2501;  : " + score);
        }
        return score;
    }

    private Double simpleRNNMaxtrixVectors(Double score, ArrayList<SimpleMatrix> simpleSMXlistVector1,
                                           ArrayList<SimpleMatrix> simpleSMXlistVector2) {
        ArrayList<Double> elementSumCounter = new ArrayList<>();
        ArrayList<Double> dotMap = new ArrayList<>();
        ArrayList<Double> elementSumMap = new ArrayList<>();
        ArrayList<Double> dotSumMap = new ArrayList<>();
        Double preDot = 0.0;
        Double postDot = 0.0;
        int iterateSize = simpleSMXlistVector1.size() + simpleSMXlistVector2.size();
        boolean punish_overhead = false;
        if (simpleSMXlistVector1.size() > 10 || simpleSMXlistVector2.size() > 10) {
            punish_overhead = true;
        }
        for (SimpleMatrix simpleSMX2 : simpleSMXlistVector2) {
            for (SimpleMatrix simpleSMX1 : simpleSMXlistVector1) {
                double dot2 = simpleSMX2.dot(simpleSMX1);
                double elementSum2 = simpleSMX2.kron(simpleSMX1).elementSum();
                double dot1 = simpleSMX1.dot(simpleSMX2);
                double elementSum1 = simpleSMX1.kron(simpleSMX2).elementSum();
                if (preDot == dot2) {
                    if (postDot == dot2) {
                        score -= 500;
                        //logger.info("score  score -= 500: " + score);
                    }
                    postDot = dot2;
                }
                if (preDot == dot1) {
                    if (postDot == dot1) {
                        score -= 500;
                        //logger.info("score  score -= 500 1: " + score);
                    }
                    postDot = dot1;
                }
                preDot = dot1;
                elementSum1 = Math.round(elementSum1 * 100.0) / 100.0;
                elementSumCounter.add(elementSum1);
                dotMap.add(dot1);
                preDot = dot2;
                elementSum2 = Math.round(elementSum2 * 100.0) / 100.0;
                elementSumCounter.add(elementSum2);
                dotMap.add(dot2);
                if (!dotSumMap.contains(dot1)) {
                    if (dot1 < 0.1 && dot1 > 0.050) {
                        score += 256;
                        //logger.info("score   score += 256;  " + score);
                    }
                    if (dot1 > 0.44 && dot1 < 0.60) {
                        score -= 2400;
                        //logger.info("score  score -= 2400;  " + score);
                    } else if (dot1 > 0.40 && dot1 < 0.445) {
                        score += 3600;
                        //logger.info("score   score += 3600; " + score);
                    }
                    dotSumMap.add(dot1);
                } else {
                    score -= 50;
                    //logger.info("score score -= 50;  " + score);
                }
                if (!elementSumMap.contains(elementSum1)) {
                    //logger.info("elementSum1: " + elementSum1);
                    if (elementSum1 > 48 && elementSum1 < 50) {
                        score -= 6891;
                        //logger.info("score post score -= 6891;: " + score);
                    }
                    if ((elementSum1 > 130 && elementSum1 < 135) ||
                            (elementSum1 > 100 && elementSum1 < 105)) {
                        score += 254 * 150;
                        //logger.info("score post score += 254 * 150; " + score);
                    }
                    if (elementSum1 > 90.0 && elementSum1 < 95.0) {
                        score -= 7678;
                        //logger.info("score post score -= 7678;");
                    }
                    if (elementSum1 > 80.0 && elementSum1 < 85.0) {
                        score -= 4521;
                        //logger.info("score post score -= 4521;: " + score);
                    }
                    if (elementSum1 > 125.0 && elementSum1 < 130.0) {
                        score += elementSum1 * 43;
                        //logger.info("score post score += elementSum1 * 43; : " + score);
                    }
                    if (elementSum1 < 0.01 && elementSum1 > 0.00) {
                        score += 1300;
                        //logger.info("score   score += 1300; " + score);
                    } else if (elementSum1 > 0.1 && elementSum1 < 1.0) {
                        score += 7934;
                        //logger.info("score    score += 7934;  " + score);
                    } else if (elementSum1 > 1.0 && elementSum1 < 10.0) {
                        //logger.info("elementSum_1: " + elementSum1);
                        score -= elementSum1 * 583;
                        //logger.info("score  score -= elementSum1 * 583;  " + score);
                    } else if (dot2 == elementSum2) {
                        score += 2501;
                        //logger.info("score score += 2501; " + score);
                    }
                    elementSumMap.add(elementSum1);
                } else {
                    score -= 50;
                    //logger.info("score  score -= 50;  " + score);
                }
                //logger.info("dot2: " + dot2);
                if (elementSum1 > 51 && elementSum1 < 57 && dot2 > 22 && dot2 < 24) {
                    score += 9876;
                    //logger.info("score post score += 9876;: " + score);
                }
                if (!dotSumMap.contains(dot2)) {
                    if (dot2 < 0.000) {
                        score += dot2 * 500;
                        //logger.info("score  score += dot2 * 500;  " + score);
                    } else if (dot2 < 0.1) {
                        score += 256;
                        //logger.info("score   score += 256;  " + score);
                    }
                    if (dot2 > 0.50) {
                        score -= 1200;
                        //logger.info("score score -= 1200;  " + score);
                    }
                    dotSumMap.add(dot2);
                } else if (dot2 > 0.050 && dot2 < 0.10) {
                    score -= 350;
                    //logger.info("score  score -= 350; " + score);
                } else if ((dot2 > 3.0 && dot2 < 9.25) || punish_overhead) {
                    score -= dot2 * 1557;
                    //logger.info("score  score -= dot2 * 1557; " + score);
                } else if (dot2 > 9.25 && dot2 < 10.0) {
                    score += dot2 * 2934;
                    //logger.info("score score += dot2 * 2934; " + score);
                } else if (dot2 > 1.0 && dot2 < 3.0) {
                    score -= dot2 * 584;
                    //logger.info("score score -= dot2 * 584; " + score);
                } else if (dot1 != elementSum1 && dot2 * 3 > elementSum1 && elementSum1 * 3 > dot2) {
                    score -= 6556;
                    //logger.info("score  score -= 6556; " + score);
                }
                if (!elementSumMap.contains(elementSum2)) {
                    if (elementSum2 < 0.01 && elementSum2 > 0.00) {
                        score += 3300;
                        //logger.info("score   score += 3300; " + score);
                    } else if (elementSum2 > 0.1 && elementSum2 < 0.2) {
                        score += 6790;
                        //logger.info("score  score += 6790; " + score);
                    } else {
                        score -= elementSum2 * 1024;
                        //logger.info("score  score -= elementSum2 * 1024; " + score);
                    }
                    elementSumMap.add(elementSum2);
                } else if (elementSum2 > 0.050 && elementSum2 < 0.10) {
                    score += 750;
                    //logger.info("score  score += 750; " + score);
                } else if (elementSum2 > 1.0 && elementSum2 < 10.0) {
                    score -= 377 * elementSum2;
                    //logger.info("elementSum2: " + elementSum2);
                    //logger.info("score  score -= 417 * elementSum2; " + score);
                } else if (dot2 != elementSum2 && dot2 * 3 < elementSum1 && elementSum1 * 3 < dot2) {
                    score -= 7501;
                    //logger.info("score post score -= 7501;" + score);
                }
            }
        }
        if (iterateSize > 5) {
            score -= iterateSize * 400;
            //logger.info("score   score -= iterateSize * 400; " + score);
        }
        score = elementsAndDotsRelation(score, dotMap, elementSumCounter);
        //logger.info("score   score = elementsAndDotsRelation(score, dotMap, elementSumCounter); " + score);
        return score;
    }

    private Double elementsAndDotsRelation(Double
                                                   score, ArrayList<Double> dotMap, ArrayList<Double> elementSumCounter) {
        OptionalDouble minvalueDots = dotMap.stream().mapToDouble(Double::doubleValue).min();
        OptionalDouble maxvalueDots = dotMap.stream().mapToDouble(Double::doubleValue).max();
        boolean permitted = false;
        if (minvalueDots.getAsDouble() != maxvalueDots.getAsDouble()) {
            permitted = true;
        }
        if (permitted) {
            Double dotsVariance = maxvalueDots.getAsDouble() - minvalueDots.getAsDouble();
            if (maxvalueDots.getAsDouble() > minvalueDots.getAsDouble() * 10 && (dotsVariance < 0.40
                    || dotsVariance > 0.60)) {
                score -= 5535;
                //logger.info("score post score -= 5535; + score");
            } else if (minvalueDots.getAsDouble() < -0.10) {
                score -= 3551;
                //logger.info("score post score -= 3551; + score");
            } else if (dotsVariance > minvalueDots.getAsDouble() * 2) {
                score += 3500;
                //logger.info("score post score -= 3551; + score");
            } else if (minvalueDots.getAsDouble() * 2 > maxvalueDots.getAsDouble()) {
                score -= 3500;
                //logger.info("score post score -= 3551; + score");
            }
        }
        OptionalDouble minvalueElements = elementSumCounter.stream().mapToDouble(Double::doubleValue).min();
        OptionalDouble maxvalueElements = elementSumCounter.stream().mapToDouble(Double::doubleValue).max();
        Double elementsVariance = maxvalueElements.getAsDouble() - minvalueElements.getAsDouble();
        if (elementsVariance != 0.0) {
            if (elementsVariance <= 0.01 && maxvalueElements.getAsDouble() <= 0.02) {
                if (maxvalueElements.getAsDouble() < 0.01 && minvalueElements.getAsDouble() > -0.02 && minvalueElements.getAsDouble() < 0.0) {
                    score += 6500;
                } else {
                    score -= 5500;
                }
            } else if (minvalueElements.getAsDouble() < 0.0 && minvalueElements.getAsDouble() - maxvalueElements.getAsDouble() < 0.50) {
                score -= 4500;
            } else if (elementsVariance * 2 >= maxvalueElements.getAsDouble() && elementsVariance < 0.1) {
                score -= elementsVariance * 86000;
            }
        } else if (maxvalueElements.getAsDouble() == minvalueElements.getAsDouble() && maxvalueElements.getAsDouble() > 0.40
                && maxvalueElements.getAsDouble() < 0.60) {
            score += 600;
        } else if (maxvalueElements.getAsDouble() < 0.20 && minvalueElements.getAsDouble() >= 0.15) {
            score += 2600;
        } else if (maxvalueElements.getAsDouble() == minvalueElements.getAsDouble() && minvalueElements.getAsDouble() == 0.12) {
            score += 2600;
        }
        return score;
    }

    private Double sentimentMatrixVariances(Double score, int longest1, int longest2, int mainSentiment1,
                                            int mainSentiment2) {
        //logger.info("longest1: " + longest1);
        //logger.info("longest2: " + longest2);
        //logger.info("mainSentiment1: " + mainSentiment1);
        //logger.info("mainSentiment2: " + mainSentiment2);
        if (longest2 > 12 && longest2 < 16) {
            score -= 9988;
            //logger.info("score post score -= 9988;: " + score);
        }
        if (longest1 > 44 && longest1 < 48) {
            score += 7903;
            //logger.info("score post score += 7903; " + score);
        }
        if (longest1 != longest2) {
            long deffLongest = longest1 > longest2 ? longest1 : longest2;
            long deffshorter = longest1 < longest2 ? longest1 : longest2;
            if (deffLongest > deffshorter * 5) {
                score -= 5500;
            } else if (deffLongest < (deffshorter * 2) - 1 && deffLongest - deffshorter <= 45) {
                score += (deffLongest - deffshorter) * 20;
            } else if (mainSentiment1 != mainSentiment2 && deffLongest - deffshorter > 20 && deffLongest - deffshorter < 45) {
                score += (deffLongest - deffshorter) * 20;
            } else if (deffLongest - deffshorter < 2) {
                score += (deffLongest - deffshorter) * 20;
            } else if (deffshorter * 2 >= deffLongest && deffshorter * 2 < deffLongest + 5) {
                score += (deffLongest - deffshorter) * 20;
            } else {
                score -= (deffLongest - deffshorter) * 50;
            }
            if (deffLongest - deffshorter <= 5) {
                if (deffLongest < 24 && deffshorter > 20) {
                    score += 4500;
                } else if (deffLongest - deffshorter == 5 && deffshorter >= 19 && deffLongest <= 24) {
                    score += 4500;
                } else {
                    if (deffshorter > 26 && deffLongest < 35) {
                        score += 3900;
                    } else if (deffLongest - deffshorter == 1 && deffshorter > 15 && deffLongest < 25) {
                        score += 4900;
                    } else {
                        score -= 1900;
                    }
                }
            }
        }
        return score;
    }

    private int classifyRawEvaluation() {
        final List classifyRaw1 = this.listF;
        final List classifyRaw2 = this.list1;
        //logger.info("classifyRaw1 size: " + classifyRaw1.size());
        //logger.info("classifyRaw2 size: " + classifyRaw2.size());
        int increaseCount = 992;
        if (classifyRaw1.size() == 2) {
            increaseCount += 5500;
        }
        return (classifyRaw1.size() > classifyRaw2.size() ? classifyRaw1.size() -
                classifyRaw2.size() : classifyRaw2.size() - classifyRaw1.size()) * increaseCount;
    }

    private Double entryCountsRelation(Double
                                               score, ArrayList<Integer> cacheSentimentLocal1, ArrayList<Integer> cacheSentimentLocal2) {
        int entry1 = cacheSentimentLocal1.size();
        int entry2 = cacheSentimentLocal2.size();
        //logger.info("entry1: " + entry1);
        //logger.info("entry2: " + entry2);
        if (entry1 == 20 && entry2 > 0 && entry1 >= entry2) {
            score += 5894 * entry1;
            //logger.info("score post score += 5894 * entry1;: " + score);
        }
        if (entry1 > 0 && entry2 > 0) {
            if ((entry1 >= entry2 * 5) || (entry2 >= entry1 * 5)) {
                score -= entry1 > entry2 ? (entry1 - entry2) * 450 : (entry2 - entry1) * 450;
            } else if ((entry1 >= entry2 * 50 || entry2 >= entry1 * 50)) {
                score -= entry1 > entry2 ? entry1 * 180 : entry2 * 180;
            } else if ((entry1 >= entry2 * 2 || entry2 >= entry1 * 2) && entry1 * 2 >= entry2 && entry2 * 2 >= entry1) {
                score -= entry1 > entry2 ? (entry1 - entry2) * 450 : (entry2 - entry1) * 450;
            } else if (entry1 * 3 >= entry2 && entry2 * 3 >= entry1) {
                score -= entry1 > entry2 ? (entry1 - entry2) * 550 : (entry2 - entry1) * 550;
            } else if (entry1 > 10 && entry2 > 10 && entry1 * 2 > entry2 && entry2 * 2 > entry1) {
                score += entry1 > entry2 ? entry2 * 600 : entry1 * 600;
            }
        }
        return score;
    }

    private ArrayList<TypedDependency> grammaticalStructureAllTypedDependencies(
            ArrayList<GrammaticalStructure> grammaticalStructures) {
        ArrayList<TypedDependency> typedDependenciesArr = new ArrayList<>();
        for (GrammaticalStructure gs : grammaticalStructures) {
            Collection<TypedDependency> typedDependencies = gs.allTypedDependencies();
            typedDependenciesArr.addAll(typedDependencies);
        }
        return typedDependenciesArr;
    }

    private ArrayList<GrammaticalStructure> grammaticalStructureSetup(ArrayList<Tree> trees) {
        ArrayList<GrammaticalStructure> grammaticalStructures = new ArrayList<GrammaticalStructure>();
        for (Tree tree : trees) {
            try {
                if (!tree.isEmpty()) {
                    GrammaticalStructure gs = gsf.newGrammaticalStructure(tree);
                    grammaticalStructures.add(gs);
                }
            } catch (NoSuchElementException e) {

            }
        }
        return grammaticalStructures;
    }

    private ArrayList<Tree> retrieveTrees(List<CoreMap> sentences) {
        ArrayList<Tree> treeList = new ArrayList<Tree>();
        for (CoreMap sentence : sentences) {
            Tree sentenceConstituencyParse = sentence.get(TreeCoreAnnotations.TreeAnnotation.class);
            treeList.add(sentenceConstituencyParse);
        }
        return treeList;
    }

    private ArrayList<SimpleMatrix> sentimentRNNCorePredicted(List<CoreMap> sentences,
                                                              Class<SentimentCoreAnnotations.SentimentAnnotatedTree> sentimentAnnotatedTreeClass) {
        ArrayList<SimpleMatrix> rnnCoreAnnotationsPrediction = new ArrayList<>();
        for (CoreMap sentence : sentences) {
            Tree tree = sentence.get(sentimentAnnotatedTreeClass);
            if (tree != null) {
                SimpleMatrix predictions = RNNCoreAnnotations.getPredictions(tree);
                rnnCoreAnnotationsPrediction.add(predictions);
            }
        }
        return rnnCoreAnnotationsPrediction;
    }

    private ArrayList<SimpleMatrix> sentimentRNNCoreNodevectors(List<CoreMap> sentences,
                                                                Class<SentimentCoreAnnotations.SentimentAnnotatedTree> sentimentAnnotatedTreeClass) {
        ArrayList<SimpleMatrix> rnnCoreAnnotationsNodevectors = new ArrayList<>();
        for (CoreMap sentence : sentences) {
            Tree tree = sentence.get(sentimentAnnotatedTreeClass);
            if (tree != null) {
                SimpleMatrix nodeVector = RNNCoreAnnotations.getNodeVector(tree);
                rnnCoreAnnotationsNodevectors.add(nodeVector);
            }
        }
        return rnnCoreAnnotationsNodevectors;
    }

    private ArrayList<Integer> sentimentRNNCoreAnnotations(List<CoreMap> sentences,
                                                           Class<SentimentCoreAnnotations.SentimentAnnotatedTree> sentimentAnnotatedTreeClass) {
        ArrayList<Integer> rnnCoreAnnotationsPredicted = new ArrayList<>();
        for (CoreMap sentence : sentences) {
            Tree tree = sentence.get(sentimentAnnotatedTreeClass);
            if (tree != null) {
                int predictedClass = RNNCoreAnnotations.getPredictedClass(tree);
                rnnCoreAnnotationsPredicted.add(predictedClass);
            }
        }
        return rnnCoreAnnotationsPredicted;
    }

    private int setupMainSentiment(List<CoreMap> sentences4,
                                   Class<SentimentCoreAnnotations.SentimentAnnotatedTree> sentimentAnnotatedTreeClass) {
        int longest = 0;
        int longestSentiment = 0;
        for (CoreMap sentence : sentences4) {
            Tree tree = sentence.get(sentimentAnnotatedTreeClass);
            int sentiment = RNNCoreAnnotations.getPredictedClass(tree);
            String partText = sentence.toString();
            if (partText.length() > longest) {
                longestSentiment = sentiment;
                longest = partText.length();
            }
        }
        return longestSentiment;
    }

    private int setupMainLongest(List<CoreMap> sentences) {
        int longest = 0;
        for (CoreMap sentence : sentences) {
            String partText = sentence.toString();
            if (partText.length() > longest) {
                longest = partText.length();
            }
        }
        return longest;
    }

    private Double entryCountsScoring(Double
                                              score, ArrayList<Integer> cacheSentimentLocal1, ArrayList<Integer> cacheSentimentLocal2) {
        ArrayList<Integer> countsMap = new ArrayList<Integer>();
        int totalsize = cacheSentimentLocal1.size() + cacheSentimentLocal2.size();
        //logger.info("cacheSentimentLocal1.size(): " + cacheSentimentLocal1.size());
        //logger.info("cacheSentimentLocal2.size(): " + cacheSentimentLocal2.size());
        if ((cacheSentimentLocal1.size() == 20 && cacheSentimentLocal2.size() < 10)
                || (cacheSentimentLocal2.size() == 20 && cacheSentimentLocal1.size() < 10)
                && cacheSentimentLocal1.size() > 0 && cacheSentimentLocal2.size() > 0) {
            score += 46843;
            //logger.info("score post score += 45843;" + score);
        }
        for (int counts : cacheSentimentLocal1) {
            for (int counts1 : cacheSentimentLocal2) {
                if (counts > 0 && counts1 > 0) {
                    if (counts == counts1 && !countsMap.contains(counts)) {
                        score += (counts * 250) / totalsize;
                        //logger.info("score post score += (counts * 250) / totalsize; " + score);
                        countsMap.add(counts);
                    } else if (counts * 3 < counts1 || counts1 * 3 < counts) {
                        score -= 929;
                        //logger.info("score post score -= 929;" + score);
                    }
                }
            }
        }
        return score;
    }

    private Double tokenEntryPosScoring(Double
                                                score, ArrayList<String> cacheSentimentLocal1, ArrayList<String> cacheSentimentLocal2) {
        if (cacheSentimentLocal1.size() > 1 && cacheSentimentLocal2.size() > 1) {
            for (String strTokenPos1 : cacheSentimentLocal1) {
                for (String strTokenPos2 : cacheSentimentLocal2) {
                    if (strTokenPos1.equals(strTokenPos2)) {
                        score += 500;
                    }
                }
            }
            int posEntrySize1 = cacheSentimentLocal1.size();
            int posEntrySize2 = cacheSentimentLocal2.size();
            if (posEntrySize1 * 3 > posEntrySize2 && posEntrySize2 * 3 > posEntrySize1) {
                score += posEntrySize1 > posEntrySize2 ? (posEntrySize1 - posEntrySize2) * 700 : (posEntrySize2 - posEntrySize1) * 700;
            }
        }
        return score;
    }

    private Double unmarkedPatternCounterScoring(Double score, int UnmarkedPatternCounter1,
                                                 int UnmarkedPatternCounter2) {
        //logger.info("UnmarkedPatternCounter1: " + UnmarkedPatternCounter1);
        //logger.info("UnmarkedPatternCounter2: " + UnmarkedPatternCounter2);
        if (UnmarkedPatternCounter1 > 0 && UnmarkedPatternCounter2 > 0) {
            if (UnmarkedPatternCounter1 < 100 && UnmarkedPatternCounter2 < 100) {
                if (UnmarkedPatternCounter1 * 2 > UnmarkedPatternCounter2 && UnmarkedPatternCounter2 * 2 > UnmarkedPatternCounter1) {
                    score += 2500;
                } else if (UnmarkedPatternCounter1 * 5 < UnmarkedPatternCounter2 || UnmarkedPatternCounter2 * 5 < UnmarkedPatternCounter1) {
                    score -= 4000;
                }
            } else if (UnmarkedPatternCounter1 > 500 && UnmarkedPatternCounter2 > 500) {
                score -= UnmarkedPatternCounter1 >= UnmarkedPatternCounter2 ? UnmarkedPatternCounter1 * 3 : UnmarkedPatternCounter2 * 3;
            }
        }
        return score;
    }

    private Double markedContiniousCounterScoring(Double score, int MarkedContinuousCounter1,
                                                  int MarkedContinuousCounter2) {
        int MarkedContiniousCounter1Entries = MarkedContinuousCounter1;
        int MarkedContiniousCounter2Entries = MarkedContinuousCounter2;
        if (MarkedContinuousCounter1 > 0 && MarkedContinuousCounter2 > 0) {
            if (MarkedContinuousCounter1 > MarkedContinuousCounter2 * 50 || MarkedContinuousCounter2 > MarkedContinuousCounter1 * 50) {
                score -= MarkedContinuousCounter1 > MarkedContinuousCounter2 ? MarkedContinuousCounter1 * 120 : MarkedContinuousCounter2 * 120;
            } else if (!Objects.equals(MarkedContiniousCounter1Entries, MarkedContiniousCounter2Entries)
                    && (MarkedContinuousCounter1 * 2 >= MarkedContinuousCounter2 * MarkedContinuousCounter1)
                    || (MarkedContinuousCounter2 * 2 >= MarkedContinuousCounter1 * MarkedContinuousCounter2)) {
                score += 4500;
            } else if (MarkedContiniousCounter1Entries == 0 || MarkedContiniousCounter2Entries == 0) {
                score += MarkedContinuousCounter1 > MarkedContinuousCounter2 ? (MarkedContinuousCounter2 - MarkedContinuousCounter1) * 500
                        : (MarkedContinuousCounter1 - MarkedContinuousCounter2) * 500;
            }
            if (MarkedContiniousCounter1Entries > 0 && MarkedContiniousCounter2Entries > 0 && MarkedContinuousCounter1 > 0
                    && MarkedContinuousCounter2 > 0 && MarkedContinuousCounter1 < MarkedContinuousCounter2 * 10
                    && MarkedContinuousCounter2 < MarkedContinuousCounter1 * 10) {
                if (MarkedContiniousCounter1Entries > MarkedContiniousCounter2Entries * 5
                        || MarkedContiniousCounter2Entries > MarkedContiniousCounter1Entries * 5
                        || MarkedContiniousCounter1Entries * 5 < MarkedContinuousCounter1
                        || MarkedContiniousCounter1Entries * 5 < MarkedContinuousCounter2
                        || MarkedContiniousCounter2Entries * 5 < MarkedContinuousCounter1
                        || MarkedContiniousCounter2Entries * 5 < MarkedContinuousCounter2) {
                    score -= MarkedContinuousCounter1 > MarkedContinuousCounter2 ? MarkedContinuousCounter1 * 400 : MarkedContinuousCounter2 * 400;
                }
            }
        }
        return score;
    }

    private Double strTokensMapScoring(Double score, ArrayList<String> cacheSentimentLocal1,
                                       ArrayList<String> cacheSentimentLocal2) {
        ArrayList<String> strtokensMap = new ArrayList<String>();
        //logger.info("cacheSentimentLocal1 size: " + cacheSentimentLocal1.size());
        //logger.info("cacheSentimentLocal2 size: " + cacheSentimentLocal2.size());
        for (String strTokeniPart1 : cacheSentimentLocal1) {
            for (String strTokeniPart2 : cacheSentimentLocal2) {
                if (strTokeniPart1.equals(strTokeniPart2) && !strtokensMap.contains(strTokeniPart2)) {
                    strtokensMap.add(strTokeniPart2);
                    score += 3883;
                    //logger.info("score post score += 3883; " + score);
                }
            }
        }
        int tokenIPartSize1 = cacheSentimentLocal1.size();
        int tokenIPartSize2 = cacheSentimentLocal2.size();
        int strTokenMapSize = strtokensMap.size();
        if (tokenIPartSize1 * 2 > tokenIPartSize2 && tokenIPartSize2 * 2 > tokenIPartSize1) {
            score += tokenIPartSize1 > tokenIPartSize2 ? (tokenIPartSize1 - tokenIPartSize2) * 700 : (tokenIPartSize2 - tokenIPartSize1) * 700;
            score += strTokenMapSize * 600;
        } else if (tokenIPartSize1 > 0 && tokenIPartSize2 > 0) {
            score -= tokenIPartSize1 > tokenIPartSize2 ? (tokenIPartSize1 - tokenIPartSize2) * 700 : (tokenIPartSize2 - tokenIPartSize1) * 700;
        }
        return score;
    }

    private Double strTokenEntryScoring(Double score, ArrayList<String> cacheSentimentLocal1,
                                        ArrayList<String> cacheSentimentLocal2) {
        int tokenEntry1 = cacheSentimentLocal1.size();
        int tokenEntry2 = cacheSentimentLocal2.size();
        boolean boundaryLeaks = false;
        int remnantCounter = 0;
        if (tokenEntry1 * 2 != tokenEntry2 && tokenEntry2 * 2 != tokenEntry1) {
            boundaryLeaks = true;
        }
        ArrayList<String> entryTokenMap = new ArrayList<String>();
        for (String strTokenEntry1 : cacheSentimentLocal1) {
            for (String strTokenEntry2 : cacheSentimentLocal2) {
                if (!entryTokenMap.contains(strTokenEntry2)) {
                    if (strTokenEntry1.equals(strTokenEntry2)) {
                        score += boundaryLeaks ? 2500 : 2500 / 2;
                        //logger.info("score post   score += boundaryLeaks ? 2500 : 2500 / 2; : " + score);
                    } else if (!boundaryLeaks) {
                        score -= 450;
                        //logger.info("score post  score -= 450;: " + score);
                    } else {
                        remnantCounter++;
                    }
                }
                entryTokenMap.add(strTokenEntry2);
            }
        }
        //logger.info("tokenEntry2: " + tokenEntry2);
        //logger.info("tokenEntry1: " + tokenEntry1);
        //logger.info("remnantCounter: " + remnantCounter);
        //logger.info("boundaryLeaks: " + boundaryLeaks);
        if (tokenEntry1 == 1) {
            score -= 9453;
            //logger.info("score post score -= 9453;: " + score);
        }
        if (remnantCounter == 1) {
            score -= 4083;
            //logger.info("score post score -= 4083;: " + score);
        }
        if (tokenEntry2 == 2) {
            score += 4563;
            //logger.info("score score += 4563; " + score);
        }
        score += remnantCounter * 250;
        //logger.info("score post  score += remnantCounter * 250;: " + score);
        return score;
    }

    private Double strTokenMapTagsScoring(Double
                                                  score, ArrayList<String> cacheSentimentLocal1, ArrayList<String> cacheSentimentLocal2) {
        ArrayList<String> iTokenMapTagsMap = new ArrayList<String>();
        for (String strmapTag : cacheSentimentLocal1) {
            for (String strmapTag1 : cacheSentimentLocal2) {
                if (strmapTag.equals(strmapTag1) && !iTokenMapTagsMap.contains(strmapTag1)) {
                    score -= 1450;
                    iTokenMapTagsMap.add(strmapTag);
                }
            }
        }
        int mapTagsize1 = cacheSentimentLocal1.size();
        int mapTagsize2 = cacheSentimentLocal2.size();
        int tokenTagMapSize = iTokenMapTagsMap.size();
        if (mapTagsize1 != 0 && mapTagsize2 != 0) {
            if (mapTagsize1 * 2 > mapTagsize2 && mapTagsize2 * 2 > mapTagsize1) {
                score += mapTagsize1 > mapTagsize2 ? (mapTagsize1 - mapTagsize2) * 700 : (mapTagsize2 - mapTagsize1) * 700;
                score += tokenTagMapSize * 600;
            } else {
                score -= mapTagsize1 > mapTagsize2 ? (mapTagsize1 - mapTagsize2) * 700 : (mapTagsize2 - mapTagsize1) * 700;
            }
        }
        return score;
    }

    private Double tokenformSizeScoring(Double
                                                score, ArrayList<String> cacheSentimentLocal1, ArrayList<String> cacheSentimentLocal2) {
        int tokenform1size = cacheSentimentLocal1.size();
        int tokenform2size = cacheSentimentLocal2.size();
        if (tokenform1size > 0 || tokenform2size > 0) {
            if (tokenform1size < tokenform2size * 5 && tokenform2size < tokenform1size * 5) {
                for (String strTokenForm1itr1 : cacheSentimentLocal1) {
                    for (String strTokenForm1itr2 : cacheSentimentLocal2) {
                        if (strTokenForm1itr1.equals(strTokenForm1itr2)) {
                            score -= 1600;
                        } else {
                            score += 500;
                        }
                    }
                }
            } else if (tokenform1size > 0 && tokenform2size > 0) {
                if (tokenform1size * 2 >= tokenform2size && tokenform2size * 2 >= tokenform1size) {
                    score += tokenform1size > tokenform2size ? tokenform1size * 600 : tokenform2size * 600;
                } else if (tokenform1size * 4 <= tokenform2size || tokenform2size * 4 <= tokenform1size) {
                    score -= tokenform1size > tokenform2size ? (tokenform1size - tokenform2size) * 600 : (tokenform2size - tokenform1size) * 600;
                }
            }
        }
        return score;
    }

    private Double tokenStemmingMapScoring(Double
                                                   score, ArrayList<String> cacheSentimentLocal1, ArrayList<String> cacheSentimentLocal2) {
        ArrayList<String> tokenStemmingMap = new ArrayList<String>();
        for (String strTokenStem : cacheSentimentLocal1) {
            for (String strTokenStem1 : cacheSentimentLocal2) {
                if (strTokenStem.equals(strTokenStem1) && !tokenStemmingMap.contains(strTokenStem)) {
                    score += 500;
                    tokenStemmingMap.add(strTokenStem);
                }
            }
        }
        return score;
    }

    private Double inflectedCounterScoring(Double score, int inflectedCounterPositive1,
                                           int inflectedCounterPositive2,
                                           int inflectedCounterNegative1, int inflectedCounterNegative2) {
        int inflectedCounterNegative = inflectedCounterNegative1 > inflectedCounterNegative1
                ? inflectedCounterNegative1 - inflectedCounterNegative2
                : inflectedCounterNegative2 - inflectedCounterNegative1;
        if ((inflectedCounterPositive1 + inflectedCounterPositive2) > inflectedCounterNegative && inflectedCounterNegative > 0) {
            score += ((inflectedCounterPositive1 + inflectedCounterPositive2) - inflectedCounterNegative) * 650;
        }
        if (inflectedCounterPositive1 > 0 && inflectedCounterPositive2 > 0) {
            if (inflectedCounterPositive1 * 2 > inflectedCounterPositive2 && inflectedCounterPositive2 * 2 > inflectedCounterPositive1
                    && inflectedCounterNegative > 0) {
                score += ((inflectedCounterPositive1 + inflectedCounterPositive2) * 150) - (inflectedCounterNegative * 10);
            } else if (inflectedCounterPositive1 * 5 < inflectedCounterPositive2 || inflectedCounterPositive2 * 5 < inflectedCounterPositive1) {
                score -= inflectedCounterPositive1 > inflectedCounterPositive2 ? (inflectedCounterPositive1 - inflectedCounterPositive2) * 400
                        : (inflectedCounterPositive2 - inflectedCounterPositive1) * 400;
            }
        }
        if (inflectedCounterPositive1 >= 15 && inflectedCounterPositive2 >= 15) {
            score -= 4000;
        }
        return score;
    }

    private Double annotatorCountScoring(Double score, int anotatorcounter1, int anotatorcounter2) {
        if (anotatorcounter1 > 1 && anotatorcounter2 > 1) {
            if (anotatorcounter1 * 2 > anotatorcounter2 && anotatorcounter2 * 2 > anotatorcounter1) {
                score += anotatorcounter1 > anotatorcounter2 ? (anotatorcounter1 - anotatorcounter2) * 700
                        : (anotatorcounter2 - anotatorcounter1) * 700;
            } else if (anotatorcounter1 * 5 < anotatorcounter2 || anotatorcounter2 * 5 < anotatorcounter1) {
                score -= anotatorcounter1 > anotatorcounter2 ? (anotatorcounter1 - anotatorcounter2) * 400 : (anotatorcounter2 - anotatorcounter1) * 400;
            }
        }
        return score;
    }

    private Double tokensCounterScoring(Double score, int tokensCounter1, int tokensCounter2) {
        if ((tokensCounter1 > 1 && tokensCounter2 > 1) && tokensCounter1 < tokensCounter2 * 5 && tokensCounter2 < tokensCounter1 * 5) {
            if (tokensCounter1 > tokensCounter2 / 2 && tokensCounter2 > tokensCounter1 / 2 && tokensCounter1 < 10 && tokensCounter2 < 10) {
                score += (tokensCounter1 + tokensCounter2) * 500;
                //logger.info("score post score += (tokensCounter1 + tokensCounter2) * 500;" + score);
            } else {
                score -= 503;
                //logger.info("Score post  score -= 503; :" + score);
            }
        } else {
            int elseint = tokensCounter1 >= tokensCounter2 ? (tokensCounter1 - tokensCounter2) * 500 : (tokensCounter2 - tokensCounter1) * 500;
            if ((tokensCounter1 > tokensCounter2 * 5 || tokensCounter2 > tokensCounter1 * 5)
                    && tokensCounter1 > 0 && tokensCounter2 > 0) {
                score -= tokensCounter1 > tokensCounter2 ? (tokensCounter1 - tokensCounter2) * 500 : (tokensCounter2 - tokensCounter1) * 500;
                //logger.info("Score post   score -= tokensCounter1 > tokensCounter2 ? (tokensCounter1 - tokensCounter2) * 500 : (tokensCounter2 - tokensCounter1) * 500; :" + score);
            } else if (elseint > 0 && tokensCounter1 > 0 && tokensCounter2 > 0) {
                if (elseint > 500 && elseint < 2000) {
                    score += elseint * 35;
                    //logger.info("Score post  score += elseint * 35; :" + score);
                } else {
                    score -= elseint * 34;
                    //logger.info("Score post  score -= elseint * 34; :" + score);
                }
            } else {
                //logger.info("tokensCounter1: " + tokensCounter1);
                //logger.info("tokensCounter2 " + tokensCounter2);
                //logger.info("elseint: " + elseint);
                if (tokensCounter1 == 0 && tokensCounter2 == 1 && elseint == 500) {
                    score += 3012;
                    ////logger.info("score post : score += 3012;" + score);
                }
                if (elseint > 0 && elseint < 1500 && (tokensCounter1 > 0 || tokensCounter2 > 0) && tokensCounter1 <= 2 && tokensCounter2 <= 2) {
                    score += elseint * 1.5;
                    //logger.info("Score post score += elseint * 1.5;  :" + score);
                } else if (elseint == 0 && tokensCounter1 == 0 && tokensCounter2 == 0) {
                    score += 3064;
                    //logger.info("score post score += 3064;  : " + score);
                } else if (tokensCounter1 < 5 && tokensCounter2 < 5) {
                    score -= elseint * (tokensCounter1 + tokensCounter2);
                    //logger.info("Score post  score -= elseint * (tokensCounter1 + tokensCounter2); :" + score);
                }
            }
        }
        return score;
    }

    private Double nerEntitiesAndTokenScoring(Double score, ArrayList<String> entityTokenTags1,
                                              ArrayList<String> entityTokenTags2, ArrayList<String> nerEntities1,
                                              ArrayList<String> nerEntities2) {
        List<String> entsCollection = new ArrayList();
        for (String strEnts1 : nerEntities1) {
            for (String strEnts2 : nerEntities2) {
                if (strEnts1.equalsIgnoreCase(strEnts2) && !entsCollection.contains(strEnts1)) {
                    score += 2500;
                    entsCollection.add(strEnts1);
                }
            }
        }
        entsCollection = new ArrayList();
        for (String strToken : entityTokenTags1) {
            for (String strToken1 : entityTokenTags2) {
                if (strToken.equalsIgnoreCase(strToken1) && !entsCollection.contains(strToken)) {
                    score += 2000;
                    entsCollection.add(strToken);
                }
            }
        }
        return score;
    }

    private Double stopWordTokenLemmaScoring(Double score, ArrayList<String> stopWordToken1,
                                             ArrayList<String> stopWordToken2, ArrayList<String> stopWordLemma1,
                                             ArrayList<String> stopWordLemma2) {
        Collection<String> stopWordCollection = new ArrayList();
        //logger.info("stopWordToken1 size: " + stopWordToken1.size());
        //logger.info("stopWordToken2 size: " + stopWordToken2.size());
        //logger.info("stopWordLemma1 size: " + stopWordLemma1.size());
        //logger.info("stopWordLemma2 size: " + stopWordLemma2.size());
        if (stopWordLemma2.size() >= 5) {
            score -= 9304;
            //logger.info("score post  score -= 9304");
        }
        if (stopWordLemma1.size() == 3 && stopWordLemma2.size() == 3 && stopWordToken1.size() == 2
                && stopWordToken2.size() == 2) {
            score += 7392;
            //logger.info("score post  score += 7392;: " + score);
        }
        for (String stopwords1 : stopWordToken1) {
            for (String stopwords2 : stopWordToken2) {
                if (stopwords1.equals(stopwords2) && !stopWordCollection.contains(stopwords1)) {
                    if (stopWordToken1.size() == stopWordToken2.size() && stopWordLemma1.size() == stopWordToken2.size() &&
                            stopWordLemma1.size() == 1 && stopWordToken1.size() == 1) {
                        score += 4103;
                        //logger.info("score post  score += 4103; : " + score);
                    } else if (stopWordLemma2.size() == 3 && stopWordLemma1.size() == 3 && stopWordToken1.size() == 3) {
                        score += 545;
                        //logger.info("score post score += 2345;: " + score);
                    } else if (stopWordLemma1.size() == 1 && stopWordToken1.size() == 0) {
                        score -= 8530;
                        //logger.info("score postscore -= 8530;: " + score);
                        stopWordCollection.add(stopwords1);
                    } else if ((stopWordLemma1.size() >= 4 || stopWordLemma2.size() >= 4)
                            && (stopWordToken1.size() >= stopWordLemma1.size() ||
                            stopWordToken2.size() >= stopWordLemma2.size())) {
                        score -= 8654;
                        //logger.info("score post score -= 8654; :" + score);
                        //logger.info("stopWordLemma1.size(): " + stopWordLemma1.size());
                        //logger.info("stopWordToken1.size(): " + stopWordToken1.size());
                        //logger.info("stopWordLemma2.size(): " + stopWordLemma2.size());
                        //logger.info("stopWordToken2.size(): " + stopWordToken2.size());
                    } else if (stopWordLemma1.size() == 2 && stopWordToken1.size() == 2) {
                        score += 2479;
                        //logger.info("score post score += 2479; : " + score);
                    }
                }
            }
        }
        stopWordCollection = new ArrayList();
        for (String stopwords1 : stopWordLemma1) {
            for (String stopwords2 : stopWordLemma2) {
                if (stopwords1.equals(stopwords2) && !stopWordCollection.contains(stopwords1)) {
                    score -= 51;
                    //logger.info("score post  score -= 51; " + score);
                    stopWordCollection.add(stopwords1);
                }
            }
        }
        return score;
    }

    private Double stopwordTokenPairCounterScoring(Double score, ArrayList<String> stopWordToken1,
                                                   ArrayList<String> stopWordToken2, int pairCounter1,
                                                   int pairCounter2) {
        if (!stopWordToken1.isEmpty() && !stopWordToken2.isEmpty()) {
            int stopwordsize1 = stopWordToken1.size();
            int stopwordsize2 = stopWordToken2.size();
            //logger.info("stopwordsize1: " + stopwordsize1);
            //logger.info("stopwordsize2: " + stopwordsize2);
            if (stopwordsize1 * 5 < stopwordsize2 || stopwordsize2 * 5 < stopwordsize1) {
                score -= stopwordsize1 > stopwordsize2 ? (stopwordsize1 - stopwordsize2) * 850 : (stopwordsize2 - stopwordsize1) * 850;
                //logger.info("score post  score -= stopwordsize1 > stopwordsize2 ? (stopwordsize1 - stopwordsize2) * 850 : (stopwordsize2 - stopwordsize1) * 850;: " + score);
            } else if (stopwordsize1 == 2 && stopwordsize2 == 2) {
                score -= 7312;
                //logger.info("score post score -= 7312;: " + score);
            } else if (stopwordsize1 == stopwordsize2 && stopwordsize1 > 5) {
                score -= stopwordsize1 * 450;
                //logger.info("score post score -= stopwordsize1 * 450;: " + score);
            } else if ((stopwordsize1 / 2 == stopwordsize2 || stopwordsize2 / 2 == stopwordsize1) && stopwordsize1 + stopwordsize2 >= 4) {
                score -= 2500;
                //logger.info("score post  score -= 2500;: " + score);
            } else if (stopwordsize1 == 3 && stopwordsize2 == 3) {
                score += 4513;
                //logger.info("score post score += 4513;: " + score);
            }
        }
        if (pairCounter1 > 0 && pairCounter2 > 0) {
            //logger.info("pairCounter1: " + pairCounter1);
            //logger.info("pairCounter2: " + pairCounter2);
            if (pairCounter1 == 1 && pairCounter2 == 1) {
                score -= 2554;
                //logger.info("score post  score -= 2554;: " + score);
            }
            if (pairCounter1 * 5 <= pairCounter2 || pairCounter2 * 5 <= pairCounter1) {
                score -= pairCounter1 > pairCounter2 ? (pairCounter1 - pairCounter2) * 1500 : (pairCounter2 - pairCounter1) * 1500;
                //logger.info("score post score -= pairCounter1 > pairCounter2 ? (pairCounter1 - pairCounter2) * 1500 : (pairCounter2 - pairCounter1) * 1500;: " + score);
            } else if (pairCounter1 == pairCounter2 && pairCounter1 > 5) {
                score -= pairCounter1 * 450;
                //logger.info("score post  score -= pairCounter1 * 450; : " + score);
            } else if ((pairCounter1 / 2 == pairCounter2 || pairCounter2 / 2 == pairCounter1) && pairCounter1 + pairCounter2 >= 4) {
                score -= 2500;
                //logger.info("score post score -= 2500;: " + score);
            } else if (pairCounter1 == 3 && pairCounter2 == 3) {
                score -= 3212;
                //logger.info("score post score -= 3112; " + score);
            }
        }
        return score;
    }

    private Double tgwListScoreIncrementer(Double score, ArrayList<String> tgwListIndex1,
                                           ArrayList<String> tgwListIndex2) {
        int runCount = 0;
        for (String taggedWord : tgwListIndex1) {
            boolean found = false;
            for (String taggedWord1 : tgwListIndex2) {
                if (taggedWord.equals(taggedWord1)) {
                    found = true;
                    break;
                }
            }
            if (!found) {
                runCount++;
            }
        }
        score += runCount * 64;
        return score;
    }

    private List<IMWE<IToken>> getIMWES(List<CoreMap> coreMaps) {
        List<IMWE<IToken>> tokenList = new ArrayList<>();
        for (CoreMap sentence : coreMaps) {
            List<IMWE<IToken>> imwes = sentence.get(JMWEAnnotation.class);
            tokenList.addAll(imwes);
        }
        return tokenList;
    }

    private int getInflictedCounterPositive(List<IMWE<IToken>> imwesFLocal) {
        int InflectedCounterPositive = 0;
        for (IMWE<IToken> token : imwesFLocal) {
            if (token.isInflected()) {
                InflectedCounterPositive++;
            }
        }
        return InflectedCounterPositive;
    }

    private int getUnmarkedPatterns(List<IMWE<IToken>> imwesFLocal) {
        int unmarked = 0;
        for (IMWE<IToken> token : imwesFLocal) {
            IMWEDesc entry = token.getEntry();
            unmarked += entry.getUnmarkedPattern();
        }
        return unmarked;
    }

    private ArrayList<String> gettokenForms(List<IMWE<IToken>> imwesFLocal) {
        ArrayList<String> arrs = new ArrayList<>();
        for (IMWE<IToken> token : imwesFLocal) {
            String form = token.getForm();
            arrs.add(form);
        }
        return arrs;
    }

    private ArrayList<String> getStrtokenEntryPos(List<IMWE<IToken>> imwesFLocal) {
        ArrayList<String> arrs = new ArrayList<>();
        for (IMWE<IToken> token : imwesFLocal) {
            IMWEDesc entry = token.getEntry();
            for (String strPostPrefix : entry.getPOS().getPrefixes()) {
                arrs.add(strPostPrefix);
            }
        }
        return arrs;
    }

    private ArrayList<Integer> getintTokenEntyCounts(List<IMWE<IToken>> imwesFLocal) {
        ArrayList<Integer> arrs = new ArrayList<>();
        for (IMWE<IToken> token : imwesFLocal) {
            IMWEDesc entry = token.getEntry();
            for (int counts : entry.getCounts()) {
                arrs.add(counts);
            }
        }
        return arrs;
    }

    private ArrayList<String> getITokenTags(List<IMWE<IToken>> imwesFLocal) {
        ArrayList<String> arrs = new ArrayList<>();
        for (IMWE<IToken> token : imwesFLocal) {
            for (IToken tokens : token.getTokens()) {
                arrs.add(tokens.getTag());
            }
        }
        return arrs;
    }

    private ArrayList<String> getstrTokenStems(List<IMWE<IToken>> imwesFLocal) {
        ArrayList<String> arrs = new ArrayList<>();
        for (IMWE<IToken> token : imwesFLocal) {
            for (IToken tokens : token.getTokens()) {
                for (String strtoken : tokens.getStems()) {
                    arrs.add(strtoken);
                }
            }
        }
        return arrs;
    }

    private Integer getAnotatorcounter(List<IMWE<IToken>> imwesFLocal) {
        return imwesFLocal.size();
    }

    private ArrayList<String> getnerEntities(CoreDocument coreDocument) {
        if (coreDocument == null || coreDocument.entityMentions() == null) {
            return new ArrayList<String>();
        }
        ArrayList<String> arrs = new ArrayList<>();
        for (CoreEntityMention em : coreDocument.entityMentions()) {
            if (!arrs.contains(em.text())) {
                arrs.add(em.text());
            }
        }
        return arrs;
    }

    private ArrayList<String> getnerEntitiesType(CoreDocument coreDocument) {
        if (coreDocument == null || coreDocument.entityMentions() == null) {
            return new ArrayList<String>();
        }
        ArrayList<String> arrs = new ArrayList<>();
        for (CoreEntityMention em : coreDocument.entityMentions()) {
            if (!arrs.contains(em.entityType())) {
                arrs.add(em.entityType());
            }
        }
        return arrs;
    }

    private Integer getPairCounter(Annotation pipelineAnnotationSentiment) {
        int counter = 0;
        List<CoreLabel> tokensSentiment = pipelineAnnotationSentiment.
                get(CoreAnnotations.TokensAnnotation.class);
        for (CoreLabel token : tokensSentiment) {
            Pair<Boolean, Boolean> stopword = token.get(StopwordAnnotator.class);
            if (stopword.first() && stopword.second()) {
                counter++;
            }
        }
        return counter;
    }

    private ArrayList<String> getstopWordLemma(Annotation pipelineAnnotationSentiment) {
        ArrayList<String> arrs = new ArrayList<>();
        List<CoreLabel> tokensSentiment = pipelineAnnotationSentiment.
                get(CoreAnnotations.TokensAnnotation.class);
        String customStopWordList = "start,starts,period,periods,a,an,and,are,as,at,be,but,by,for," +
                "if,in,into,is,it,no,not,of,on,or,such,that,the,their,then,there,these," +
                "they,this,to,was,will,with";
        for (CoreLabel token : tokensSentiment) {
            Set<?> stopWords = StopAnalyzer.ENGLISH_STOP_WORDS_SET;
            Set<?> stopWordsCustom = StopwordAnnotator.getStopWordList(customStopWordList, true);
            if (token.lemma() != null) {
                String lemma = token.lemma().toLowerCase();
                if (stopWords.contains(lemma) || stopWordsCustom.contains(lemma)) {
                    arrs.add(lemma);
                }
            }
        }
        return arrs;
    }

    private ArrayList<String> getstopWordToken(Annotation pipelineAnnotationSentiment) {
        ArrayList<String> arrs = new ArrayList<>();
        List<CoreLabel> tokensSentiment = pipelineAnnotationSentiment.
                get(CoreAnnotations.TokensAnnotation.class);
        String customStopWordList = "start,starts,period,periods,a,an,and,are,as,at,be,but,by,for," +
                "if,in,into,is,it,no,not,of,on,or,such,that,the,their,then,there,these," +
                "they,this,to,was,will,with";
        for (CoreLabel token : tokensSentiment) {
            String word = token.word().toLowerCase();
            Set<?> stopWords = StopAnalyzer.ENGLISH_STOP_WORDS_SET;
            Set<?> stopWordsCustom = StopwordAnnotator.getStopWordList(customStopWordList, true);
            if (stopWords.contains(word) || stopWordsCustom.contains(word)) {
                arrs.add(word);
            }
        }
        return arrs;
    }

    private ArrayList<String> getentityTokenTags(CoreDocument coreDocument) {
        if (coreDocument == null || coreDocument.entityMentions() == null) {
            return new ArrayList<String>();
        }
        ArrayList<String> arrs = new ArrayList<>();
        if (coreDocument != null) {
            for (CoreEntityMention em : coreDocument.entityMentions()) {
                List<CoreLabel> tokens = em.tokens();
                String entityType = em.entityType();
                Double EntityConfidences = 0.0;
                Set<Map.Entry<String, Double>> entrySet = em.entityTypeConfidences().entrySet();
                for (Map.Entry<String, Double> entries : entrySet) {
                    if (EntityConfidences < entries.getValue()) {
                        EntityConfidences = entries.getValue();
                    }
                }
                for (CoreLabel token : tokens) {
                    if (token != null) {
                        if (!arrs.contains(token.tag())) {
                            if (entityType.equals("PERSON") && EntityConfidences > 0.80) {
                                arrs.add(token.tag());
                            }
                        }
                    }
                }
            }
        }
        return arrs;
    }

    private ArrayList<String> getstrTokensIpartForm(List<IMWE<IToken>> imwesFLocal) {
        ArrayList<String> arrs = new ArrayList<>();
        for (IMWE<IToken> token : imwesFLocal) {
            Collection<IMWEDesc.IPart> values = token.getPartMap().values();
            for (IMWEDesc.IPart iPart : values) {
                String iPartForm = iPart.getForm();
                arrs.add(iPartForm);
            }
        }
        return arrs;
    }

    private int getMarkedCounter(List<IMWE<IToken>> imwesFLocal) {
        int marked = 0;
        for (IMWE<IToken> token : imwesFLocal) {
            IMWEDesc entry = token.getEntry();
            marked += entry.getMarkedContinuous();
            for (IToken tokens : token.getTokens()) {
                marked += tokens.getStems().size();
            }
        }
        return marked;
    }

    public int getInflictedCounterNegative(List<IMWE<IToken>> imwesFLocal) {
        int InflectedCounterNegative = 0;
        Collection<IMWE<IToken>> tokeninflectionMap = new ArrayList();
        for (IMWE<IToken> token : imwesFLocal) {
            if (!token.isInflected() && !tokeninflectionMap.contains(token)) {
                InflectedCounterNegative++;
                tokeninflectionMap.add(token);
            }
        }
        return InflectedCounterNegative;
    }

    public ArrayList<String> getTokenEntries(List<IMWE<IToken>> imwesFLocal) {
        ArrayList<String> tokenStrList = new ArrayList<>();
        for (IMWE<IToken> token : imwesFLocal) {
            final String substring = token.getEntry().toString().substring(token.getEntry()
                    .toString().length() - 1);
            tokenStrList.add(substring);
        }
        return tokenStrList;
    }


    public void validateStringCaches() {

        Class<SentimentCoreAnnotations.SentimentAnnotatedTree> sentimentAnnotatedTreeClass =
                SentimentCoreAnnotations.SentimentAnnotatedTree.class;

        if (this.tokenizeCountingF == null) {
            this.tokenizeCountingF = tokenizeCounting(getTaggedWordList(str1));
        }
        if (this.tokenizeCounting == null) {
            this.tokenizeCounting = tokenizeCounting(getTaggedWordList(str));
        }
        if (this.taggedWordListF == null) {
            this.taggedWordListF = getTaggedWordList(str);
        }
        if (this.taggedWordList1 == null) {
            this.taggedWordList1 = getTaggedWordList(str1);
        }
        if (this.retrieveTGWListF == null) {
            this.retrieveTGWListF = retrieveTGWListIndex(this.taggedWordListF);
        }
        if (this.retrieveTGWList1 == null) {
            this.retrieveTGWList1 = retrieveTGWListIndex(this.taggedWordList1);
        }
        if (this.sentencesF == null) {
            this.sentencesF = pipelineAnnotation1.get(CoreAnnotations.SentencesAnnotation.class);
        }
        if (this.sentences1 == null) {
            this.sentences1 = pipelineAnnotation2.get(CoreAnnotations.SentencesAnnotation.class);
        }
        if (this.sentencesSentimentF == null) {
            this.sentencesSentimentF = pipelineAnnotation1Sentiment.get(CoreAnnotations.SentencesAnnotation.class);
        }
        if (this.sentencesSentiment1 == null) {
            this.sentencesSentiment1 = pipelineAnnotation2Sentiment.get(CoreAnnotations.SentencesAnnotation.class);
        }
        if (this.treesF == null) {
            this.treesF = retrieveTrees(this.sentencesF);
        }
        if (this.trees1 == null) {
            this.trees1 = retrieveTrees(this.sentences1);
        }
        if (this.grammaticalStructuresF == null) {
            this.grammaticalStructuresF = grammaticalStructureSetup(this.treesF);
        }
        if (this.grammaticalStructures1 == null) {
            this.grammaticalStructures1 = grammaticalStructureSetup(this.trees1);
        }
        if (this.typedDependenciesF == null) {
            this.typedDependenciesF = grammaticalStructureAllTypedDependencies(this.grammaticalStructuresF);
        }
        if (this.typedDependencies1 == null) {
            this.typedDependencies1 = grammaticalStructureAllTypedDependencies(this.grammaticalStructures1);
        }
        if (this.rnnCoreAnnotationsPredictedF == null) {
            this.rnnCoreAnnotationsPredictedF = sentimentRNNCoreAnnotations(this.sentencesSentimentF,
                    sentimentAnnotatedTreeClass);
        }
        if (this.rnnCoreAnnotationsPredicted1 == null) {
            this.rnnCoreAnnotationsPredicted1 = sentimentRNNCoreAnnotations(this.sentencesSentiment1,
                    sentimentAnnotatedTreeClass);
        }
        if (this.simpleMatricesF == null) {
            this.simpleMatricesF = sentimentRNNCorePredicted(this.sentencesSentimentF, sentimentAnnotatedTreeClass);
        }
        if (this.simpleMatrices1 == null) {
            this.simpleMatrices1 = sentimentRNNCorePredicted(this.sentencesSentiment1, sentimentAnnotatedTreeClass);
        }
        if (this.simpleMatricesNodevectorsF == null) {
            this.simpleMatricesNodevectorsF = sentimentRNNCoreNodevectors(this.sentencesSentimentF, sentimentAnnotatedTreeClass);
        }
        if (this.simpleMatricesNodevectors1 == null) {
            this.simpleMatricesNodevectors1 = sentimentRNNCoreNodevectors(this.sentencesSentiment1, sentimentAnnotatedTreeClass);
        }
        if (this.listF == null) {
            DocumentReaderAndWriter<CoreLabel> readerAndWriter = classifier.makePlainTextReaderAndWriter();
            this.listF = classifier.classifyRaw(str, readerAndWriter);
        }
        if (this.list1 == null) {
            DocumentReaderAndWriter<CoreLabel> readerAndWriter = classifier.makePlainTextReaderAndWriter();
            this.list1 = classifier.classifyRaw(str1, readerAndWriter);
        }
        if (this.longestF == null) {
            this.longestF = setupMainLongest(this.sentencesSentimentF);
        }
        if (this.longest1 == null) {
            this.longest1 = setupMainLongest(this.sentencesSentiment1);
        }
        if (this.sentimentLongestF == null) {
            this.sentimentLongestF = setupMainSentiment(this.sentencesSentimentF, sentimentAnnotatedTreeClass);
        }
        if (this.sentimentLongest1 == null) {
            this.sentimentLongest1 = setupMainSentiment(this.sentencesSentiment1, sentimentAnnotatedTreeClass);
        }
        if (this.imwesF == null) {
            this.imwesF = getIMWES(this.coreMaps1);
        }
        if (this.imwes1 == null) {
            this.imwes1 = getIMWES(this.coreMaps2);
        }
        if (this.InflectedCounterNegativeF == null) {
            this.InflectedCounterNegativeF = getInflictedCounterNegative(this.imwesF);
        }
        if (this.InflectedCounterNegative1 == null) {
            this.InflectedCounterNegative1 = getInflictedCounterNegative(this.imwes1);
        }
        if (this.InflectedCounterPositiveF == null) {
            this.InflectedCounterPositiveF = getInflictedCounterPositive(this.imwesF);
        }
        if (this.InflectedCounterPositive1 == null) {
            this.InflectedCounterPositive1 = getInflictedCounterPositive(this.imwes1);
        }
        if (this.tokenEntryF == null) {
            this.tokenEntryF = getTokenEntries(this.imwesF);
        }
        if (this.tokenEntry1 == null) {
            this.tokenEntry1 = getTokenEntries(this.imwes1);
        }
        if (this.MarkedContinuousCounterF == null) {
            this.MarkedContinuousCounterF = getMarkedCounter(this.imwesF);
        }
        if (this.MarkedContinuousCounter1 == null) {
            this.MarkedContinuousCounter1 = getMarkedCounter(this.imwes1);
        }
        if (this.UnmarkedPatternCounterF == null) {
            this.UnmarkedPatternCounterF = getUnmarkedPatterns(this.imwesF);
        }
        if (this.UnmarkedPatternCounter1 == null) {
            this.UnmarkedPatternCounter1 = getUnmarkedPatterns(this.imwes1);
        }
        if (this.strTokensIpartFormF == null) {
            this.strTokensIpartFormF = getstrTokensIpartForm(this.imwesF);
        }
        if (this.strTokensIpartForm1 == null) {
            this.strTokensIpartForm1 = getstrTokensIpartForm(this.imwes1);
        }
        if (this.tokenFormsF == null) {
            this.tokenFormsF = gettokenForms(this.imwesF);
        }
        if (this.tokenForms1 == null) {
            this.tokenForms1 = gettokenForms(this.imwes1);
        }
        if (this.strTokenEntryGetPOSF == null) {
            this.strTokenEntryGetPOSF = getStrtokenEntryPos(this.imwesF);
        }
        if (this.strTokenEntryGetPOS1 == null) {
            this.strTokenEntryGetPOS1 = getStrtokenEntryPos(this.imwes1);
        }
        if (this.intTokenEntyCountsF == null) {
            this.intTokenEntyCountsF = getintTokenEntyCounts(this.imwesF);
        }
        if (this.intTokenEntyCounts1 == null) {
            this.intTokenEntyCounts1 = getintTokenEntyCounts(this.imwes1);
        }
        if (this.ITokenTagsF == null) {
            this.ITokenTagsF = getITokenTags(this.imwesF);
        }
        if (this.ITokenTags1 == null) {
            this.ITokenTags1 = getITokenTags(this.imwes1);
        }
        if (this.strTokenStemsF == null) {
            this.strTokenStemsF = getstrTokenStems(this.imwesF);
        }
        if (this.strTokenStems1 == null) {
            this.strTokenStems1 = getstrTokenStems(this.imwes1);
        }
        if (this.AnotatorcounterF == null) {
            this.AnotatorcounterF = getAnotatorcounter(this.imwesF);
        }
        if (this.Anotatorcounter1 == null) {
            this.Anotatorcounter1 = getAnotatorcounter(this.imwes1);
        }
        if (this.TokensCounterF == null) {
            this.TokensCounterF = getAnotatorcounter(this.imwesF);
        }
        if (this.TokensCounter1 == null) {
            this.TokensCounter1 = getAnotatorcounter(this.imwes1);
        }
        if (this.entityTokenTagsF == null) {
            this.entityTokenTagsF = getentityTokenTags(this.pipelineCoreDcoument1);
        }
        if (this.entityTokenTags1 == null) {
            this.entityTokenTags1 = getentityTokenTags(this.pipelineCoreDcoument2);
        }
        if (this.nerEntitiesF == null) {
            this.nerEntitiesF = getnerEntities(this.pipelineCoreDcoument1);
        }
        if (this.nerEntities1 == null) {
            this.nerEntities1 = getnerEntities(this.pipelineCoreDcoument2);
        }
        if (this.nerEntitiesTypeF == null) {
            this.nerEntitiesTypeF = getnerEntitiesType(this.pipelineCoreDcoument1);
        }
        if (this.nerEntitiesType1 == null) {
            this.nerEntitiesType1 = getnerEntitiesType(this.pipelineCoreDcoument2);
        }
        if (this.stopWordTokenF == null) {
            this.stopWordTokenF = getstopWordToken(this.pipelineAnnotation1Sentiment);
        }
        if (this.stopWordToken1 == null) {
            this.stopWordToken1 = getstopWordToken(this.pipelineAnnotation2Sentiment);
        }
        if (this.stopWordLemmaF == null) {
            this.stopWordLemmaF = getstopWordLemma(this.pipelineAnnotation1Sentiment);
        }
        if (this.stopWordLemma1 == null) {
            this.stopWordLemma1 = getstopWordLemma(this.pipelineAnnotation2Sentiment);
        }
        if (this.PairCounterF == null) {
            this.PairCounterF = getPairCounter(this.pipelineAnnotation1Sentiment);
        }
        if (this.PairCounter1 == null) {
            this.PairCounter1 = getPairCounter(this.pipelineAnnotation2Sentiment);
        }
    }


    public Double callSMX() {

        Double score = -100.0;

        /*
        try {
            int index = new Random().nextInt(9);
            fh = new FileHandler("E:/stationær backup filer/Projects/ArtificialAutism_intellij/logs/autismlog-" + index);
           //logger.addHandler(fh);
            SimpleFormatter formatter = new SimpleFormatter();
            fh.setFormatter(formatter);
        } catch (SecurityException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } */

        //logger.info("Sent1: " + str);
        //logger.info("Sent2: " + str1);
        int counter1;
        int counter2;
        validateStringCaches();
        counter1 = this.tokenizeCountingF;
        counter2 = this.tokenizeCounting;
        final int overValue = (counter1 >= counter2 ? counter1 - counter2 : counter2 - counter1) * 32;
        score -= overValue;
        //logger.info("score post overValue: " + score);
        score = tgwListScoreIncrementer(score, this.retrieveTGWListF, this.retrieveTGWList1);
        //logger.info("score post tgwListScoreIncrementer: " + score);
        Class<SentimentCoreAnnotations.SentimentAnnotatedTree> sentimentAnnotatedTreeClass =
                SentimentCoreAnnotations.SentimentAnnotatedTree.class;

        score = iterateTrees(this.treesF, this.trees1, score);
        //logger.info("\n\n \n \n \nscore post iterateTrees: " + score);
        score = typeDependenciesGrammaticalRelation(this.typedDependenciesF, typedDependencies1, score, this.grammaticalStructuresF, this.grammaticalStructures1,
                this.treesF, this.trees1);
        //logger.info("score post typeDependenciesGrammaticalRelation: " + score);

        score = simpleRNNMatrixCalculations(score, this.simpleMatricesF, this.simpleMatrices1);
        //logger.info("score post simpleRNNMatrixCalculations: " + score);
        score = simpleRNNMaxtrixVectors(score, this.simpleMatricesNodevectorsF, this.simpleMatricesNodevectors1);
        //logger.info("score post simpleRNNMaxtrixVectors: " + score);
        Integer sentiment1 = this.rnnCoreAnnotationsPredictedF.size();
        Integer sentiment2 = this.rnnCoreAnnotationsPredicted1.size();
        score -= (sentiment1 > sentiment2 ? sentiment2 - sentiment1 : sentiment1 - sentiment2) * 500;
        //logger.info("score post rnnCoreAnnotationsPredicted " + score);
        int scoreClassifyraw = classifyRawEvaluation();
        //logger.info("scoreClassifyraw: " + scoreClassifyraw);
        score -= scoreClassifyraw;
        //logger.info("score post classifyRawEvaluation " + score);
        score = sentimentMatrixVariances(score, this.longestF, this.longest1, this.sentimentLongestF, this.sentimentLongest1);
        //logger.info("score post sentimentMatrixVariances " + score);
        score = entryCountsRelation(score, this.intTokenEntyCountsF, this.intTokenEntyCounts1);
        //logger.info("score post entryCountsRelation " + score);
        score = entryCountsScoring(score, this.intTokenEntyCountsF, this.intTokenEntyCounts1);
        //logger.info("score post entryCountsScoring " + score);
        score = tokenEntryPosScoring(score, this.strTokenEntryGetPOSF, this.strTokenEntryGetPOS1);
        //logger.info("score post tokenEntryPosScoring " + score);
        score = unmarkedPatternCounterScoring(score, this.UnmarkedPatternCounterF,
                this.UnmarkedPatternCounter1);
        //logger.info("score post  unmarkedPatternCounterScoring: " + score);
        score = markedContiniousCounterScoring(score, this.MarkedContinuousCounterF,
                this.MarkedContinuousCounter1);
        //logger.info("score post markedContiniousCounterScoring " + score);
        score = strTokensMapScoring(score, this.strTokensIpartFormF, this.strTokensIpartForm1);
        //logger.info("score post strTokensMapScoring  " + score);
        score = strTokenEntryScoring(score, this.tokenEntryF, this.tokenEntry1);
        //logger.info("score post strTokenEntryScoring  " + score);
        score = strTokenMapTagsScoring(score, this.ITokenTagsF, this.ITokenTags1);
        //logger.info("score post strTokenMapTagsScoring  " + score);
        score = tokenformSizeScoring(score, this.tokenFormsF, this.tokenForms1);
        //logger.info("score post tokenformSizeScoring  " + score);
        score = tokenStemmingMapScoring(score, this.strTokenStemsF, this.strTokenStems1);
        //logger.info("score post tokenStemmingMapScoring  " + score);

        score = inflectedCounterScoring(score, this.InflectedCounterPositiveF, this.InflectedCounterPositive1,
                this.InflectedCounterNegativeF, this.InflectedCounterNegative1);
        //logger.info("score post inflectedCounterScoring  " + score);
        score = annotatorCountScoring(score, this.AnotatorcounterF, this.Anotatorcounter1);
        //logger.info("score post annotatorCountScoring  " + score);
        score = tokensCounterScoring(score, this.TokensCounterF, this.TokensCounter1);
        //logger.info("score post tokensCounterScoring  " + score);
        LevenshteinDistance leven = new LevenshteinDistance(str, str1);
        double SentenceScoreDiff = leven.computeLevenshteinDistance();
        SentenceScoreDiff *= 15;
        score -= SentenceScoreDiff;
        //logger.info("score post SentenceScoreDiff  " + score);
        score = nerEntitiesAndTokenScoring(score, this.entityTokenTagsF, this.entityTokenTags1,
                this.nerEntitiesF, this.nerEntities1);
        //logger.info("score post nerEntitiesAndTokenScoring  " + score);
        score = stopWordTokenLemmaScoring(score, this.stopWordTokenF, this.stopWordToken1,
                this.stopWordLemmaF, this.stopWordLemma1);
        //logger.info("score post stopWordTokenLemmaScoring  " + score);
        score = stopwordTokenPairCounterScoring(score, this.stopWordTokenF, this.stopWordToken1,
                this.PairCounterF, this.PairCounter1);
        //logger.info("score post stopwordTokenPairCounterScoring  " + score);

        return score;

    }
}
