Link Google automl translation custom model with glossary

135 Views Asked by At

I have built a custom translation model and a glossary using Google automl. This resulted in two different paths, one for using the model and a different one for the glossary. I was wondering if it would be possible to link both model and glossary to get a single path to connect model+glossary with a different translation tool (in my case Wordbee). I am now able to connect the model but not the glossary.

I know I can use together model and glossary making a POST request and with a request JSON, but what I want is to integrate together model and corresponding glossary in an external tool with a single path if possible. Something like

projects/project-number/locations/us-central1/model+glossary-id

Thanks in advance

1

There are 1 best solutions below

0
On

I think that you can essentially just combine the JSON of the glossary and model requests.

The HTTP method and URL is the same.

https://cloud.google.com/translate/docs/advanced/glossary#translate_v3_get_glossary-drest

HTTP method and URL:

POST https://translation.googleapis.com/v3/projects/PROJECT_NUMBER_OR_ID/locations/us-central1:translateText

Request JSON body:

{
 "sourceLanguageCode": "en",
 "targetLanguageCode": "ru",
 "contents": "Dr. Watson, please discard your trash. You've shared > unsolicited email with me. Let's talk about spam and importance ranking in a confidential mode.",
 "glossaryConfig": {
   "glossary": "projects/project-number/locations/us-> central1/glossaries/glossary-id",
   "ignoreCase": BOOLEAN
 }
}

https://cloud.google.com/translate/automl/docs/predict#using-translate-api

HTTP method and URL:

POST https://translation.googleapis.com/v3/projects/project-number-or-id/locations/us-central1:translateText

Request JSON body:

{
 "model": "projects/project-number-or-id/locations/us-central1/models/TRL1395675701985363739",
 "sourceLanguageCode": "en",
 "targetLanguageCode": "ru",
 "contents": ["Dr. Watson, please discard your trash. You've shared unsolicited email with me.
 Let's talk about spam and importance ranking in a confidential mode."]
}

You will end up with something like this.

{
  "model": "projects/project-number-or-id/locations/us-central1/models/TRL1395675701985363739",
  "glossaryConfig": {
   "glossary": "projects/project-number/locations/us-> central1/glossaries/glossary-id",
   "ignoreCase": BOOLEAN
  }
  "sourceLanguageCode": "en",
  "targetLanguageCode": "ru",
  "contents": ["Dr. Watson, please discard your trash. You've shared unsolicited email with me.
  Let's talk about spam and importance ranking in a confidential mode."]
}