Sha256: 74b9682ec970d17821ad5d85c2d22cb5b03edcc967cde07fa5744fd8cda849bd

Contents?: true

Size: 1.8 KB

Versions: 7

Compression:

Stored size: 1.8 KB

Contents

# encoding: UTF-8
grammar ScientificNameCanonical
  include ScientificNameClean
  include ScientificNameDirty

  rule root
    multinomial_with_garbage {
      def hybrid
        false
      end

      def details
        [super]
      end
    }
    /
    uninomial_with_garbage {
      def hybrid
        false
      end
      
      def details
        [super]
      end
    }
  end
  
  rule multinomial_with_garbage
  
    a:genus space b:subgenus space c:species garbage {
      def value
        a.value + " " + b.value + " " + c.value
      end
      
      def canonical
        a.canonical + " " + b.canonical + " " + c.canonical
      end
      
      def pos
        a.pos.merge(b.pos).merge(c.pos)
      end
      
      def details
        a.details.merge(b.details).merge(c.details)
      end
    }
    /
    a:genus space b:subgenus garbage {
      def value
        a.value + " " + b.value
      end
      
      def canonical
        a.canonical + " " + b.canonical
      end
      
      def pos
        a.pos.merge(b.pos)
      end
      
      def details
        a.details.merge(b.details)
      end
    }
    /
    a:genus space b:species garbage {
      def value
        a.value + " " + b.value
      end
      
      def canonical
        a.canonical + " " + b.canonical
      end
      
      def pos
        a.pos.merge(b.pos)
      end
      
      def details
        a.details.merge(b.details)
      end
    }
  end
  
  rule uninomial_with_garbage
    a:uninomial_epitheton b:garbage {
      def value
        a.value
      end
      
      def canonical
        a.canonical
      end
      
      def pos
        a.pos
      end
      
      def details
        {:uninomial => a.details[:uninomial]}
      end
    }
  end
  
  rule garbage
    space (["',.]) space [^щ]*
    /
    space_hard [^ш]+
  end

end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
dimus-biodiversity-0.5.10 lib/biodiversity/parser/scientific_name_canonical.treetop
dimus-biodiversity-0.5.11 lib/biodiversity/parser/scientific_name_canonical.treetop
dimus-biodiversity-0.5.13 lib/biodiversity/parser/scientific_name_canonical.treetop
dimus-biodiversity-0.5.14 lib/biodiversity/parser/scientific_name_canonical.treetop
dimus-biodiversity-0.5.3 lib/biodiversity/parser/scientific_name_canonical.treetop
dimus-biodiversity-0.5.4 lib/biodiversity/parser/scientific_name_canonical.treetop
biodiversity-0.5.14 lib/biodiversity/parser/scientific_name_canonical.treetop