[TA] Changes based on V3.0 swagger, etc#10593
Conversation
...e-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/AnalyzeSentimentAsyncClient.java
Outdated
Show resolved
Hide resolved
...i-textanalytics/src/main/java/com/azure/ai/textanalytics/models/RecognizeEntitiesResult.java
Outdated
Show resolved
Hide resolved
...e-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/AnalyzeSentimentAsyncClient.java
Show resolved
Hide resolved
...ure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/DetectLanguageAsyncClient.java
Outdated
Show resolved
Hide resolved
...e-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/ExtractKeyPhraseAsyncClient.java
Show resolved
Hide resolved
...ure-ai-textanalytics/src/samples/java/com/azure/ai/textanalytics/RecognizeEntitiesAsync.java
Show resolved
Hide resolved
...lytics/src/samples/java/com/azure/ai/textanalytics/batch/AnalyzeSentimentBatchDocuments.java
Outdated
Show resolved
Hide resolved
...s/src/samples/java/com/azure/ai/textanalytics/batch/AnalyzeSentimentBatchDocumentsAsync.java
Outdated
Show resolved
Hide resolved
...ytics/src/samples/java/com/azure/ai/textanalytics/batch/ExtractKeyPhrasesBatchDocuments.java
Outdated
Show resolved
Hide resolved
...ics/azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/LinkedEntity.java
Outdated
Show resolved
Hide resolved
samvaity
left a comment
There was a problem hiding this comment.
Left a few comments, but rest LGTM.
| public static HttpResponse getMockHttpResponse(SimpleResponse<?> response) { | ||
| return new HttpResponse(response.getRequest()) { | ||
| @Override | ||
| public int getStatusCode() { |
There was a problem hiding this comment.
Is it expected to only return the status code in the response?
There was a problem hiding this comment.
The exception the user will get should be the same as if the service returns a status = 400 and all the information with it.
For .net, for example, we have status, error code, and error message and we throw a RequestFailedException
There was a problem hiding this comment.
This is HttpResponse implementation class. Unless we know what is the expected header values and etc. We can make it up. But the for error message, it exist in the HttpResponseException level.
...e-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/AnalyzeSentimentAsyncClient.java
Show resolved
Hide resolved
| Objects.requireNonNull(documents, "'documents' cannot be null."); | ||
| final Iterator<?> iterator = documents.iterator(); | ||
| if (!iterator.hasNext()) { | ||
| throw new IllegalArgumentException("'documents' cannot be empty."); |
...azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/DetectedLanguage.java
Outdated
Show resolved
Hide resolved
...zure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/DocumentSentiment.java
Outdated
Show resolved
Hide resolved
...tics/src/samples/java/com/azure/ai/textanalytics/TextAnalyticsClientJavaDocCodeSnippets.java
Outdated
Show resolved
Hide resolved
...lytics/src/samples/java/com/azure/ai/textanalytics/batch/AnalyzeSentimentBatchDocuments.java
Outdated
Show resolved
Hide resolved
...-ai-textanalytics/src/test/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClientTest.java
Show resolved
Hide resolved
|
|
||
| <T> T clientSetup(Function<HttpPipeline, T> clientBuilder) { | ||
| TokenCredential credential = null; | ||
| AzureKeyCredential credential = null; |
There was a problem hiding this comment.
Any particular reason we changed this from AAD to AzureKeyCredential?
There was a problem hiding this comment.
the new endpoint, is only support Key Credential, it is owned by the service team. We are just using it temporately.
| "networkCallRecords" : [ { | ||
| "Method" : "POST", | ||
| "Uri" : "https://javatextanalyticstestresources.cognitiveservices.azure.com/text/analytics/v3.0-preview.1/entities/linking", | ||
| "Uri" : "https://westus2.ppe.cognitiveservices.azure.com/text/analytics/v3.0//entities/linking", |
There was a problem hiding this comment.
extra / .
Also, do we need to update all the recordings?
There was a problem hiding this comment.
extra / should be fine.
There is a lot of place involving renaming, such as, score to confidenceScore
.../azure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/implementation/Utility.java
Outdated
Show resolved
Hide resolved
...-ai-textanalytics/src/test/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClientTest.java
Show resolved
Hide resolved
...-ai-textanalytics/src/test/java/com/azure/ai/textanalytics/TextAnalyticsAsyncClientTest.java
Outdated
Show resolved
Hide resolved
...zure-ai-textanalytics/src/main/java/com/azure/ai/textanalytics/models/SentenceSentiment.java
Outdated
Show resolved
Hide resolved
| public TextDocumentInput(String id, String text) { | ||
| this.id = id; | ||
| this.text = text; | ||
| this.language = "en"; |
There was a problem hiding this comment.
Sorry I was wrong when I suggested this, I didn't realize that this TextDocumentInput constructor didn't take language. I'm confused though: it looks like in master you had two constructors: one that took language, one that did not.
I think you should still have two constructors here like in master. For the one that doesn't take language as a parameter, it should set this.language = "en", since that is the default. Otherwise, this.language = language
There was a problem hiding this comment.
if in the future, the default lanauge is change to 'es. we need to update it to es`. Since service team take default value in service side, we should not add what they are maintaining here. So keep no-assigned in SDK should be an better idea.
| * @return The object {@link TextDocumentInput} itself. | ||
| */ | ||
| public void setLanguage(String language) { | ||
| public TextDocumentInput setLanguage(String language) { |
There was a problem hiding this comment.
i'm not sure i understand the context on just making setLanguage a setter and not adding it to a separate constructor like you used to have it. Is there a reason why you can't add this constructor back like it is in master:
I really don't think it's a good idea to force users to call TextDocumentInput.setLanguage("en") for the most basic version of TextDocumentInput (you're doing this in your tests). What I think you should do is have two constructors exactly how it is in master. Is there a reason why you're changing this code?
There was a problem hiding this comment.
the only time constructor needed is when the parameter is required. But since language is optional. it should not go to constructor. Let's say maybe in the future, more parameter will be added to this class, we will not add another constructor if the value is not required.
TextAnalyticsErrorExceptiontoHttpResponseExceptionand added testsgetText()toSentenceSentimentTextAnalyticsWarningand one expandatable enumWarningCodeTextDocumentInput(String id, String text, String language)constructor, but addedsetLanguage()setter sincelanguageis optional.getGraphemeLength()andgetGraphemeOffset()fromCategorizedEntity,SentenceSentiment, andLinkedEntityMatch.getGraphemeCount()inTextDocumentStatisticshas been renamed togetCharacterCount(). fixes: [TA] Encoding and removing grapheme prefix #10587property added to each document-level response object returned from the endpoints. It is a list ofTextAnalyticsWarnings`. fixes: [TA] Warnings is enable in V3.0. Add it to single and batch APIs #10586CategorizedEntityCollection,KeyPhrasesCollection,LinkedEntityCollectionfor havinggetWarnings()to retrieve warnings.ADDRESStoEntityCategory.TextAnalyticsPagedFlux<CategorizedEntity> recognizeEntities(String document)toMono<CategorizedEntityCollection> recognizeEntities(String document).TextAnalyticsPagedFlux<LinkedEntity> recognizeLinkedEntities(String document)toMono<LinkedEntityCollection> recognizeLinkedEntities(String document).TextAnalyticsPagedFlux<String> extractKeyPhrases(String document)toMono<KeyPhrasesCollection> extractKeyPhrases(String document).TextAnalyticsPagedIterable<CategorizedEntity> recognizeEntities(String document)toCategorizedEntityCollection recognizeEntities(String document).TextAnalyticsPagedIterable<LinkedEntity> recognizeLinkedEntities(String document)toLinkedEntityCollection recognizeLinkedEntities(String document).TextAnalyticsPagedIterable<String> extractKeyPhrases(String document)toKeyPhrasesCollection extractKeyPhrases(String document).