lib/biodiversity/parser/scientific_name.treetop in dimus-biodiversity-0.0.6 vs lib/biodiversity/parser/scientific_name.treetop in dimus-biodiversity-0.0.7
- old
+ new
@@ -29,10 +29,12 @@
/
scientific_name
end
rule scientific_name
+ name_authors_part
+ /
space a:name_part space b:authors_part space c:status_part space {
def value
a.value + " " + b.value + " " + c.value
end
def canonical
@@ -96,10 +98,24 @@
}
/
latin_word
end
+ rule name_authors_part
+ a:species_name space b:authors_part space c:subspecies_name {
+ def value
+ a.value + " " + b.value + " " + c.value
+ end
+ def canonical
+ a.canonical + " " + c.canonical
+ end
+ def details
+ a.details.merge(c.details).merge({:species_authors=>b.details})
+ end
+ }
+ end
+
rule authors_part
a:original_authors_revised_name space b:authors_revised_name {
def value
a.value + " " + b.value
end
@@ -212,11 +228,13 @@
end
rule author_name_separator
("&"/",") {
def apply(a,b)
- a.value + " " + text_value + " " + b.value
+ sep = text_value.strip
+ sep = " " + sep if sep == "&"
+ a.value + sep + " " + b.value
end
def details(a,b)
{:authors => {:names => a.details[:authors][:names] + b.details[:authors][:names]}}
end
@@ -258,11 +276,11 @@
end
}
end
rule name_part
- space a:species_name space b:selector space_hard c:editorials_full {
+ space a:species_name space b:rank space_hard c:editorials_full {
def value
a.value + " " + b.value + " " + c.value
end
def canonical
a.canonical
@@ -293,11 +311,11 @@
def canonical
value
end
def details
- a.details.merge({:subspecies => {:type => "n/a", :value =>b.value}})
+ a.details.merge({:subspecies => {:rank => "n/a", :value =>b.value}})
end
}
/
species_name
/
@@ -322,11 +340,11 @@
/
subspecies_name
end
rule subspecies_name
- sel:selector space_hard a:latin_word {
+ sel:rank space_hard a:latin_word {
def value
sel.apply(a)
end
def canonical
sel.canonical(a)
@@ -350,20 +368,20 @@
end
}
end
rule editorials
- space a:selector space [&]? space b:editorials {
+ space a:rank space [&]? space b:editorials {
def value
a.value + b.value
end
}
/
- selector
+ rank
end
- rule selector
+ rule rank
("f.sp."/"f."/"B"/"ssp."/"mut."/"pseudovar."/"sect."/"ser."/"var."/"subvar."/ "[var.]" /"subsp."/"subf."/"race"/"α"
/"ββ"/"β"/"γ"/"δ"/"ε"/"φ"/"θ"/"μ"/"a."/"b."/"c."/"d."/"e."/"g."/"k."/"****"/"**"/"*")
{
def value
text_value.strip
@@ -373,17 +391,17 @@
end
def canonical(a)
" " + a.value
end
def details(a = nil)
- {:subspecies => [{:type => text_value, :value => (a.value rescue nil)}]}
+ {:subspecies => [{:rank => text_value, :value => (a.value rescue nil)}]}
end
}
end
rule species_name
- hybrid_separator space_hard a:cap_latin_word space_hard b:latin_word {
+ hybrid_separator space_hard a:cap_latin_word space_hard b:latin_word {
def value
"× " + a.value + " " + b.value
end
def canonical
a.value + " " + b.value
@@ -391,11 +409,11 @@
def details
{:genus => a.value, :species => b.value, :cross => 'before'}
end
}
/
- hybrid_separator space_hard a:cap_latin_word {
+ hybrid_separator space_hard a:cap_latin_word {
def value
"× " + a.value
end
def canonical
a.value
@@ -415,11 +433,11 @@
def details
{:genus => a.value, :species => b.value, :cross => 'inside'}
end
}
/
- a:cap_latin_word space_hard b:subgenus space_hard c:latin_word {
+ a:cap_latin_word space b:subgenus space c:latin_word {
def value
a.value + " " + b.value + " " + c.value
end
def canonical
a.value + " " + c.value
@@ -471,10 +489,10 @@
def canonical
text_value.strip
end
def details
- {:name_type => "Uninomial", :uninomial => value}
+ {:uninomial => value}
end
}
end
rule hybrid_separator
\ No newline at end of file