diff --git a/nomer-taxon-resolver/src/main/java/org/eol/globi/taxon/GlobalNamesService2.java b/nomer-taxon-resolver/src/main/java/org/eol/globi/taxon/GlobalNamesService2.java index e63e09b1..4f5ae9f3 100644 --- a/nomer-taxon-resolver/src/main/java/org/eol/globi/taxon/GlobalNamesService2.java +++ b/nomer-taxon-resolver/src/main/java/org/eol/globi/taxon/GlobalNamesService2.java @@ -165,6 +165,7 @@ private void parseResult(TermMatchListener termMatchListener, String result) thr } private void parseResultNode(TermMatchListener termMatchListener, JsonNode jsonNode) { + JsonNode dataList = jsonNode.get("data"); if (dataList != null && dataList.isArray()) { for (JsonNode data : dataList) { @@ -287,7 +288,7 @@ protected void parseClassification(TermMatchListener termMatchListener, JsonNode } // related to https://github.com/GlobalNamesArchitecture/gni/issues/48 - if (!pathTailRepetitions(taxon)) { + if (!pathTailRepetitions(taxon) && !speciesNoGenus(taxon)) { termMatchListener.foundTaxonForName(requestId(data), suppliedNameString, taxon, nameType); } } @@ -310,6 +311,11 @@ protected void parseClassification(TermMatchListener termMatchListener, JsonNode } } + private boolean speciesNoGenus(Taxon taxon) { + return taxon.getPathNames().contains("species") + && !taxon.getPathNames().contains("genus"); + } + private String getSuppliedNameString(JsonNode data) { return data.get("supplied_name_string").getTextValue(); } diff --git a/nomer-taxon-resolver/src/test/java/org/eol/globi/service/GlobalNamesService2Test.java b/nomer-taxon-resolver/src/test/java/org/eol/globi/service/GlobalNamesService2Test.java index 3c291787..b27fd335 100644 --- a/nomer-taxon-resolver/src/test/java/org/eol/globi/service/GlobalNamesService2Test.java +++ b/nomer-taxon-resolver/src/test/java/org/eol/globi/service/GlobalNamesService2Test.java @@ -438,4 +438,34 @@ public void foundTaxonForName(Long nodeId, String name, Taxon taxon, NameType na } + @Test + public void lookupNCBIIgnoreCanonicalMatchOnExactMatch() throws PropertyEnricherException { + GlobalNamesService2 service = new GlobalNamesService2(Arrays.asList(GlobalNamesSources2.NCBI)); + final List taxa = new ArrayList<>(); + service.findTermsForNames(Collections.singletonList("Amphipoda"), (nodeId, name, taxon, nameType) -> { + taxa.add(taxon); + assertThat(nameType, is(NameType.SAME_AS)); + }); + + assertThat(taxa.size(), is(1)); + assertThat(taxa.get(0).getPath(), endsWith("Amphipoda")); + assertThat(taxa.get(0).getPathNames(), endsWith("order")); + + } + + @Test + public void lookupNCBIIgnoreCanonicalMatchSingleWordSpecies() throws PropertyEnricherException { + GlobalNamesService2 service = new GlobalNamesService2(Collections.singletonList(GlobalNamesSources2.NCBI)); + final List taxa = new ArrayList<>(); + service.findTermsForNames(Collections.singletonList("Procladius sp1 M_PL_014"), (nodeId, name, taxon, nameType) -> { + taxa.add(taxon); + assertThat(nameType, is(NameType.SAME_AS)); + }); + + assertThat(taxa.size(), is(1)); + assertThat(taxa.get(0).getPath(), endsWith("Procladius")); + assertThat(taxa.get(0).getPathNames(), endsWith("genus")); + + } + }