lac

package module
v0.0.0-...-af7bea5 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: MIT Imports: 10 Imported by: 0

README

lac

Go Reference

Go Inference API for LAC.

Installation

  1. Install lac

    $ go get -u github.com/go-aie/lac
    
  2. Install Paddle Inference Go API

Documentation

Check out the documentation.

Testing

Generate the inference model:

$ python3 cli/cli.py download

Run tests:

$ go test -v -race | grep -E 'go|Test'
=== RUN   TestCustomization_Parse
--- PASS: TestCustomization_Parse (0.00s)
=== RUN   TestTriedTree_Search
--- PASS: TestTriedTree_Search (0.00s)
=== RUN   TestLAC_Seg
--- PASS: TestLAC_Seg (0.15s)
ok  	github.com/go-aie/lac	1.188s

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadQ2bVocab

func LoadQ2bVocab(filename string) (map[string]string, error)

func NewTokenizer

func NewTokenizer(wordVocabFile, q2bVocabFile string) (*aietokenizer.Tokenizer, error)

Types

type Config

type Config struct {
	ModelPath, ParamsPath string
	WordVocabFile         string
	TagVocabFile          string
	Q2bVocabFile          string
	UserDict              string
	DoLowerCase           bool
	ForCN                 bool
	// The maximum number of predictors for concurrent inferences.
	// Defaults to the value of runtime.NumCPU.
	MaxConcurrency int
}

type Customization

type Customization struct {
	// contains filtered or unexported fields
}

func NewCustomization

func NewCustomization() *Customization

func (*Customization) LoadFromFile

func (c *Customization) LoadFromFile(filename string) error

func (*Customization) LoadFromSlice

func (c *Customization) LoadFromSlice(lines []string)

func (*Customization) Parse

func (c *Customization) Parse(text string, tags []*Tag)

type Data

type Data struct {
	Text   string
	TagIDs []int64
}

type LAC

type LAC struct {
	// contains filtered or unexported fields
}

func NewLAC

func NewLAC(cfg *Config) *LAC

func (*LAC) LAC

func (l *LAC) LAC(texts []string) ([]Segments, error)

func (*LAC) Seg

func (l *LAC) Seg(texts []string) ([][]string, error)

type Offset

type Offset struct {
	Start int // The start offset.
	End   int // The end offset.
}

type Segment

type Segment struct {
	Word string
	POS  string
	Offset
}

type Segments

type Segments []Segment

func (Segments) POSs

func (s Segments) POSs() []string

func (Segments) Words

func (s Segments) Words() []string

type Tag

func NewTag

func NewTag(s string) *Tag

func (*Tag) SetPOSIfNonempty

func (t *Tag) SetPOSIfNonempty(pos string)

func (*Tag) String

func (t *Tag) String() string

type Trie

type Trie struct {
	// contains filtered or unexported fields
}

func NewTrie

func NewTrie() Trie

func (Trie) Add

func (t Trie) Add(word string)

func (Trie) Search

func (t Trie) Search(text string) []Offset

Search implements FMM (Forward maximum matching).

type Vocab

type Vocab struct {
	// contains filtered or unexported fields
}

func NewVocab

func NewVocab(wordVocabFile, q2bVocabFile string) (*Vocab, error)

func (*Vocab) TokenToID

func (v *Vocab) TokenToID(token string) (int, error)

func (*Vocab) UnkToken

func (v *Vocab) UnkToken() string

func (*Vocab) Vocab

func (v *Vocab) Vocab() map[string]int

Jump to

Keyboard shortcuts

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