Search in sources :

Example 1 with GetGlossaryRequest

use of com.google.cloud.translate.v3.GetGlossaryRequest in project java-translate by googleapis.

the class GetGlossary method getGlossary.

// Get a particular glossary based on the glossary ID
public static void getGlossary(String projectId, String glossaryId) throws IOException {
    // the "close" method on the client to safely clean up any remaining background resources.
    try (TranslationServiceClient client = TranslationServiceClient.create()) {
        // Supported Locations: `global`, [glossary location], or [model location]
        // Glossaries must be hosted in `us-central1`
        // Custom Models must use the same location as your model. (us-central1)
        GlossaryName glossaryName = GlossaryName.of(projectId, "us-central1", glossaryId);
        GetGlossaryRequest request = GetGlossaryRequest.newBuilder().setName(glossaryName.toString()).build();
        Glossary response = client.getGlossary(request);
        System.out.printf("Glossary name: %s\n", response.getName());
        System.out.printf("Entry count: %s\n", response.getEntryCount());
        System.out.printf("Input URI: %s\n", response.getInputConfig().getGcsSource().getInputUri());
    }
}
Also used : GetGlossaryRequest(com.google.cloud.translate.v3.GetGlossaryRequest) TranslationServiceClient(com.google.cloud.translate.v3.TranslationServiceClient) Glossary(com.google.cloud.translate.v3.Glossary) GlossaryName(com.google.cloud.translate.v3.GlossaryName)

Aggregations

GetGlossaryRequest (com.google.cloud.translate.v3.GetGlossaryRequest)1 Glossary (com.google.cloud.translate.v3.Glossary)1 GlossaryName (com.google.cloud.translate.v3.GlossaryName)1 TranslationServiceClient (com.google.cloud.translate.v3.TranslationServiceClient)1