gnquery

package module
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2025 License: MIT Imports: 2 Imported by: 2

README

GNquery

This is a library for parsing search query for GNames API. It creates an Input object that is further used for faceted search. The search.Input object is able to create search filters genus, specific epithet, abbreviated name, author, year, parent clade, or data-source.

Usage

import (
	"fmt"

	"github.com/gnames/gnquery"
)

func Example() {
	q := "ds:2 tx:Aves g:Bubo asp:bubo y:1758"
	gnq := gnquery.New()
	res := gnq.Parse(q)
	fmt.Println(res.Query)
	fmt.Println(res.DataSourceID)
	fmt.Println(res.ParentTaxon)
	fmt.Println(res.Genus)
	fmt.Println(res.SpeciesAny)
	fmt.Println(res.Year)
	fmt.Println(res.Tail)
	// Output:
	// ds:2 tx:Aves g:Bubo asp:bubo y:1758
	// 2
	// Aves
	// Bubo
	// bubo
	// 1758
  //
}

License

Released under MIT license

Documentation

Overview

gnquery package is a parser of a search query for GNames API. The query is used for faceted search that can be filtered by abbreviated name, by species epithet, author, year, a parent clade.

Example
package main

import (
	"fmt"

	"github.com/gnames/gnquery"
)

func main() {
	q := "ds:2 tx:Aves g:Bubo asp:bubo y:1758"
	gnq := gnquery.New()
	res := gnq.Parse(q)
	fmt.Println(res.Query)
	fmt.Println(res.DataSources)
	fmt.Println(res.ParentTaxon)
	fmt.Println(res.Genus)
	fmt.Println(res.SpeciesAny)
	fmt.Println(res.Year)
	fmt.Println(res.Tail)
}
Output:
ds:2 tx:Aves g:Bubo asp:bubo y:1758
[2]
Aves
Bubo
bubo
1758

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GNquery

type GNquery interface {
	// Parse takes a query and returns back an Input object for performing
	// a faceted search in GNames.
	Parse(q string) search.Input

	// Process takes an search.Input, updates its fields if necessary
	// (for example if there is a query or name fields) and returns
	// this updated input.
	Process(inp search.Input) search.Input
}

GNquery is an object for parsing search queries by GNames.

func New

func New() GNquery

New returns GNquery object. GNquery provides conversion of a query into search parameters.

Directories

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

Jump to

Keyboard shortcuts

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