public static Document parse(String text, int windowSize, JSONArray spacyEntities, JSONArray dbpediaEntities) {
		Document result = new Document();
		result._originaltext = text;
		result._sentences    = new java.util.ArrayList<Sentence>();
		List<String> splitSentences = StanfordNLP.splitSentences(text);
		int lastFoundPosition = -1;
		int lastSentenceLength = 1;
		int sentenceCount      = 0;
		int runningSentinmentScore = 0; 
		// perform the window parsing - used to do coreref, plus get initial named entities, sentiment, and tokens
		for (int sentenceIndex = 0; sentenceIndex < splitSentences.size(); sentenceIndex++) {
			SplitResult sr = getTextWindow(splitSentences, sentenceIndex,windowSize);
			Annotation sentenceDoc = StanfordNLP.annotateText(sr.text);
		    List<CoreMap> sentences = sentenceDoc.get(CoreAnnotations.SentencesAnnotation.class);
		    CoreMap sentence = sentences.get(sr.sentencePositionToUse);
	    	sentenceCount++;
	    	String sentenceText = sentence.get(CoreAnnotations.TextAnnotation.class);
	    	int documentPosition = text.indexOf(sentenceText,lastFoundPosition);
	    	if (documentPosition == -1) { 
	    		documentPosition = lastFoundPosition + lastSentenceLength;
	    	}
	    	java.util.List<Token> sentenceTokens = Token.extractTokens(sentence, sentenceCount);
	    	Sentence s = new Sentence(sentenceText, documentPosition, sentenceCount, sentenceTokens);
	    	Tree tree = sentence.get(SentimentCoreAnnotations.SentimentAnnotatedTree.class);
            int sentiment = RNNCoreAnnotations.getPredictedClass(tree);
            s.setSentiment(sentiment);
            runningSentinmentScore += sentiment;
            List<String> resolvedSentences = Coreference.resolveCoreferences(sentenceDoc);
            s.setCorefText(resolvedSentences.get(sr.sentencePositionToUse));
	    	result._sentences.add(s);
	    	lastFoundPosition = documentPosition;
	    	lastSentenceLength = sentenceText.length();
		}
		result._sentimentScore =  ((double) runningSentinmentScore) / sentenceCount;
		// reparse to get openIE / relations items
		int baseSentenceIndex = -1;
		for (Sentence s: result._sentences) {
			Annotation sentenceDoc = StanfordNLP.annotateText(s.getCorefText());
			baseSentenceIndex++;
			java.util.List<Token> sentenceTokens = Token.extractTokens(sentenceDoc.get(CoreAnnotations.SentencesAnnotation.class).get(0), baseSentenceIndex);
			java.util.List<TripleRelation> triples = TripleRelation.extractTriples(sentenceDoc, baseSentenceIndex);
			triples = TripleRelation.valiadateTriples(triples, sentenceTokens);
			List<AnnotatedProposition> minieTriplesAP =  StanfordNLP.extractMinIETriples(s.getCorefText());
			java.util.List<TripleRelation> minetriples = TripleRelation.extractTriples(minieTriplesAP, baseSentenceIndex);
			minetriples = TripleRelation.valiadateTriples(minetriples, sentenceTokens);
			java.util.List<TripleRelation> combinedTriples = TripleRelation.combine(triples, minetriples);
			combinedTriples = TripleRelation.reduceTriples(combinedTriples, FilterStyle.FILTER_TO_MAXIMIZE_SUBJ_OBJ_MINIMIZE_RELATION);
			//combinedTriples = TripleRelation.reduceTriples(combinedTriples, FilterStyle.FILTER_TO_MINIMIZE_TERMS);
			TripleRelation.augmentSubjectObjectWithStanfordNER(combinedTriples,s.getNamedEntities());
			TripleRelation.augmentSubjectObjectWithSpacyNER(combinedTriples, spacyEntities, s.getStartPosition(), s.getStartPosition() + s.getOriginalText().length());
			TripleRelation.augmentSubjectObjectWithDBPedia(combinedTriples, dbpediaEntities, s.getStartPosition(), s.getStartPosition() + s.getOriginalText().length());
			s.setTripleRelations(combinedTriples);
		}
		return result;
	}
