Skip to content

Commit

Permalink
Merge pull request #1241 from jkirsch/master
Browse files Browse the repository at this point in the history
#1240 - Ensures DictionaryAnnotator matches all token
  • Loading branch information
reckart committed May 29, 2018
2 parents 6e3eec7 + 9a596e4 commit e2bd0d7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public void process(JCas jcas)
List<Token> tokens = new ArrayList<>(selectCovered(Token.class, currSentence));

for (int i = 0; i < tokens.size(); i++) {
List<Token> tokensToSentenceEnd = tokens.subList(i, tokens.size() - 1);
List<Token> tokensToSentenceEnd = tokens.subList(i, tokens.size());
String[] sentenceToEnd = new String[tokens.size()];

for (int j = 0; j < tokensToSentenceEnd.size(); j++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,23 @@ public void testWithWrongValueFeature() throws Exception
assertTrue(ExceptionUtils.getRootCauseMessage(e).contains("Undeclared feature"));
}
}

@Test
public void testMatchesAtEndOfSentence() throws Exception
{
AnalysisEngine ae = createEngine(DictionaryAnnotator.class,
DictionaryAnnotator.PARAM_ANNOTATION_TYPE, NamedEntity.class,
DictionaryAnnotator.PARAM_VALUE, "PERSON",
DictionaryAnnotator.PARAM_MODEL_LOCATION, "src/test/resources/persons.txt");

JCas jcas = JCasFactory.createJCas();
TokenBuilder<Token, Sentence> tb = new TokenBuilder<>(Token.class, Sentence.class);
tb.buildTokens(jcas, "I am John Silver");

ae.process(jcas);

NamedEntity ne = selectSingle(jcas, NamedEntity.class);
assertEquals("PERSON", ne.getValue());
assertEquals("John Silver", ne.getCoveredText());
}
}

0 comments on commit e2bd0d7

Please sign in to comment.