Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Text Translation] Updating to the latest TypeSpec #40035

Merged
merged 21 commits into from
May 17, 2024
2 changes: 1 addition & 1 deletion eng/versioning/version_client.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ com.azure:azure-ai-openai-assistants;1.0.0-beta.2;1.0.0-beta.3
com.azure:azure-ai-personalizer;1.0.0-beta.1;1.0.0-beta.2
com.azure:azure-ai-textanalytics;5.4.5;5.5.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.0.0-beta.1;1.0.0-beta.2
com.azure:azure-ai-translation-text;1.0.0-beta.1;1.0.0
com.azure:azure-analytics-defender-easm;1.0.0-beta.1;1.0.0-beta.2
com.azure:azure-analytics-purview-catalog;1.0.0-beta.4;1.0.0-beta.5
com.azure:azure-analytics-purview-datamap;1.0.0-beta.1;1.0.0-beta.2
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,13 +1,22 @@
# Release History

## 1.0.0-beta.2 (Unreleased)
## 1.0.0 (Unreleased)

### Features Added

- Added support for AAD authentication for Text Translation endpoints.
- Ability to translate strings directly without a need to create instances of objects.
- Options pattern used for methods with too many parameters.

### Breaking Changes

- Method `getSentLen` renamed to `getSentencesLengths`.
- `String` can be used for translate, transliterate, find sentence boundaries methods instead of `InputTextItem`.
- `GetLanguages*` classes and definitions were renamed to `GetSupportedLanguages*`.
- `getProj` method renamed to `getProjections`.
- `Translation` class renamed to `TranslationText`.
- `getScore` method renamed to `getConfidence`.

### Bugs Fixed

### Other Changes
Expand Down
27 changes: 11 additions & 16 deletions sdk/translation/azure-ai-translation-text/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Various documentation is available to help you get started
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-ai-translation-text</artifactId>
<version>1.0.0-beta.1</version>
<version>1.0.0</version>
</dependency>
```
[//]: # ({x-version-update-end})
Expand Down Expand Up @@ -96,7 +96,7 @@ The following section provides several code snippets using the `client` [created
Gets the set of languages currently supported by other operations of the Translator.

```java getTextTranslationLanguages
GetLanguagesResult languages = client.getLanguages();
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() + ".");
Expand Down Expand Up @@ -125,16 +125,14 @@ 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
String from = "en";
List<String> targetLanguages = new ArrayList<>();
targetLanguages.add("cs");
List<InputTextItem> content = new ArrayList<>();
content.add(new InputTextItem("This is a test."));
TranslateOptions translateOptions = new TranslateOptions()
.setSourceLanguage("en")
.addTargetLanguage("es");

List<TranslatedTextItem> translations = client.translate(targetLanguages, content, null, from, TextType.PLAIN, null, ProfanityAction.NO_ACTION, ProfanityMarker.ASTERISK, false, false, null, null, null, false);
List<TranslatedTextItem> translations = client.translate("This is a test.", translateOptions);

for (TranslatedTextItem translation : translations) {
for (Translation textTranslation : translation.getTranslations()) {
for (TranslationText textTranslation : translation.getTranslations()) {
System.out.println("Text was translated to: '" + textTranslation.getTo() + "' and the result is: '" + textTranslation.getText() + "'.");
}
}
Expand All @@ -150,8 +148,7 @@ Converts characters or letters of a source language to the corresponding charact
String language = "zh-Hans";
String fromScript = "Hans";
String toScript = "Latn";
List<InputTextItem> content = new ArrayList<>();
content.add(new InputTextItem("这是个测试。"));
String content = "这是个测试。";

List<TransliteratedText> transliterations = client.transliterate(language, fromScript, toScript, content);

Expand All @@ -169,13 +166,12 @@ Identifies the positioning of sentence boundaries in a piece of text.
```java getTextTranslationSentenceBoundaries
String sourceLanguage = "zh-Hans";
String sourceScript = "Latn";
List<InputTextItem> content = new ArrayList<>();
content.add(new InputTextItem("zhè shì gè cè shì。"));
String content = "zhè shì gè cè shì。";

List<BreakSentenceItem> breakSentences = client.findSentenceBoundaries(content, null, sourceLanguage, sourceScript);

for (BreakSentenceItem breakSentence : breakSentences) {
System.out.println("The detected sentence boundaries: " + breakSentence.getSentLen());
System.out.println("The detected sentence boundaries: " + breakSentence.getSentencesLengths());
}
```

Expand All @@ -188,8 +184,7 @@ Returns equivalent words for the source term in the target language.
```java getTextTranslationDictionaryLookup
String sourceLanguage = "en";
String targetLanguage = "es";
List<InputTextItem> content = new ArrayList<>();
content.add(new InputTextItem("fly"));
String content = "fly";

List<DictionaryLookupItem> dictionaryEntries = client.lookupDictionaryEntries(sourceLanguage, targetLanguage, content);

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_09668e5176"
"Tag": "java/translation/azure-ai-translation-text_a2b0c1776a"
}
7 changes: 1 addition & 6 deletions 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.0.0-beta.2</version> <!-- {x-version-update;com.azure:azure-ai-translation-text;current} -->
<version>1.0.0</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 Expand Up @@ -49,11 +49,6 @@
<artifactId>azure-core</artifactId>
<version>1.49.0</version> <!-- {x-version-update;com.azure:azure-core;dependency} -->
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core-experimental</artifactId>
<version>1.0.0-beta.50</version> <!-- {x-version-update;com.azure:azure-core-experimental;dependency} -->
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core-http-netty</artifactId>
Expand Down