public void substituteSynonymVerbs()

in opennlp-similarity/src/main/java/opennlp/tools/apps/review_builder/SentenceOriginalizer.java [163:203]


	public void substituteSynonymVerbs(){
		for(int i = 0; i< sents.length; i++){
			String line = sents[i];
			List<List<ParseTreeChunk>> ps = pProc.getPhrasesOfAllTypes(line);
			if (ps==null || ps.size()<2)
				continue;

			List<ParseTreeChunk> vps = ps.get(1);

			extractNounPhrasesWithSentiments(ps.get(0));

			line = substituteSentimentSynonyms(line, ps);

			if (vps==null)
				continue;
			boolean bVerbRule = false;
			if (vps.size()==1)
				line = rePhraser.rePhrase(line);
			else {
				if (vps.size()>1) {
					for (ParseTreeChunk v: vps){
						String verbLemma = v.getLemmas().get(0);
						String newVerb = filter.getSynonym(verbLemma);
						if (newVerb!=null && newVerb.length()>3 && verbLemma.length()>3 // both old and new words should be above 3
								&& !newVerb.endsWith("ness") // empirical rule
								&& !verbsShouldStayNoSubstition.contains(verbLemma) &&
								!verbsShouldStayNoSubstition.contains(newVerb)	){
							line = line.replace(verbLemma+" ", newVerb+" ");
							line = line.replace(" "+verbLemma, " "+newVerb);
							System.out.println("Synonym for verb substitution: "+verbLemma + "->"+newVerb);
							bVerbRule = true;
						}
					}
				}
				if (!bVerbRule && vps.size()==2 && Math.random()>0.8) // no other means of originalization worked, so do inverse translation
					line = rePhraser.rePhrase(line);
			}
			sents[i]=line;

		}
	}