public static boolean filter(PhraseInfo phrase) { if (phrase == null || phrase.getTree() == null) return false; Tree phraseTree = phrase.getTree(); // __ < ( NP < (PRP !< it|them) ) | < ( NP < ( NP < (PRP !< it|them) ) ) String invalidPronounPattern = " ( NP < (PRP=prp !< " + Utils.wordsConjuction(Rules.VALID_PRONOUNS) + ") ) "; String filterPattern = "__ < " + invalidPronounPattern + " | < ( NP <" + invalidPronounPattern + ")"; TregexPattern tregexPattern = TregexPattern.compile(filterPattern); TregexMatcher matcher = tregexPattern.matcher(phraseTree); if (matcher.matches()) { Proof proof = new Proof(ProofType.FAIL_PERSONAL_PRONOUN); Tree evdTree = matcher.getNode("prp"); proof.setEvidenceTree(evdTree); phrase.addProof(proof); return false; } return true; }