-
Notifications
You must be signed in to change notification settings - Fork 5
/
option.go
68 lines (58 loc) · 1.3 KB
/
option.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package hanlp
import (
"time"
)
// Options opts define
type Options struct {
URL string
Auth string
Language string
Timeout time.Time
Tasks []string
SkipTasks []string
OutPut interface{}
Tokens []string
}
// Option opts list func
type Option func(*Options)
// WithURL 设置hanlp地址
func WithURL(url string) Option {
return func(o *Options) {
o.URL = url
}
}
// WithAuth 设置授权码
func WithAuth(auth string) Option {
return func(o *Options) {
o.Auth = auth
}
}
// WithLanguage 设置语言
func WithLanguage(language string) Option {
return func(o *Options) {
o.Language = language
}
}
// WithTimeout 调用超时设置
func WithTimeout(timeout time.Time) Option {
return func(o *Options) {
o.Timeout = timeout
}
}
// WithTasks 设置任务列表("tok","ud","ner","srl","sdp/dm","sdp/pas","sdp/psd","con")
func WithTasks(tasks ...string) Option {
return func(o *Options) {
o.Tasks = append(o.Tasks, tasks...)
}
}
// WithSkipTasks 设置忽略的任务列表("tok","ud","ner","srl","sdp/dm","sdp/pas","sdp/psd","con")
func WithSkipTasks(skipTasks ...string) Option {
return func(o *Options) {
o.SkipTasks = append(o.SkipTasks, skipTasks...)
}
}
func WithTokens(tokens ...string) Option {
return func(o *Options) {
o.Tokens = append(o.Tokens, tokens...)
}
}