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
25 changes: 10 additions & 15 deletions sdk/translation/azure-ai-translation-text/README.md
Original file line number Diff line number Diff line change
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"
}
5 changes: 0 additions & 5 deletions sdk/translation/azure-ai-translation-text/pom.xml
Original file line number Diff line number Diff line change
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