-
Notifications
You must be signed in to change notification settings - Fork 0
/
vocabulary.go
41 lines (36 loc) · 963 Bytes
/
vocabulary.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
package clientutil
import (
"strings"
voicebase "github.com/grokify/go-voicebase-v3/v3/client"
)
// BuildVocabulariesForStrings takes a list of strings and converts them
// to a list of `VbVocabulary` structs for use in uploading media.
func BuildVocabulariesForStrings(vocabNames ...string) []voicebase.VbVocabulary {
vocabs := []voicebase.VbVocabulary{}
for _, vocabName := range vocabNames {
vocabName = strings.TrimSpace(vocabName)
if len(vocabName) > 0 {
vocabs = append(vocabs, voicebase.VbVocabulary{
VocabularyName: vocabName,
})
}
}
return vocabs
}
type Vocabulary struct {
VocabularyName string
Term string
SoundsLike []string
}
func (v *Vocabulary) ToVbVocabulary() voicebase.VbVocabulary {
return voicebase.VbVocabulary{
VocabularyName: v.VocabularyName,
VocabularyType: voicebase.TERMS,
Terms: []voicebase.VbVocabularyTerm{
{
Term: v.Term,
SoundsLike: v.SoundsLike,
},
},
}
}