Documentation
¶
Overview ¶
Example ¶
package main
import (
"fmt"
"log/slog"
"os"
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, err := dict.LoadDictionary()
if err != nil {
slog.Error("Cannot load dictionary")
os.Exit(1)
}
weights, err := nlp.BayesWeights()
if err != nil {
slog.Error("Cannot get Bayesian weights")
os.Exit(1)
}
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.10" 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.
Click to show internal directories.
Click to hide internal directories.