mirror of
https://github.com/eeeXun/GTT.git
synced 2025-05-21 01:50:36 -07:00
style: rename
This commit is contained in:
parent
0d6a3576d6
commit
adc1e2e632
@ -143,14 +143,14 @@ func (t *BingTranslate) Translate(message string) (translation, definition, part
|
||||
if err != nil {
|
||||
return "", "", "", err
|
||||
}
|
||||
// Bing will return a list request part of speech success
|
||||
// Bing will return the request with list when success
|
||||
// Otherwises, it would return map
|
||||
// Then the following err would not be nil
|
||||
if err = json.Unmarshal(body, &data); err == nil {
|
||||
set := make(posSet)
|
||||
for _, pos := range data[0].(map[string]interface{})["translations"].([]interface{}) {
|
||||
pos := pos.(map[string]interface{})
|
||||
var words translationWord
|
||||
var words translationWords
|
||||
|
||||
words.target = pos["displayTarget"].(string)
|
||||
for _, backTranslation := range pos["backTranslations"].([]interface{}) {
|
||||
|
@ -4,20 +4,20 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type translationWord struct {
|
||||
type translationWords struct {
|
||||
target string
|
||||
backTargets []string
|
||||
}
|
||||
|
||||
func (t *translationWord) add(s string) {
|
||||
func (t *translationWords) add(s string) {
|
||||
t.backTargets = append(t.backTargets, s)
|
||||
}
|
||||
|
||||
type posSet map[string][]translationWord
|
||||
type posSet map[string][]translationWords
|
||||
|
||||
func (set posSet) add(tag string, words translationWord) {
|
||||
func (set posSet) add(tag string, words translationWords) {
|
||||
if _, ok := set[tag]; !ok {
|
||||
set[tag] = []translationWord{words}
|
||||
set[tag] = []translationWords{words}
|
||||
} else {
|
||||
set[tag] = append(set[tag], words)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user