### Question:
DependencyParseFeature implements FactFeature { @Override public void extractFeature(ComplexProof proof, Evidence evidence) { List<Pattern> patterns = searcher.querySolrIndex(evidence.getModel().getPropertyUri(), 20, 0, proof.getLanguage()); float score = (float) 0.0; String patternString = ""; for ( Pattern p : patterns ) { if ( p.getNormalized().trim().isEmpty() ) continue; if ( proof.getProofPhrase().toLowerCase().contains(p.getNormalized()) ) { patternString = p.getNormalized().trim(); break; } } if(!(patternString=="")) { List<TypedDependency> tdl = null; Annotation doc = evidence.getModel().corenlpClient.sentenceAnnotation(proof.getProofPhrase()); for(CoreMap sentence: doc.get(SentencesAnnotation.class)) { if(sentence.get(CoreAnnotations.TextAnnotation.class).toLowerCase().contains(patternString) && sentence.get(CoreAnnotations.TextAnnotation.class).split(" ").length<30) { List<CoreLabel> tokens = sentence.get(TokensAnnotation.class); Tree tree = parser.parse(tokens); TreebankLanguagePack tlp = new PennTreebankLanguagePack(); GrammaticalStructureFactory gsf = tlp.grammaticalStructureFactory(); GrammaticalStructure gs = gsf.newGrammaticalStructure(tree); tdl = gs.typedDependenciesEnhanced(); List<String> subLabels = new ArrayList<String>(); List<String> objLabels = new ArrayList<String>(); for (String str : proof.getSubject().split(" ")) { subLabels.add(str.toLowerCase()); } for (String str : proof.getObject().split(" ")) { objLabels.add(str.toLowerCase()); } Iterator<TypedDependency> it = tdl.iterator(); while(it.hasNext()) { TypedDependency td = it.next(); if((patternString.contains(td.gov().toString().toLowerCase()) && (subLabels.contains(td.dep().originalText().toLowerCase()))) || (patternString.contains(td.dep().toString().toLowerCase()) && (subLabels.contains(td.gov().originalText().toLowerCase())))) score = (float) (score + 0.5); if((subLabels.contains(td.dep().originalText().toLowerCase()) && (objLabels.contains(td.gov().originalText().toLowerCase()))) || (subLabels.contains(td.dep().originalText().toLowerCase()) && (objLabels.contains(td.gov().originalText().toLowerCase())))) score = (float) (score + 0.5); if((patternString.contains(td.gov().toString().toLowerCase()) && (objLabels.contains(td.dep().originalText().toLowerCase()))) || (patternString.contains(td.dep().toString().toLowerCase()) && (objLabels.contains(td.gov().originalText().toLowerCase())))) score = (float) (score + 0.5); } } } } proof.getFeatures().setValue(AbstractFactFeatures.DEPENDENCY_SUBJECT_OBJECT, score); } DependencyParseFeature(); @Override void extractFeature(ComplexProof proof, Evidence evidence); static void main(String[] args); public LexicalizedParser parser; }### Answer:
@Test public void test() { if(this.errorClass != null) { try { feature.extractFeature(this.proof, this.evidence); Assert.fail("Excpected expection"); } catch (NullPointerException e) { Assert.assertTrue(true); return; } } feature.extractFeature(this.proof, this.evidence); Assert.assertEquals(this.expectedScore, this.proof.getFeatures().value(AbstractFactFeatures.DEPENDENCY_SUBJECT_OBJECT),0.0); }