public static Document parse(String text, int windowSize, JSONArray spacyEntities, JSONArray dbpediaEntities) {
		Document result = new Document();
		result._originaltext = text;
		result._sentences    = new java.util.ArrayList<Sentence>();
		List<String> splitSentences = StanfordNLP.splitSentences(text);
		int lastFoundPosition = -1;
		int lastSentenceLength = 1;
		int sentenceCount      = 0;
		int runningSentinmentScore = 0; 
	
		for (int sentenceIndex = 0; sentenceIndex < splitSentences.size(); sentenceIndex++) {
			SplitResult sr = getTextWindow(splitSentences, sentenceIndex,windowSize);
			Annotation sentenceDoc = StanfordNLP.annotateText(sr.text);
		    List<CoreMap> sentences = sentenceDoc.get(CoreAnnotations.SentencesAnnotation.class);
		    CoreMap sentence = sentences.get(sr.sentencePositionToUse);
	    	sentenceCount++;
	    	String sentenceText = sentence.get(CoreAnnotations.TextAnnotation.class);
	    	int documentPosition = text.indexOf(sentenceText,lastFoundPosition);
	    	if (documentPosition == -1) { 
	    		documentPosition = lastFoundPosition + lastSentenceLength;
	    	}
	    	java.util.List<Token> sentenceTokens = Token.extractTokens(sentence, sentenceCount);
	    	Sentence s = new Sentence(sentenceText, documentPosition, sentenceCount, sentenceTokens);
	    	Tree tree = sentence.get(SentimentCoreAnnotations.SentimentAnnotatedTree.class);
            int sentiment = RNNCoreAnnotations.getPredictedClass(tree);
            s.setSentiment(sentiment);
            runningSentinmentScore += sentiment;
            List<String> resolvedSentences = Coreference.resolveCoreferences(sentenceDoc);
            s.setCorefText(resolvedSentences.get(sr.sentencePositionToUse));
	    	result._sentences.add(s);
	    	lastFoundPosition = documentPosition;
	    	lastSentenceLength = sentenceText.length();
		}
		result._sentimentScore =  ((double) runningSentinmentScore) / sentenceCount;
	
		int baseSentenceIndex = -1;
		for (Sentence s: result._sentences) {
			Annotation sentenceDoc = StanfordNLP.annotateText(s.getCorefText());
			baseSentenceIndex++;
			java.util.List<Token> sentenceTokens = Token.extractTokens(sentenceDoc.get(CoreAnnotations.SentencesAnnotation.class).get(0), baseSentenceIndex);
			java.util.List<TripleRelation> triples = TripleRelation.extractTriples(sentenceDoc, baseSentenceIndex);
			triples = TripleRelation.valiadateTriples(triples, sentenceTokens);
			List<AnnotatedProposition> minieTriplesAP =  StanfordNLP.extractMinIETriples(s.getCorefText());
			java.util.List<TripleRelation> minetriples = TripleRelation.extractTriples(minieTriplesAP, baseSentenceIndex);
			minetriples = TripleRelation.valiadateTriples(minetriples, sentenceTokens);
			java.util.List<TripleRelation> combinedTriples = TripleRelation.combine(triples, minetriples);
			combinedTriples = TripleRelation.reduceTriples(combinedTriples, FilterStyle.FILTER_TO_MAXIMIZE_SUBJ_OBJ_MINIMIZE_RELATION);
		
			TripleRelation.augmentSubjectObjectWithStanfordNER(combinedTriples,s.getNamedEntities());
			TripleRelation.augmentSubjectObjectWithSpacyNER(combinedTriples, spacyEntities, s.getStartPosition(), s.getStartPosition() + s.getOriginalText().length());
			TripleRelation.augmentSubjectObjectWithDBPedia(combinedTriples, dbpediaEntities, s.getStartPosition(), s.getStartPosition() + s.getOriginalText().length());
			s.setTripleRelations(combinedTriples);
		}
		return result;
	}
public static document parse(string text, int windowsize, jsonarray spacyentities, jsonarray dbpediaentities) { document result = new document(); result._originaltext = text; result._sentences = new java.util.arraylist<sentence>(); list<string> splitsentences = stanfordnlp.splitsentences(text); int lastfoundposition = -1; int lastsentencelength = 1; int sentencecount = 0; int runningsentinmentscore = 0; for (int sentenceindex = 0; sentenceindex < splitsentences.size(); sentenceindex++) { splitresult sr = gettextwindow(splitsentences, sentenceindex,windowsize); annotation sentencedoc = stanfordnlp.annotatetext(sr.text); list<coremap> sentences = sentencedoc.get(coreannotations.sentencesannotation.class); coremap sentence = sentences.get(sr.sentencepositiontouse); sentencecount++; string sentencetext = sentence.get(coreannotations.textannotation.class); int documentposition = text.indexof(sentencetext,lastfoundposition); if (documentposition == -1) { documentposition = lastfoundposition + lastsentencelength; } java.util.list<token> sentencetokens = token.extracttokens(sentence, sentencecount); sentence s = new sentence(sentencetext, documentposition, sentencecount, sentencetokens); tree tree = sentence.get(sentimentcoreannotations.sentimentannotatedtree.class); int sentiment = rnncoreannotations.getpredictedclass(tree); s.setsentiment(sentiment); runningsentinmentscore += sentiment; list<string> resolvedsentences = coreference.resolvecoreferences(sentencedoc); s.setcoreftext(resolvedsentences.get(sr.sentencepositiontouse)); result._sentences.add(s); lastfoundposition = documentposition; lastsentencelength = sentencetext.length(); } result._sentimentscore = ((double) runningsentinmentscore) / sentencecount; int basesentenceindex = -1; for (sentence s: result._sentences) { annotation sentencedoc = stanfordnlp.annotatetext(s.getcoreftext()); basesentenceindex++; java.util.list<token> sentencetokens = token.extracttokens(sentencedoc.get(coreannotations.sentencesannotation.class).get(0), basesentenceindex); java.util.list<triplerelation> triples = triplerelation.extracttriples(sentencedoc, basesentenceindex); triples = triplerelation.valiadatetriples(triples, sentencetokens); list<annotatedproposition> minietriplesap = stanfordnlp.extractminietriples(s.getcoreftext()); java.util.list<triplerelation> minetriples = triplerelation.extracttriples(minietriplesap, basesentenceindex); minetriples = triplerelation.valiadatetriples(minetriples, sentencetokens); java.util.list<triplerelation> combinedtriples = triplerelation.combine(triples, minetriples); combinedtriples = triplerelation.reducetriples(combinedtriples, filterstyle.filter_to_maximize_subj_obj_minimize_relation); triplerelation.augmentsubjectobjectwithstanfordner(combinedtriples,s.getnamedentities()); triplerelation.augmentsubjectobjectwithspacyner(combinedtriples, spacyentities, s.getstartposition(), s.getstartposition() + s.getoriginaltext().length()); triplerelation.augmentsubjectobjectwithdbpedia(combinedtriples, dbpediaentities, s.getstartposition(), s.getstartposition() + s.getoriginaltext().length()); s.settriplerelations(combinedtriples); } return result; }