gnfinder

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Example
package main

import (
	"fmt"

	gnfinder "github.com/gnames/gnfinder/pkg"
	"github.com/gnames/gnfinder/pkg/config"
	"github.com/gnames/gnfinder/pkg/ent/nlp"
	"github.com/gnames/gnfinder/pkg/io/dict"
)

func main() {
	txt := `Blue Adussel (Mytilus edulis) grows to about two
inches the first year,Pardosa moesta Banks, 1892`
	cfg := config.New()
	dictionary := dict.LoadDictionary()
	weights := nlp.BayesWeights()
	gnf := gnfinder.New(cfg, dictionary, weights)
	res := gnf.Find("", txt)
	name := res.Names[0]
	fmt.Printf(
		"Name: %s, start: %d, end: %d",
		name.Name,
		name.OffsetStart,
		name.OffsetEnd,
	)
}
Output:

Name: Mytilus edulis, start: 13, end: 29

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	Version = "v1.1.4"
	Build   string
)

Functions

This section is empty.

Types

type GNfinder

type GNfinder interface {
	// Find detects names in a `text`. The `file` argument provides the file-name
	// that contains the `text` (if given).
	Find(file, text string) output.Output

	// GetConfig provides all public Config fields.
	GetConfig() config.Config

	// ChangeConfig allows to modify config fields at the run-time.
	ChangeConfig(opts ...config.Option) GNfinder

	// GetVersion returns the version of GNfinder.
	GetVersion() gnvers.Version
}

GNfinder provides the main user-case functionality. It allows to find names in text, get/set configuration options, find out version of the project.

func New

func New(
	cfg config.Config,
	dictionaries *dict.Dictionary,
	weights map[lang.Language]bayes.Bayes,
) GNfinder

Directories

Path Synopsis
ent
api
nlp
token
Package token deals with breaking a text into tokens.
Package token deals with breaking a text into tokens.
io
dict
package dict contains dictionaries for finding scientific names
package dict contains dictionaries for finding scientific names
web

Jump to

Keyboard shortcuts

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