parser

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

package parser allows extract elements from a query string and create Input object required for GNames faceted search.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Pretty

func Pretty(pretty bool) func(*engine) error

func Size

func Size(size int) func(*engine) error

Types

type Parser

type Parser interface {
	// ParseQuery takes a query string, parses it, registers warnings if
	// query is not well-formed, and packs received data into a search.Input
	// object.
	ParseQuery(q string) search.Input

	// Debug takes a query string, parses it, and prints aot an abstract
	// syntax tree of the parsed result. This method is used for developing
	// and debuging the parser behavior.
	Debug(string)
}

Parser contains methods for parsing a faceted search query for GNames.

func New

func New() Parser

New creates a new Parser object for converting a query string into search.Input object.

type Tag

type Tag int

Tag represents allowed tags in a search query. The tags in the query should be followed by a colon character. Only NameString tag is allowed to have more than one word.

For example `g:Hom. sp:sapiens`, `n:Homo sapiens`

const (
	Author Tag = iota
	DataSourceID
	ParentTaxon
	Year
	NameString
	Uninomial
	Genus
	Species
	SpeciesAny
	SpeciesInfra
)

func (Tag) String

func (t Tag) String() string

String returns a string representation of a tag.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL