use of org.icij.datashare.text.NamedEntity in project datashare by ICIJ.
the class NamedEntityResourceTest method test_get_named_entity.
@Test
public void test_get_named_entity() {
NamedEntity toBeReturned = create(PERSON, "mention", asList(123L), "docId", "root", CORENLP, FRENCH);
doReturn(toBeReturned).when(indexer).get("index", "my_id", "root_parent");
get("/api/index/namedEntities/my_id?routing=root_parent").should().respond(200).haveType("application/json");
}
use of org.icij.datashare.text.NamedEntity in project datashare by ICIJ.
the class NamedEntityResourceTest method test_hide_named_entity_when_success.
@Test
public void test_hide_named_entity_when_success() throws IOException {
NamedEntity toBeHidden = create(PERSON, "to_update", asList(123L), "docId", "root", CORENLP, FRENCH);
assertThat(toBeHidden.isHidden()).isFalse();
Indexer.Searcher searcher = mock(Indexer.Searcher.class);
doReturn(Stream.of(toBeHidden)).when(searcher).execute();
doReturn(searcher).when(searcher).thatMatchesFieldValue(any(), any());
doReturn(searcher).when(indexer).search("index", NamedEntity.class);
put("/api/index/namedEntities/hide/to_update").should().respond(200);
verify(indexer).bulkUpdate("index", singletonList(toBeHidden));
}
use of org.icij.datashare.text.NamedEntity in project datashare by ICIJ.
the class EmailPipelineTest method test_acceptance.
@Test
public void test_acceptance() throws IOException {
Path emailFile = Paths.get(getClass().getResource("/email.eml").getPath());
String content = new String(Files.readAllBytes(emailFile));
List<NamedEntity> annotations = pipeline.process(createDocument(content, "docId", Language.ENGLISH));
assertThat(annotations).hasSize(3);
assertThat(annotations.get(0).getOffsets()).containsExactly(14L, 48L, 168L, 332L, 1283L, 1482L, 1544L, 1582L);
}
use of org.icij.datashare.text.NamedEntity in project datashare by ICIJ.
the class JooqRepositoryTest method test_create_named_entity_list.
@Test
public void test_create_named_entity_list() {
List<NamedEntity> namedEntities = Arrays.asList(NamedEntity.create(PERSON, "mention 1", asList(123L), "doc_id", "root", CORENLP, GERMAN), NamedEntity.create(PERSON, "mention 2", asList(321L), "doc_id", "root", CORENLP, ENGLISH));
repository.create(namedEntities);
NamedEntity actualNe1 = repository.getNamedEntity(namedEntities.get(0).getId());
assertThat(actualNe1).isEqualTo(namedEntities.get(0));
assertThat(actualNe1.getCategory()).isEqualTo(PERSON);
assertThat(actualNe1.getExtractor()).isEqualTo(CORENLP);
assertThat(actualNe1.getExtractorLanguage()).isEqualTo(GERMAN);
assertThat(repository.getNamedEntity(namedEntities.get(1).getId())).isEqualTo(namedEntities.get(1));
}
use of org.icij.datashare.text.NamedEntity in project datashare by ICIJ.
the class ElasticsearchIndexerTest method test_update_named_entity.
@Test
public void test_update_named_entity() throws IOException {
Document parent = new org.icij.datashare.text.Document("id", project("prj"), Paths.get("doc.txt"), "content Madeline", Language.FRENCH, Charset.defaultCharset(), "text/plain", new HashMap<>(), DONE, new HashSet<>(), 123L);
NamedEntity ne = create(PERSON, "Madeline", asList(8L), parent.getId(), "root", CORENLP, Language.ENGLISH);
indexer.add(TEST_INDEX, parent);
indexer.add(TEST_INDEX, ne);
ne.hide();
indexer.update(TEST_INDEX, ne);
NamedEntity neFromES = indexer.get(TEST_INDEX, ne.getId(), parent.getId());
assertThat(neFromES.isHidden()).isTrue();
}
Aggregations