private void createdependency(WordToken govenor, WordToken dependent, String type) { Dependency dependency = new Dependency(jCas); dependency.setBegin(dependent.getBegin()); dependency.setEnd(dependent.getEnd()); dependency.setGovernor(govenor); dependency.setDependent(dependent); dependency.setDependencyType(type); dependency.addToIndexes(); }
private void createdependency(WordToken govenor, WordToken dependent, String type) { Dependency dependency = new Dependency(jCas); dependency.setBegin(dependent.getBegin()); dependency.setEnd(dependent.getEnd()); dependency.setGovernor(govenor); dependency.setDependent(dependent); dependency.setDependencyType(type); dependency.addToIndexes(); }
private void setGovernor(Dependency d, WordToken wt) { d.setGovernor(wt); d.setBegin(wt.getBegin()); d.setEnd(wt.getEnd()); } }
private void setDependent(Dependency d, WordToken wt) { d.setDependent(wt); d.setBegin(wt.getBegin()); d.setEnd(wt.getEnd()); }
@Test public void testAddsLemma() throws UIMAException, ResourceInitializationException { jCas.setDocumentText("Is this working?"); final WordToken t = new WordToken(jCas); t.setBegin(jCas.getDocumentText().indexOf("working")); t.setEnd(t.getBegin() + "working".length()); t.setPartOfSpeech("VERB"); t.addToIndexes(); processJCas("wordnet", wordnetErd); final List<WordToken> out = new ArrayList<>(JCasUtil.select(jCas, WordToken.class)); assertEquals("work", out.get(0).getLemmas(0).getLemmaForm()); }
@Test public void testAddsLemmaToExistingLemmas() throws UIMAException, ResourceInitializationException { jCas.setDocumentText("Is this working?"); final WordToken s = new WordToken(jCas); s.setBegin(jCas.getDocumentText().indexOf("working")); s.setEnd(s.getBegin() + "working".length()); s.setPartOfSpeech("VERB"); s.setLemmas(new FSArray(jCas, 1)); final WordLemma existingLemma = new WordLemma(jCas); existingLemma.setPartOfSpeech("existing"); existingLemma.setLemmaForm("existing"); s.setLemmas(0, existingLemma); s.addToIndexes(); processJCas("wordnet", wordnetErd); final List<WordToken> out = new ArrayList<>(JCasUtil.select(jCas, WordToken.class)); assertEquals(existingLemma, out.get(0).getLemmas(0)); assertEquals("work", out.get(0).getLemmas(1).getLemmaForm()); } }
public static Dependency createDependency(JCas jCas, WordToken gov, WordToken dep, String type) { Dependency d = new Dependency(jCas); d.setDependencyType(type); d.setBegin(dep.getBegin()); d.setEnd(dep.getEnd()); d.setGovernor(gov); d.setDependent(dep); d.addToIndexes(); return d; }
@Test public void test() throws AnalysisEngineProcessException, ResourceInitializationException { String text = "John say that he would visit London"; jCas.setDocumentText(text); ReferenceTarget rt = new ReferenceTarget(jCas); rt.addToIndexes(); Person p = new Person(jCas); p.setBegin(0); p.setEnd(4); p.setReferent(rt); p.setValue("John"); p.addToIndexes(); WordToken he = new WordToken(jCas); he.setBegin(text.indexOf("he")); he.setEnd(he.getBegin() + "he".length()); he.setReferent(rt); he.addToIndexes(); Location l = new Location(jCas); l.setBegin(text.indexOf("London")); l.setEnd(l.getBegin() + "London".length()); l.setValue("London"); l.addToIndexes(); processJCas(); List<Entity> list = new ArrayList<>(JCasUtil.select(jCas, Entity.class)); assertEquals(3, list.size()); assertEquals("John", list.get(0).getValue()); assertEquals("John", list.get(1).getValue()); assertTrue(list.get(1) instanceof Person); assertEquals("London", list.get(2).getValue()); }
attackAdj.setBegin(attackAdj.getBegin()); attackAdj.setEnd(attackAdj.getEnd()); attackAdj.setPartOfSpeech("ADJ");