GlobalNamesArchitecture / gnparser

Split scientific names to meaningful elements with meta information
https://parser.globalnames.org/
MIT License
20 stars 2 forks source link

Fix the bug with positioning #463

Closed alexander-myltsev closed 6 years ago

alexander-myltsev commented 6 years ago

This one has incorrect positions:

scala> fromString("<i>Velutina halioides</i> (Linnaeus, 1758)").render(false, false)
res3: String =
{
  "name_string_id" : "653bbe42-aef4-5847-add4-8c7f8a4d1f9b",
  "parsed" : true,
  "quality" : 2,
  "quality_warnings" : [ [ 2, "Name had to be changed by preprocessing" ] ],
  "parser_version" : "0.4.5-SNAPSHOT",
  "verbatim" : "<i>Velutina halioides</i> (Linnaeus, 1758)",
  "normalized" : "Velutina halioides (Linnaeus 1758)",
  "canonical_name" : {
    "value" : "Velutina halioides",
    "value_ranked" : "Velutina halioides"
  },
  "hybrid" : false,
  "surrogate" : false,
  "virus" : false,
  "bacteria" : false,
  "details" : [ {
    "genus" : {
      "value" : "Velutina"
    },
    "specific_epithet" : {
      "value" : "halioides",
      "authorship" : {
        "value" : "(Linnaeus 1758)",
        "basionym_authorship" : {
          "authors" : [ "Linnaeus" ],
          "year" : {
            "value" : "1758"
          }
        }
      }
    }
  } ],
  "positions" : [ [ "genus", 0, 10 ], [ "specific_epithet", 11, 20 ], [ "author_word", 25, 33 ], [ "year", 35, 39 ] ]
}

Positioning should be as follows:

<i>Velutina halioides</i> (Linnaeus, 1758)
start index -- 0 -- starts with 0, instead of 1
Velutina -- [3, 11] -- it is right open interval 
halioides [12, 21]
Linnaeus [27, 35]