2023-08-16 13:15:21 +05:30
|
|
|
package utils
|
2023-08-17 19:39:18 +05:30
|
|
|
|
2023-08-30 15:13:34 +05:30
|
|
|
import "os"
|
|
|
|
|
2023-08-16 13:15:21 +05:30
|
|
|
func AutoDetectWatson(query string) (string, error) {
|
|
|
|
json := []byte(`{"text":"` + query + `"}`)
|
|
|
|
watsonOut := PostRequest("https://www.ibm.com/demos/live/watson-language-translator/api/translate/detect", json)
|
|
|
|
gjsonArr := watsonOut.Get("payload.languages.0.language.language").Array()
|
|
|
|
answer := gjsonArr[0].String()
|
|
|
|
return answer, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func AutoDetectLibreTranslate(query string) (string, error) {
|
|
|
|
json := []byte(`{"q":"` + query + `"}`)
|
2023-08-30 15:13:34 +05:30
|
|
|
libreTranslateOut := PostRequest(os.Getenv("MOZHI_LIBRETRANSLATE_URL")+"/detect", json)
|
2023-08-16 13:15:21 +05:30
|
|
|
gjsonArr := libreTranslateOut.Get("0.language").Array()
|
|
|
|
answer := gjsonArr[0].String()
|
|
|
|
return answer, nil
|
|
|
|
}
|