Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eng/versioning/version_client.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ com.azure:azure-ai-personalizer;1.0.0-beta.1;1.0.0-beta.2
com.azure:azure-ai-projects;1.0.0-beta.3;1.0.0-beta.4
com.azure:azure-ai-textanalytics;5.5.11;5.6.0-beta.1
com.azure:azure-ai-textanalytics-perf;1.0.0-beta.1;1.0.0-beta.1
com.azure:azure-ai-translation-text;1.1.7;1.2.0-beta.1
com.azure:azure-ai-translation-text;1.1.7;2.0.0-beta.1
com.azure:azure-ai-translation-document;1.0.6;1.1.0-beta.1
com.azure:azure-ai-vision-face;1.0.0-beta.2;1.0.0-beta.3
com.azure:azure-ai-voicelive;1.0.0-beta.2;1.0.0-beta.3
Expand Down
11 changes: 10 additions & 1 deletion sdk/translation/azure-ai-translation-text/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
# Release History

## 1.2.0-beta.1 (Unreleased)
## 2.0.0-beta.1 (Unreleased)

### Features Added

- Added support for the latest Azure AI Translator API, including translations using LLM models, adaptive custom translation, tone variant translations, and gender-specific translations.
- Added `TranslationTarget` class for configuring translation options.

### Breaking Changes

- Added `Models` property to `GetSupportedLanguagesResult` to include the list of LLM models available for translations.
- Changed the name of `TargetLanguage` property to `Language` in `TranslationText`.
- Changed the name of `Confidence` property to `Score` in `DetectedLanguage`.
- Removed `SourceText` and `Transliteration` properties in translation responses.
- Dictionary, sentence boundaries and text alignments features have been deprecated and relevant classes and properties have been removed.

### Bugs Fixed

### Other Changes
Expand Down
112 changes: 23 additions & 89 deletions sdk/translation/azure-ai-translation-text/README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
# Azure Text Translation client library for Java

Text translation is a cloud-based REST API feature of the Translator service that uses neural machine translation technology to enable quick and accurate source-to-target text translation in real time across all supported languages.
Azure text translation is a cloud-based REST API provided by the Azure Translator service. It utilizes neural machine translation technology to deliver precise, contextually relevant, and semantically accurate real-time text translations across all supported languages.

Use the Text Translation client library for Java to:

* Return a list of languages supported by Translate, Transliterate, and Dictionary operations.
- Retrieve the list of languages supported for translation and transliteration operations, as well as LLM models available for translations.

* Render single source-language text to multiple target-language texts with a single request.
- Perform deterministic text translation from a specified source language to a target language, with configurable parameters to ensure precision and maintain contextual integrity.

* Convert text of a source language in letters of a different script.
- Execute transliteration by converting text from the original script to an alternative script representation.

* Return equivalent words for the source term in the target language.

* Return grammatical structure and context examples for the source term and target term pair.
- Use LLM models to produce translation output variants that are tone-specific and gender-aware.

## Documentation

Expand All @@ -36,7 +34,7 @@ Various documentation is available to help you get started
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-ai-translation-text</artifactId>
<version>1.2.0-beta.1</version>
<version>2.0.0-beta.1</version>
</dependency>
```
[//]: # ({x-version-update-end})
Expand Down Expand Up @@ -100,7 +98,7 @@ GetSupportedLanguagesResult languages = client.getSupportedLanguages();

System.out.println("Number of supported languages for translate operation: " + languages.getTranslation().size() + ".");
System.out.println("Number of supported languages for transliterate operation: " + languages.getTransliteration().size() + ".");
System.out.println("Number of supported languages for dictionary operations: " + languages.getDictionary().size() + ".");
System.out.println("Number of supported models for translate operation: " + languages.getModels().size() + ".");

System.out.println("Translation Languages:");
for (Map.Entry<String, TranslationLanguage> translationLanguage : languages.getTranslation().entrySet()) {
Expand All @@ -112,9 +110,9 @@ for (Map.Entry<String, TransliterationLanguage> transliterationLanguage : langua
System.out.println(transliterationLanguage.getKey() + " -- name: " + transliterationLanguage.getValue().getName() + ", supported script count: " + transliterationLanguage.getValue().getScripts().size());
}

System.out.println("Dictionary Languages:");
for (Map.Entry<String, SourceDictionaryLanguage> dictionaryLanguage : languages.getDictionary().entrySet()) {
System.out.println(dictionaryLanguage.getKey() + " -- name: " + dictionaryLanguage.getValue().getName() + ", supported target languages count: " + dictionaryLanguage.getValue().getTranslations().size());
System.out.println("Available models:");
for (String model : languages.getModels()) {
System.out.println(model);
}
```

