11# Azure Text Translation client library for Java
22
3- 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.
3+ 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.
44
55Use the Text Translation client library for Java to:
66
7- * Return a list of languages supported by Translate, Transliterate, and Dictionary operations.
7+ - Retrieve the list of languages supported for translation and transliteration operations, as well as LLM models available for translations .
88
9- * Render single source- language text to multiple target- language texts with a single request .
9+ - Perform deterministic text translation from a specified source language to a target language, with configurable parameters to ensure precision and maintain contextual integrity .
1010
11- * Convert text of a source language in letters of a different script.
11+ - Execute transliteration by converting text from the original script to an alternative script representation .
1212
13- * Return equivalent words for the source term in the target language.
14-
15- * Return grammatical structure and context examples for the source term and target term pair.
13+ - Use LLM models to produce translation output variants that are tone-specific and gender-aware.
1614
1715## Documentation
1816
@@ -36,7 +34,7 @@ Various documentation is available to help you get started
3634<dependency >
3735 <groupId >com.azure</groupId >
3836 <artifactId >azure-ai-translation-text</artifactId >
39- <version >1.2 .0-beta.1</version >
37+ <version >2.0 .0-beta.1</version >
4038</dependency >
4139```
4240[ // ] : # ( {x-version-update-end} )
@@ -100,7 +98,7 @@ GetSupportedLanguagesResult languages = client.getSupportedLanguages();
10098
10199System . out. println(" Number of supported languages for translate operation: " + languages. getTranslation(). size() + " ." );
102100System . out. println(" Number of supported languages for transliterate operation: " + languages. getTransliteration(). size() + " ." );
103- System . out. println(" Number of supported languages for dictionary operations : " + languages. getDictionary (). size() + " ." );
101+ System . out. println(" Number of supported models for translate operation : " + languages. getModels (). size() + " ." );
104102
105103System . out. println(" Translation Languages:" );
106104for (Map . Entry<String , TranslationLanguage > translationLanguage : languages. getTranslation(). entrySet()) {
@@ -112,9 +110,9 @@ for (Map.Entry<String, TransliterationLanguage> transliterationLanguage : langua
112110 System . out. println(transliterationLanguage. getKey() + " -- name: " + transliterationLanguage. getValue(). getName() + " , supported script count: " + transliterationLanguage. getValue(). getScripts(). size());
113111}
114112
115- System . out. println(" Dictionary Languages :" );
116- for (Map . Entry< String , SourceDictionaryLanguage > dictionaryLanguage : languages. getDictionary() . entrySet ()) {
117- System . out. println(dictionaryLanguage . getKey() + " -- name: " + dictionaryLanguage . getValue() . getName() + " , supported target languages count: " + dictionaryLanguage . getValue() . getTranslations() . size() );
113+ System . out. println(" Available models :" );
114+ for (String model : languages. getModels ()) {
115+ System . out. println(model );
118116}
119117```
120118
@@ -125,14 +123,15 @@ Please refer to the service documentation for a conceptual discussion of [langua
125123Renders single source-language text to multiple target-language texts with a single request.
126124
127125``` java getTextTranslationMultiple
128- TranslateOptions translateOptions = new TranslateOptions ()
129- .setSourceLanguage(" en" )
130- .addTargetLanguage(" es" );
126+ TranslateInputItem input = new TranslateInputItem (
127+ " This is a test." ,
128+ Arrays . asList(new TranslationTarget (" es" ), new TranslationTarget (" fr" )));
129+ input. setLanguage(" en" );
131130
132- TranslatedTextItem translation = client. translate(" This is a test. " , translateOptions );
131+ TranslatedTextItem translation = client. translate(Arrays . asList(input)) . get( 0 );
133132
134133for (TranslationText textTranslation : translation. getTranslations()) {
135- System . out. println(" Text was translated to: '" + textTranslation. getTargetLanguage () + " ' and the result is: '" + textTranslation. getText() + " '." );
134+ System . out. println(" Text was translated to: '" + textTranslation. getLanguage () + " ' and the result is: '" + textTranslation. getText() + " '." );
136135}
137136```
138137
@@ -155,58 +154,6 @@ System.out.println("Input text was transliterated to '" + transliteration.getScr
155154
156155Please refer to the service documentation for a conceptual discussion of [ transliterate] [ transliterate_doc ] .
157156
158- ### Break Sentence
159-
160- Identifies the positioning of sentence boundaries in a piece of text.
161-
162- ``` java getTextTranslationSentenceBoundaries
163- String sourceLanguage = " zh-Hans" ;
164- String sourceScript = " Latn" ;
165- String content = " zhè shì gè cè shì。" ;
166-
167- BreakSentenceItem breakSentence = client. findSentenceBoundaries(content, sourceLanguage, sourceScript);
168-
169- System . out. println(" The detected sentence boundaries: " + breakSentence. getSentencesLengths());
170- ```
171-
172- Please refer to the service documentation for a conceptual discussion of [ break sentence] [ breaksentence_doc ] .
173-
174- ### Dictionary Lookup
175-
176- Returns equivalent words for the source term in the target language.
177-
178- ``` java getTextTranslationDictionaryLookup
179- String sourceLanguage = " en" ;
180- String targetLanguage = " es" ;
181- String content = " fly" ;
182-
183- DictionaryLookupItem dictionaryEntry = client. lookupDictionaryEntries(sourceLanguage, targetLanguage, content);
184-
185- System . out. println(" For the given input " + dictionaryEntry. getTranslations(). size() + " entries were found in the dictionary." );
186- System . out. println(" First entry: '" + dictionaryEntry. getTranslations(). get(0 ). getDisplayTarget() + " ', confidence: " + dictionaryEntry. getTranslations(). get(0 ). getConfidence());
187- ```
188-
189- Please refer to the service documentation for a conceptual discussion of [ dictionary lookup] [ dictionarylookup_doc ] .
190-
191- ### Dictionary Examples
192-
193- Returns grammatical structure and context examples for the source term and target term pair.
194-
195- ``` java getTextTranslationDictionaryExamples
196- String sourceLanguage = " en" ;
197- String targetLanguage = " es" ;
198- List<DictionaryExampleTextItem > content = new ArrayList<> ();
199- content. add(new DictionaryExampleTextItem (" fly" , " volar" ));
200-
201- List<DictionaryExampleItem > dictionaryEntries = client. lookupDictionaryExamples(sourceLanguage, targetLanguage, content);
202-
203- for (DictionaryExampleItem dictionaryEntry : dictionaryEntries) {
204- System . out. println(" For the given input " + dictionaryEntry. getExamples(). size() + " entries were found in the dictionary." );
205- System . out. println(" Example: '" + dictionaryEntry. getExamples(). get(0 ). getTargetPrefix() + dictionaryEntry. getExamples(). get(0 ). getTargetTerm() + dictionaryEntry. getExamples(). get(0 ). getTargetSuffix());
206- }
207- ```
208-
209- Please refer to the service documentation for a conceptual discussion of [ dictionary examples] [ dictionaryexamples_doc ] .
210157
211158## Troubleshooting
212159
@@ -225,19 +172,14 @@ Samples are provided for each main functional area, and for each area, samples a
225172* [ Translation to multiple languages] [ sample_translatetargets ]
226173* [ Translation of multiple sources] [ sample_translatesources ]
227174* [ Translation and Transliteration] [ sample_translatetransliteration ]
175+ * [ Translation using LLM] [ sample_translatelargelanguagemodel ]
228176* [ Using Custom Translation Model] [ sample_translatecustom ]
229- * [ Translation with Custom Dictionary] [ sample_translatedictionary ]
230177* [ Translation with NoTranslate tag] [ sample_translatenotranslate ]
231- * [ Translation with Alignments] [ sample_translatealignments ]
232- * [ Translation with Sentence Boundaries] [ sample_translatesentencelength ]
233178* [ Handling translation of HTML text] [ sample_translatetexttypes ]
234179* [ Transliteration] [ sample_transliterate ]
235180* [ Get Languages] [ sample_getlanguages ]
236181* [ Get Localized Languages] [ sample_getlanguagesaccept ]
237182* [ Get Scoped Languages] [ sample_getlanguagesscope ]
238- * [ Find Sentence Boundaries] [ sample_breaksentence ]
239- * [ Lookup Dictionary Examples] [ sample_dictionaryexamples ]
240- * [ Lookup Dictionary Entries] [ sample_dictionarylookup ]
241183
242184## Contributing
243185
@@ -250,7 +192,7 @@ For details on contributing to this repository, see the [contributing guide](htt
2501921 . Create new Pull Request
251193
252194<!-- LINKS -->
253- [ product_documentation ] : https://learn.microsoft.com/azure/cognitive -services/translator/reference/v3-0-reference
195+ [ product_documentation ] : https://learn.microsoft.com/azure/ai -services/translator/text-translation/preview/overview
254196[ docs ] : https://azure.github.io/azure-sdk-for-java/
255197[ jdk ] : https://learn.microsoft.com/java/azure/jdk/
256198[ azure_subscription ] : https://azure.microsoft.com/free/
@@ -259,32 +201,24 @@ For details on contributing to this repository, see the [contributing guide](htt
259201[ azure_cli ] : https://learn.microsoft.com/cli/azure
260202[ azure_portal ] : https://portal.azure.com
261203
262- [ translator_auth ] : https://learn.microsoft.com/azure/cognitive -services/translator/reference/v3-0- reference# authentication
204+ [ translator_auth ] : https://learn.microsoft.com/azure/ai -services/translator/text-translation/ reference/ authentication
263205[ translator_limits ] : https://learn.microsoft.com/azure/cognitive-services/translator/request-limits
264206
265- [ languages_doc ] : https://learn.microsoft.com/azure/cognitive-services/translator/reference/v3-0-languages
266- [ translate_doc ] : https://learn.microsoft.com/azure/cognitive-services/translator/reference/v3-0-translate
267- [ transliterate_doc ] : https://learn.microsoft.com/azure/cognitive-services/translator/reference/v3-0-transliterate
268- [ breaksentence_doc ] : https://learn.microsoft.com/azure/cognitive-services/translator/reference/v3-0-break-sentence
269- [ dictionarylookup_doc ] : https://learn.microsoft.com/azure/cognitive-services/translator/reference/v3-0-dictionary-lookup
270- [ dictionaryexamples_doc ] : https://learn.microsoft.com/azure/cognitive-services/translator/reference/v3-0-dictionary-examples
207+ [ languages_doc ] : https://learn.microsoft.com/azure/ai-services/translator/text-translation/preview/get-languages
208+ [ translate_doc ] : https://learn.microsoft.com/azure/ai-services/translator/text-translation/preview/translate-api
209+ [ transliterate_doc ] : https://learn.microsoft.com/azure/ai-services/translator/text-translation/preview/transliterate-api
271210
272- [ 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
273- [ 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
274- [ 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
275211[ 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
276212[ 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
277213[ 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
278214[ 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
279- [ 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
215+ [ 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
280216[ 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
281217[ 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
282- [ 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
283218[ 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
284219[ 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
285220[ 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
286221[ 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
287- [ 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
288222[ 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
289223[ 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
290224[ 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
0 commit comments