Skip to content

Commit

Permalink
add homonym annotation; related to #161
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorrit Poelen committed Apr 5, 2024
1 parent 466394f commit 41c5a7f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public static void emitNameRelatedToFocalTaxon(
Taxon focalTaxon,
Map<String, String> relatedTaxonMap,
Taxon relatedTaxon) {
boolean relatedNameIsHomonym = isHomonym(relatedTaxonMap);
boolean relatedNameIsHomonym = isHomonym(relatedTaxonMap) || (relatedTaxon.getStatus() != null && NameType.HOMONYM_OF.name().equals(relatedTaxon.getStatus().getName()));
if (relatedNameIsHomonym) {
listener.foundTaxonForTerm(
null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.eol.globi.data.CharsetConstant;
import org.eol.globi.domain.NameType;
import org.eol.globi.domain.PropertyAndValueDictionary;
import org.eol.globi.domain.Taxon;
import org.eol.globi.domain.TaxonImpl;
import org.eol.globi.domain.TermImpl;
import org.eol.globi.service.TaxonUtil;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
Expand Down Expand Up @@ -268,6 +270,13 @@ public static Taxon parse(String name) {
}

}

if (matched != null) {
NameType status = StringUtils.contains(name, "_sic") ? NameType.TRANSLATES_TO : NameType.SYNONYM_OF;
status = StringUtils.contains(name, "_homonym") ? NameType.HOMONYM_OF : status;
matched.setStatus(new TermImpl(status.name(), status.name()));
}

return matched;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void foundTaxonForTerm(Long requestId, Term providedTerm, NameType nameTy
counter.incrementAndGet();
}
});
assertThat(counter.get(), Is.is(48503));
assertThat(counter.get(), Is.is(48518));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public void parseRelatedNames() throws ParserConfigurationException, XPathExpres
Taxon lastTaxon = taxons.get(taxons.size() - 1);
assertThat(lastTaxon.getName(), is("Andrena (Holandrena) cressonii"));
assertThat(lastTaxon.getAuthorship(), is("Robertson, 1891"));
assertThat(lastTaxon.getStatus().getName(), is(NameType.SYNONYM_OF.name()));
}

@Test
Expand Down

0 comments on commit 41c5a7f

Please sign in to comment.