Expand All @@ -125,14 +123,15 @@ Please refer to the service documentation for a conceptual discussion of [langua
Renders single source-language text to multiple target-language texts with a single request.

```java getTextTranslationMultiple
TranslateOptions translateOptions = new TranslateOptions()
.setSourceLanguage("en")
.addTargetLanguage("es");
TranslateInputItem input = new TranslateInputItem(
"This is a test.",
Arrays.asList(new TranslationTarget("es"), new TranslationTarget("fr")));
input.setLanguage("en");

TranslatedTextItem translation = client.translate("This is a test.", translateOptions);
TranslatedTextItem translation = client.translate(Arrays.asList(input)).get(0);

for (TranslationText textTranslation : translation.getTranslations()) {
System.out.println("Text was translated to: '" + textTranslation.getTargetLanguage() + "' and the result is: '" + textTranslation.getText() + "'.");
System.out.println("Text was translated to: '" + textTranslation.getLanguage() + "' and the result is: '" + textTranslation.getText() + "'.");
}
```

Expand All @@ -155,58 +154,6 @@ System.out.println("Input text was transliterated to '" + transliteration.getScr

Please refer to the service documentation for a conceptual discussion of [transliterate][transliterate_doc].

### Break Sentence

Identifies the positioning of sentence boundaries in a piece of text.

```java getTextTranslationSentenceBoundaries
String sourceLanguage = "zh-Hans";
String sourceScript = "Latn";
String content = "zhè shì gè cè shì。";

BreakSentenceItem breakSentence = client.findSentenceBoundaries(content, sourceLanguage, sourceScript);

System.out.println("The detected sentence boundaries: " + breakSentence.getSentencesLengths());
```

Please refer to the service documentation for a conceptual discussion of [break sentence][breaksentence_doc].

### Dictionary Lookup

Returns equivalent words for the source term in the target language.

```java getTextTranslationDictionaryLookup
String sourceLanguage = "en";
String targetLanguage = "es";
String content = "fly";

DictionaryLookupItem dictionaryEntry = client.lookupDictionaryEntries(sourceLanguage, targetLanguage, content);

System.out.println("For the given input " + dictionaryEntry.getTranslations().size() + " entries were found in the dictionary.");
System.out.println("First entry: '" + dictionaryEntry.getTranslations().get(0).getDisplayTarget() + "', confidence: " + dictionaryEntry.getTranslations().get(0).getConfidence());
```

Please refer to the service documentation for a conceptual discussion of [dictionary lookup][dictionarylookup_doc].

### Dictionary Examples

Returns grammatical structure and context examples for the source term and target term pair.

```java getTextTranslationDictionaryExamples
String sourceLanguage = "en";
String targetLanguage = "es";
List<DictionaryExampleTextItem> content = new ArrayList<>();
content.add(new DictionaryExampleTextItem("fly", "volar"));

List<DictionaryExampleItem> dictionaryEntries = client.lookupDictionaryExamples(sourceLanguage, targetLanguage, content);

for (DictionaryExampleItem dictionaryEntry : dictionaryEntries) {
System.out.println("For the given input " + dictionaryEntry.getExamples().size() + " entries were found in the dictionary.");
System.out.println("Example: '" + dictionaryEntry.getExamples().get(0).getTargetPrefix() + dictionaryEntry.getExamples().get(0).getTargetTerm() + dictionaryEntry.getExamples().get(0).getTargetSuffix());
}
```

Please refer to the service documentation for a conceptual discussion of [dictionary examples][dictionaryexamples_doc].

## Troubleshooting

Expand All @@ -225,19 +172,14 @@ Samples are provided for each main functional area, and for each area, samples a
* [Translation to multiple languages][sample_translatetargets]
* [Translation of multiple sources][sample_translatesources]
* [Translation and Transliteration][sample_translatetransliteration]
* [Translation using LLM][sample_translatelargelanguagemodel]
* [Using Custom Translation Model][sample_translatecustom]
* [Translation with Custom Dictionary][sample_translatedictionary]
* [Translation with NoTranslate tag][sample_translatenotranslate]
* [Translation with Alignments][sample_translatealignments]
* [Translation with Sentence Boundaries][sample_translatesentencelength]
* [Handling translation of HTML text][sample_translatetexttypes]
* [Transliteration][sample_transliterate]
* [Get Languages][sample_getlanguages]
* [Get Localized Languages][sample_getlanguagesaccept]
* [Get Scoped Languages][sample_getlanguagesscope]
* [Find Sentence Boundaries][sample_breaksentence]
* [Lookup Dictionary Examples][sample_dictionaryexamples]
* [Lookup Dictionary Entries][sample_dictionarylookup]

## Contributing

Expand All @@ -250,7 +192,7 @@ For details on contributing to this repository, see the [contributing guide](htt
1. Create new Pull Request

<!-- LINKS -->
[product_documentation]: https://learn.microsoft.com/azure/cognitive-services/translator/reference/v3-0-reference
[product_documentation]: https://learn.microsoft.com/azure/ai-services/translator/text-translation/preview/overview
[docs]: https://azure.github.io/azure-sdk-for-java/
[jdk]: https://learn.microsoft.com/java/azure/jdk/
[azure_subscription]: https://azure.microsoft.com/free/
Expand All @@ -259,32 +201,24 @@ For details on contributing to this repository, see the [contributing guide](htt
[azure_cli]: https://learn.microsoft.com/cli/azure
[azure_portal]: https://portal.azure.com

[translator_auth]: https://learn.microsoft.com/azure/cognitive-services/translator/reference/v3-0-reference#authentication
[translator_auth]: https://learn.microsoft.com/azure/ai-services/translator/text-translation/reference/authentication
[translator_limits]: https://learn.microsoft.com/azure/cognitive-services/translator/request-limits

[languages_doc]: https://learn.microsoft.com/azure/cognitive-services/translator/reference/v3-0-languages
[translate_doc]: https://learn.microsoft.com/azure/cognitive-services/translator/reference/v3-0-translate
[transliterate_doc]: https://learn.microsoft.com/azure/cognitive-services/translator/reference/v3-0-transliterate
[breaksentence_doc]: https://learn.microsoft.com/azure/cognitive-services/translator/reference/v3-0-break-sentence
[dictionarylookup_doc]: https://learn.microsoft.com/azure/cognitive-services/translator/reference/v3-0-dictionary-lookup
[dictionaryexamples_doc]: https://learn.microsoft.com/azure/cognitive-services/translator/reference/v3-0-dictionary-examples
[languages_doc]: https://learn.microsoft.com/azure/ai-services/translator/text-translation/preview/get-languages
[translate_doc]: https://learn.microsoft.com/azure/ai-services/translator/text-translation/preview/translate-api
[transliterate_doc]: https://learn.microsoft.com/azure/ai-services/translator/text-translation/preview/transliterate-api

[sample_breaksentence]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/BreakSentence.java
[sample_dictionaryexamples]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/DictionaryExamples.java
[sample_dictionarylookup]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/DictionaryLookup.java
[sample_getlanguages]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/GetLanguages.java
[sample_getlanguagesaccept]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/GetLanguagesAcceptLanguage.java
[sample_getlanguagesscope]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/GetLanguagesScope.java
[sample_translate]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/Translate.java
[sample_translatealignments]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateAlignments.java
[sample_translatelargelanguagemodel]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateLlm.java
[sample_translatecustom]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateCustom.java
[sample_translatedetection]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateDetection.java
[sample_translatedictionary]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateDictionary.java
[sample_translatesources]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateMultipleSources.java
[sample_translatetargets]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateMultipleTargets.java
[sample_translatenotranslate]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateNoTranslate.java
[sample_translateprofanity]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateProfanity.java
[sample_translatesentencelength]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateSentenceLength.java
[sample_translatetexttypes]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateTextType.java
[sample_translatetransliteration]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/TranslateWithTransliteration.java
[sample_transliterate]: https://github.com/azure/azure-sdk-for-java/blob/main/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/Transliterate.java
Expand Down
2 changes: 1 addition & 1 deletion sdk/translation/azure-ai-translation-text/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "java",
"TagPrefix": "java/translation/azure-ai-translation-text",
"Tag": "java/translation/azure-ai-translation-text_177e917101"
"Tag": "java/translation/azure-ai-translation-text_3fac03d964"
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import org.slf4j.Logger;

/**
* This class contains the customization code to customize the TypeSpec generated code for Text Translation Client Builder.
* This class contains the customization code to customize the TypeSpec generated code for Text Translation.
*/
public class TextTranslationClientBuilderCustomization extends Customization {
public class TextTranslationCustomization extends Customization {

@Override
public void customize(LibraryCustomization customization, Logger logger) {
Expand Down Expand Up @@ -36,5 +36,29 @@ public void customize(LibraryCustomization customization, Logger logger) {
}
});
});

logger.info("Customizing the TextTranslationServiceVersion enum - removing V3_0");
customization.getClass("com.azure.ai.translation.text", "TextTranslationServiceVersion")
.customizeAst(ast -> ast.getEnumByName("TextTranslationServiceVersion")
.ifPresent(enumDeclaration -> {
enumDeclaration.getEntries().stream()
.filter(entry -> entry.getNameAsString().equals("V3_0"))
.findFirst()
.ifPresent(enumConstant -> enumConstant.remove());
}
)
);

logger.info("Customizing the client classes - public protocol methods");
customization.getClass("com.azure.ai.translation.text", "TextTranslationClient").customizeAst(ast ->
ast.getClassByName("TextTranslationClient").ifPresent(clazz -> {
clazz.getMethodsByName("translateWithResponse").forEach(method -> method.setPublic(true));
clazz.getMethodsByName("transliterateWithResponse").forEach(method -> method.setPublic(true));
}));
customization.getClass("com.azure.ai.translation.text", "TextTranslationAsyncClient").customizeAst(ast ->
ast.getClassByName("TextTranslationAsyncClient").ifPresent(clazz -> {
clazz.getMethodsByName("translateWithResponse").forEach(method -> method.setPublic(true));
clazz.getMethodsByName("transliterateWithResponse").forEach(method -> method.setPublic(true));
}));
}
}
2 changes: 1 addition & 1 deletion sdk/translation/azure-ai-translation-text/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>com.azure</groupId>
<artifactId>azure-ai-translation-text</artifactId>
<version>1.2.0-beta.1</version> <!-- {x-version-update;com.azure:azure-ai-translation-text;current} -->
<version>2.0.0-beta.1</version> <!-- {x-version-update;com.azure:azure-ai-translation-text;current} -->

<name>Microsoft Azure client library for Text Translation</name>
<description>This package contains Microsoft Azure Text Translation client library.</description>
Expand Down
Loading