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

[TA] Added HeathcareEntityCategory type and disable failed tests #44

Merged
merged 2 commits into from
Jun 10, 2021
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
5 changes: 3 additions & 2 deletions sdk/textanalytics/azure-ai-textanalytics/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Release History

## 5.1.0-beta.8 (Unreleased)

## 5.1.0 (Unreleased)
#### Feature Added
- Added a new class, `HealthcareEntityCategory` to replace the `String` type of property `category` in the `HealthcareEntity`.

## 5.1.0-beta.7 (2021-05-19)
### Features Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.azure.ai.textanalytics.models.EntityDataSource;
import com.azure.ai.textanalytics.models.HealthcareEntity;
import com.azure.ai.textanalytics.models.HealthcareEntityAssertion;
import com.azure.ai.textanalytics.models.HealthcareEntityCategory;
import com.azure.core.util.IterableStream;

/**
Expand All @@ -22,7 +23,7 @@ private HealthcareEntityPropertiesHelper() { }
public interface HealthcareEntityAccessor {
void setText(HealthcareEntity healthcareEntity, String text);
void setNormalizedText(HealthcareEntity healthcareEntity, String normalizedText);
void setCategory(HealthcareEntity healthcareEntity, String category);
void setCategory(HealthcareEntity healthcareEntity, HealthcareEntityCategory category);
void setSubcategory(HealthcareEntity healthcareEntity, String subcategory);
void setConfidenceScore(HealthcareEntity healthcareEntity, double confidenceScore);
void setDataSources(HealthcareEntity healthcareEntity, IterableStream<EntityDataSource> dataSources);
Expand All @@ -44,7 +45,7 @@ public static void setText(HealthcareEntity healthcareEntity, String text) {
accessor.setText(healthcareEntity, text);
}

public static void setCategory(HealthcareEntity healthcareEntity, String category) {
public static void setCategory(HealthcareEntity healthcareEntity, HealthcareEntityCategory category) {
accessor.setCategory(healthcareEntity, category);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import com.azure.ai.textanalytics.models.ExtractKeyPhraseResult;
import com.azure.ai.textanalytics.models.HealthcareEntity;
import com.azure.ai.textanalytics.models.HealthcareEntityAssertion;
import com.azure.ai.textanalytics.models.HealthcareEntityCategory;
import com.azure.ai.textanalytics.models.HealthcareEntityRelation;
import com.azure.ai.textanalytics.models.HealthcareEntityRelationRole;
import com.azure.ai.textanalytics.models.HealthcareEntityRelationType;
Expand Down Expand Up @@ -525,7 +526,10 @@ public static IterableStream<AnalyzeHealthcareEntitiesResult> toRecognizeHealthc
final HealthcareEntity healthcareEntity = new HealthcareEntity();
HealthcareEntityPropertiesHelper.setText(healthcareEntity, entity.getText());
HealthcareEntityPropertiesHelper.setNormalizedText(healthcareEntity, entity.getName());
HealthcareEntityPropertiesHelper.setCategory(healthcareEntity, entity.getCategory());
if (entity.getCategory() != null) {
HealthcareEntityPropertiesHelper.setCategory(healthcareEntity,
HealthcareEntityCategory.fromString(entity.getCategory().toString()));
}
HealthcareEntityPropertiesHelper.setConfidenceScore(healthcareEntity,
entity.getConfidenceScore());
HealthcareEntityPropertiesHelper.setOffset(healthcareEntity, entity.getOffset());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
public final class HealthcareEntity {
private String text;
private String normalizedText;
private String category;
private HealthcareEntityCategory category;
private String subcategory;
private double confidenceScore;
private int offset;
Expand All @@ -33,7 +33,7 @@ public void setNormalizedText(HealthcareEntity healthcareEntity, String normaliz
}

@Override
public void setCategory(HealthcareEntity healthcareEntity, String category) {
public void setCategory(HealthcareEntity healthcareEntity, HealthcareEntityCategory category) {
healthcareEntity.setCategory(category);
}

Expand Down Expand Up @@ -94,7 +94,7 @@ public String getNormalizedText() {
*
* @return The category value.
*/
public String getCategory() {
public HealthcareEntityCategory getCategory() {
return this.category;
}

Expand Down Expand Up @@ -161,7 +161,7 @@ private void setNormalizedText(String normalizedText) {
this.normalizedText = normalizedText;
}

private void setCategory(String category) {
private void setCategory(HealthcareEntityCategory category) {
this.category = category;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.ai.textanalytics.models;

import com.azure.core.annotation.Immutable;
import com.azure.core.util.ExpandableStringEnum;
import com.fasterxml.jackson.annotation.JsonCreator;

/**
* Gets the healthcare entity category inferred by the text analytics service's healthcare entity recognition model.
* The list of available categories is described at
* See <a href="https://docs.microsoft.com/azure/cognitive-services/Text-Analytics/named-entity-types?tabs=health">healthcare entity types</a>.
*/
@Immutable
public final class HealthcareEntityCategory extends ExpandableStringEnum<HealthcareEntityCategory> {
/** Static value BODY_STRUCTURE for HealthcareEntityCategory. */
public static final HealthcareEntityCategory BODY_STRUCTURE = fromString("BODY_STRUCTURE");

/** Static value AGE for HealthcareEntityCategory. */
public static final HealthcareEntityCategory AGE = fromString("AGE");

/** Static value GENDER for HealthcareEntityCategory. */
public static final HealthcareEntityCategory GENDER = fromString("GENDER");

/** Static value EXAMINATION_NAME for HealthcareEntityCategory. */
public static final HealthcareEntityCategory EXAMINATION_NAME = fromString("EXAMINATION_NAME");

/** Static value DATE for HealthcareEntityCategory. */
public static final HealthcareEntityCategory DATE = fromString("DATE");

/** Static value DIRECTION for HealthcareEntityCategory. */
public static final HealthcareEntityCategory DIRECTION = fromString("DIRECTION");

/** Static value FREQUENCY for HealthcareEntityCategory. */
public static final HealthcareEntityCategory FREQUENCY = fromString("FREQUENCY");

/** Static value MEASUREMENT_VALUE for HealthcareEntityCategory. */
public static final HealthcareEntityCategory MEASUREMENT_VALUE = fromString("MEASUREMENT_VALUE");

/** Static value MEASUREMENT_UNIT for HealthcareEntityCategory. */
public static final HealthcareEntityCategory MEASUREMENT_UNIT = fromString("MEASUREMENT_UNIT");

/** Static value RELATIONAL_OPERATOR for HealthcareEntityCategory. */
public static final HealthcareEntityCategory RELATIONAL_OPERATOR = fromString("RELATIONAL_OPERATOR");

/** Static value TIME for HealthcareEntityCategory. */
public static final HealthcareEntityCategory TIME = fromString("TIME");

/** Static value GENE_OR_PROTEIN for HealthcareEntityCategory. */
public static final HealthcareEntityCategory GENE_ORPROTEIN = fromString("GENE_OR_PROTEIN");

/** Static value VARIANT for HealthcareEntityCategory. */
public static final HealthcareEntityCategory VARIANT = fromString("VARIANT");

/** Static value ADMINISTRATIVE_EVENT for HealthcareEntityCategory. */
public static final HealthcareEntityCategory ADMINISTRATIVE_EVENT = fromString("ADMINISTRATIVE_EVENT");

/** Static value CARE_ENVIRONMENT for HealthcareEntityCategory. */
public static final HealthcareEntityCategory CARE_ENVIRONMENT = fromString("CARE_ENVIRONMENT");

/** Static value HEALTHCARE_PROFESSION for HealthcareEntityCategory. */
public static final HealthcareEntityCategory HEALTHCARE_PROFESSION = fromString("HEALTHCARE_PROFESSION");

/** Static value DIAGNOSIS for HealthcareEntityCategory. */
public static final HealthcareEntityCategory DIAGNOSIS = fromString("DIAGNOSIS");

/** Static value SYMPTOM_OR_SIGN for HealthcareEntityCategory. */
public static final HealthcareEntityCategory SYMPTOM_OR_SIGN = fromString("SYMPTOM_OR_SIGN");

/** Static value CONDITION_QUALIFIER for HealthcareEntityCategory. */
public static final HealthcareEntityCategory CONDITION_QUALIFIER = fromString("CONDITION_QUALIFIER");

/** Static value MEDICATION_CLASS for HealthcareEntityCategory. */
public static final HealthcareEntityCategory MEDICATION_CLASS = fromString("MEDICATION_CLASS");

/** Static value MEDICATION_NAME for HealthcareEntityCategory. */
public static final HealthcareEntityCategory MEDICATION_NAME = fromString("MEDICATION_NAME");

/** Static value DOSAGE for HealthcareEntityCategory. */
public static final HealthcareEntityCategory DOSAGE = fromString("DOSAGE");

/** Static value MEDICATION_FORM for HealthcareEntityCategory. */
public static final HealthcareEntityCategory MEDICATION_FORM = fromString("MEDICATION_FORM");

/** Static value MEDICATION_ROUTE for HealthcareEntityCategory. */
public static final HealthcareEntityCategory MEDICATION_ROUTE = fromString("MEDICATION_ROUTE");

/** Static value FAMILY_RELATION for HealthcareEntityCategory. */
public static final HealthcareEntityCategory FAMILY_RELATION = fromString("FAMILY_RELATION");

/** Static value TREATMENT_NAME for HealthcareEntityCategory. */
public static final HealthcareEntityCategory TREATMENT_NAME = fromString("TREATMENT_NAME");

/**
* Creates or finds a {@link HealthcareEntityCategory} from its string representation.
*
* @param name The string name to look for.
* @return The corresponding {@link HealthcareEntityCategory}.
*/
@JsonCreator
public static HealthcareEntityCategory fromString(String name) {
return fromString(name, HealthcareEntityCategory.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import com.azure.ai.textanalytics.models.ExtractKeyPhraseResult;
import com.azure.ai.textanalytics.models.ExtractKeyPhrasesActionResult;
import com.azure.ai.textanalytics.models.HealthcareEntity;
import com.azure.ai.textanalytics.models.HealthcareEntityCategory;
import com.azure.ai.textanalytics.models.HealthcareEntityRelation;
import com.azure.ai.textanalytics.models.HealthcareEntityRelationRole;
import com.azure.ai.textanalytics.models.HealthcareEntityRelationType;
Expand Down Expand Up @@ -684,7 +685,7 @@ static AnalyzeHealthcareEntitiesResult getRecognizeHealthcareEntitiesResult1(Str
// HealthcareEntity
final HealthcareEntity healthcareEntity1 = new HealthcareEntity();
HealthcareEntityPropertiesHelper.setText(healthcareEntity1, "54-year-old");
HealthcareEntityPropertiesHelper.setCategory(healthcareEntity1, "Age");
HealthcareEntityPropertiesHelper.setCategory(healthcareEntity1, HealthcareEntityCategory.AGE);
HealthcareEntityPropertiesHelper.setConfidenceScore(healthcareEntity1, 1.0);
HealthcareEntityPropertiesHelper.setOffset(healthcareEntity1, 17);
HealthcareEntityPropertiesHelper.setLength(healthcareEntity1, 11);
Expand All @@ -693,7 +694,7 @@ static AnalyzeHealthcareEntitiesResult getRecognizeHealthcareEntitiesResult1(Str
final HealthcareEntity healthcareEntity2 = new HealthcareEntity();
HealthcareEntityPropertiesHelper.setText(healthcareEntity2, "gentleman");
HealthcareEntityPropertiesHelper.setNormalizedText(healthcareEntity2, "Male population group");
HealthcareEntityPropertiesHelper.setCategory(healthcareEntity2, "Gender");
HealthcareEntityPropertiesHelper.setCategory(healthcareEntity2, HealthcareEntityCategory.GENDER);
HealthcareEntityPropertiesHelper.setConfidenceScore(healthcareEntity2, 1.0);
HealthcareEntityPropertiesHelper.setOffset(healthcareEntity2, 29);
HealthcareEntityPropertiesHelper.setLength(healthcareEntity2, 9);
Expand All @@ -704,7 +705,7 @@ static AnalyzeHealthcareEntitiesResult getRecognizeHealthcareEntitiesResult1(Str
IterableStream.of(Collections.emptyList()));
final HealthcareEntity healthcareEntity3 = new HealthcareEntity();
HealthcareEntityPropertiesHelper.setText(healthcareEntity3, "progressive");
HealthcareEntityPropertiesHelper.setCategory(healthcareEntity3, "ConditionQualifier");
HealthcareEntityPropertiesHelper.setCategory(healthcareEntity3, HealthcareEntityCategory.CONDITION_QUALIFIER);
HealthcareEntityPropertiesHelper.setConfidenceScore(healthcareEntity3, 0.91);
HealthcareEntityPropertiesHelper.setOffset(healthcareEntity3, 57);
HealthcareEntityPropertiesHelper.setLength(healthcareEntity3, 11);
Expand All @@ -713,7 +714,7 @@ static AnalyzeHealthcareEntitiesResult getRecognizeHealthcareEntitiesResult1(Str
final HealthcareEntity healthcareEntity4 = new HealthcareEntity();
HealthcareEntityPropertiesHelper.setText(healthcareEntity4, "angina");
HealthcareEntityPropertiesHelper.setNormalizedText(healthcareEntity4, "Angina Pectoris");
HealthcareEntityPropertiesHelper.setCategory(healthcareEntity4, "SymptomOrSign");
HealthcareEntityPropertiesHelper.setCategory(healthcareEntity4, HealthcareEntityCategory.SYMPTOM_OR_SIGN);
HealthcareEntityPropertiesHelper.setConfidenceScore(healthcareEntity4, 0.81);
HealthcareEntityPropertiesHelper.setOffset(healthcareEntity4, 69);
HealthcareEntityPropertiesHelper.setLength(healthcareEntity4, 6);
Expand All @@ -724,7 +725,7 @@ static AnalyzeHealthcareEntitiesResult getRecognizeHealthcareEntitiesResult1(Str
IterableStream.of(Collections.emptyList()));
final HealthcareEntity healthcareEntity5 = new HealthcareEntity();
HealthcareEntityPropertiesHelper.setText(healthcareEntity5, "past several months");
HealthcareEntityPropertiesHelper.setCategory(healthcareEntity5, "Time");
HealthcareEntityPropertiesHelper.setCategory(healthcareEntity5, HealthcareEntityCategory.TIME);
HealthcareEntityPropertiesHelper.setConfidenceScore(healthcareEntity5, 1.0);
HealthcareEntityPropertiesHelper.setOffset(healthcareEntity5, 85);
HealthcareEntityPropertiesHelper.setLength(healthcareEntity5, 19);
Expand Down Expand Up @@ -775,7 +776,7 @@ static AnalyzeHealthcareEntitiesResult getRecognizeHealthcareEntitiesResult2() {
// HealthcareEntity
final HealthcareEntity healthcareEntity1 = new HealthcareEntity();
HealthcareEntityPropertiesHelper.setText(healthcareEntity1, "six minutes");
HealthcareEntityPropertiesHelper.setCategory(healthcareEntity1, "Time");
HealthcareEntityPropertiesHelper.setCategory(healthcareEntity1, HealthcareEntityCategory.TIME);
HealthcareEntityPropertiesHelper.setConfidenceScore(healthcareEntity1, 0.87);
HealthcareEntityPropertiesHelper.setOffset(healthcareEntity1, 21);
HealthcareEntityPropertiesHelper.setLength(healthcareEntity1, 11);
Expand All @@ -784,7 +785,7 @@ static AnalyzeHealthcareEntitiesResult getRecognizeHealthcareEntitiesResult2() {
IterableStream.of(Collections.emptyList()));
final HealthcareEntity healthcareEntity2 = new HealthcareEntity();
HealthcareEntityPropertiesHelper.setText(healthcareEntity2, "minimal");
HealthcareEntityPropertiesHelper.setCategory(healthcareEntity2, "ConditionQualifier");
HealthcareEntityPropertiesHelper.setCategory(healthcareEntity2, HealthcareEntityCategory.CONDITION_QUALIFIER);
HealthcareEntityPropertiesHelper.setConfidenceScore(healthcareEntity2, 1.0);
HealthcareEntityPropertiesHelper.setOffset(healthcareEntity2, 38);
HealthcareEntityPropertiesHelper.setLength(healthcareEntity2, 7);
Expand All @@ -794,7 +795,7 @@ static AnalyzeHealthcareEntitiesResult getRecognizeHealthcareEntitiesResult2() {
final HealthcareEntity healthcareEntity3 = new HealthcareEntity();
HealthcareEntityPropertiesHelper.setText(healthcareEntity3, "ST depressions");
HealthcareEntityPropertiesHelper.setNormalizedText(healthcareEntity3, "ST segment depression (finding)");
HealthcareEntityPropertiesHelper.setCategory(healthcareEntity3, "SymptomOrSign");
HealthcareEntityPropertiesHelper.setCategory(healthcareEntity3, HealthcareEntityCategory.SYMPTOM_OR_SIGN);
HealthcareEntityPropertiesHelper.setConfidenceScore(healthcareEntity3, 1.0);
HealthcareEntityPropertiesHelper.setOffset(healthcareEntity3, 46);
HealthcareEntityPropertiesHelper.setLength(healthcareEntity3, 14);
Expand All @@ -803,7 +804,7 @@ static AnalyzeHealthcareEntitiesResult getRecognizeHealthcareEntitiesResult2() {
IterableStream.of(Collections.emptyList()));
final HealthcareEntity healthcareEntity4 = new HealthcareEntity();
HealthcareEntityPropertiesHelper.setText(healthcareEntity4, "anterior lateral");
HealthcareEntityPropertiesHelper.setCategory(healthcareEntity4, "Direction");
HealthcareEntityPropertiesHelper.setCategory(healthcareEntity4, HealthcareEntityCategory.DIRECTION);
HealthcareEntityPropertiesHelper.setConfidenceScore(healthcareEntity4, 0.6);
HealthcareEntityPropertiesHelper.setOffset(healthcareEntity4, 68);
HealthcareEntityPropertiesHelper.setLength(healthcareEntity4, 16);
Expand All @@ -813,7 +814,7 @@ static AnalyzeHealthcareEntitiesResult getRecognizeHealthcareEntitiesResult2() {
final HealthcareEntity healthcareEntity5 = new HealthcareEntity();
HealthcareEntityPropertiesHelper.setText(healthcareEntity5, "fatigue");
HealthcareEntityPropertiesHelper.setNormalizedText(healthcareEntity5, "Fatigue");
HealthcareEntityPropertiesHelper.setCategory(healthcareEntity5, "SymptomOrSign");
HealthcareEntityPropertiesHelper.setCategory(healthcareEntity5, HealthcareEntityCategory.SYMPTOM_OR_SIGN);
HealthcareEntityPropertiesHelper.setConfidenceScore(healthcareEntity5, 1.0);
HealthcareEntityPropertiesHelper.setOffset(healthcareEntity5, 108);
HealthcareEntityPropertiesHelper.setLength(healthcareEntity5, 7);
Expand All @@ -823,7 +824,7 @@ static AnalyzeHealthcareEntitiesResult getRecognizeHealthcareEntitiesResult2() {
final HealthcareEntity healthcareEntity6 = new HealthcareEntity();
HealthcareEntityPropertiesHelper.setText(healthcareEntity6, "wrist pain");
HealthcareEntityPropertiesHelper.setNormalizedText(healthcareEntity6, "Pain in wrist");
HealthcareEntityPropertiesHelper.setCategory(healthcareEntity6, "SymptomOrSign");
HealthcareEntityPropertiesHelper.setCategory(healthcareEntity6, HealthcareEntityCategory.SYMPTOM_OR_SIGN);
HealthcareEntityPropertiesHelper.setConfidenceScore(healthcareEntity6, 1.0);
HealthcareEntityPropertiesHelper.setOffset(healthcareEntity6, 120);
HealthcareEntityPropertiesHelper.setLength(healthcareEntity6, 10);
Expand All @@ -833,7 +834,7 @@ static AnalyzeHealthcareEntitiesResult getRecognizeHealthcareEntitiesResult2() {
final HealthcareEntity healthcareEntity7 = new HealthcareEntity();
HealthcareEntityPropertiesHelper.setText(healthcareEntity7, "anginal equivalent");
HealthcareEntityPropertiesHelper.setNormalizedText(healthcareEntity7, "Anginal equivalent");
HealthcareEntityPropertiesHelper.setCategory(healthcareEntity7, "SymptomOrSign");
HealthcareEntityPropertiesHelper.setCategory(healthcareEntity7, HealthcareEntityCategory.SYMPTOM_OR_SIGN);
HealthcareEntityPropertiesHelper.setConfidenceScore(healthcareEntity7, 1.0);
HealthcareEntityPropertiesHelper.setOffset(healthcareEntity7, 137);
HealthcareEntityPropertiesHelper.setLength(healthcareEntity7, 18);
Expand Down
Loading