-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
348 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
tidy: | ||
go mod tidy | ||
|
||
BinName=anto-v3.6.3-windows.exe | ||
BinName=anto-v3.7.0-windows.exe | ||
|
||
deploy: rs build | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package xfyun | ||
|
||
import ( | ||
"anto/domain/service/translator" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
type Config struct { | ||
*translator.DefaultConfig | ||
AppId string `mapstructure:"app_id"` | ||
ApiKey string `mapstructure:"api_key"` | ||
ApiSecret string `mapstructure:"api_secret"` | ||
QPS int `mapstructure:"qps"` | ||
MaxCharNum int `mapstructure:"max_single_text_length"` | ||
MaxCoroutineNum int `mapstructure:"max_coroutine_num"` | ||
} | ||
|
||
func (config *Config) Default() translator.ImplConfig { | ||
return &Config{ | ||
AppId: "", ApiKey: "", ApiSecret: "", | ||
MaxCharNum: 5000, QPS: 50, MaxCoroutineNum: 20, | ||
} | ||
} | ||
|
||
func (config *Config) SyncDisk(currentViper *viper.Viper) error { | ||
tagAndVal := config.JoinAllTagAndValue(API(), config, "mapstructure") | ||
|
||
for tag, val := range tagAndVal { | ||
currentViper.Set(tag, val) | ||
} | ||
return nil | ||
} | ||
|
||
func (config *Config) GetProjectKey() string { return config.AppId } | ||
func (config *Config) GetAK() string { return config.ApiKey } | ||
func (config *Config) GetSK() string { return config.ApiSecret } | ||
|
||
func (config *Config) GetQPS() int { return config.QPS } | ||
func (config *Config) GetMaxCharNum() int { return config.MaxCharNum } | ||
func (config *Config) GetMaxCoroutineNum() int { return config.MaxCoroutineNum } | ||
|
||
func (config *Config) SetProjectKey(str string) error { | ||
if err := config.ValidatorStr(str); err != nil { | ||
return err | ||
} | ||
config.AppId = str | ||
return nil | ||
} | ||
|
||
func (config *Config) SetAK(str string) error { | ||
if err := config.ValidatorStr(str); err != nil { | ||
return err | ||
} | ||
config.ApiKey = str | ||
return nil | ||
} | ||
|
||
func (config *Config) SetSK(str string) error { | ||
if err := config.ValidatorStr(str); err != nil { | ||
return err | ||
} | ||
config.ApiSecret = str | ||
return nil | ||
} | ||
|
||
func (config *Config) SetQPS(num int) error { | ||
if err := config.ValidatorNum(num); err != nil { | ||
return err | ||
} | ||
config.QPS = num | ||
return nil | ||
} | ||
|
||
func (config *Config) SetMaxCharNum(num int) error { | ||
if err := config.ValidatorNum(num); err != nil { | ||
return err | ||
} | ||
config.MaxCharNum = num | ||
return nil | ||
} | ||
|
||
func (config *Config) SetMaxCoroutineNum(num int) error { | ||
if err := config.ValidatorNum(num); err != nil { | ||
return err | ||
} | ||
config.MaxCoroutineNum = num | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package xfyun | ||
|
||
import ( | ||
"anto/domain/service/translator" | ||
) | ||
|
||
// @link https://www.xfyun.cn/doc/nlp/xftrans_new/API.html#%E8%AF%AD%E7%A7%8D%E5%88%97%E8%A1%A8 | ||
var langSupported = []translator.LangPair{ | ||
{"cn", "中文"}, {"en", "英语"}, {"cs", "捷克语"}, {"ha", "豪萨语"}, | ||
{"ja", "日语"}, {"ro", "罗马尼亚语"}, {"hu", "匈牙利语"}, {"ko", "韩语"}, | ||
{"sv", "瑞典语"}, {"sw", "斯瓦希里语"}, {"th", "泰语"}, {"nl", "荷兰语"}, | ||
{"uz", "乌兹别克语"}, {"ru", "俄语"}, {"pl", "波兰语"}, {"zu", "祖鲁语"}, | ||
{"bg", "保加利亚语"}, {"ar", "阿拉伯语"}, {"el", "希腊语"}, {"uk", "乌克兰语"}, | ||
{"fa", "波斯语"}, {"he", "希伯来语"}, {"vi", "越南语"}, {"ps", "普什图语"}, | ||
{"hy", "亚美尼亚语"}, {"ms", "马来语"}, {"ur", "乌尔都语"}, {"hy", "亚美尼亚语"}, | ||
{"ms", "马来语"}, {"ur", "乌尔都语"}, {"ka", "格鲁吉亚语"}, {"id", "印尼语"}, | ||
{"yue", "广东话"}, {"tl", "菲律宾语"}, {"bn", "孟加拉语"}, {"ii", "彝语"}, | ||
{"de", "德语"}, {"nm", "外蒙语"}, {"zua", "壮语"}, {"es", "西班牙语"}, | ||
{"kk", "外哈语"}, {"mn", "内蒙语"}, {"fr", "法语"}, {"tr", "土耳其语"}, | ||
{"kka", "内哈萨克语"}, | ||
} |
Oops, something went wrong.