| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using System.ComponentModel; |
| | 6 | | using Azure.Core; |
| | 7 | |
|
| | 8 | | namespace Azure.AI.TextAnalytics |
| | 9 | | { |
| | 10 | | /// <summary> |
| | 11 | | /// Gets the entity category inferred by the Text Analytics service's named entity recognition model. |
| | 12 | | /// The list of available categories is described at <see href="https://docs.microsoft.com/azure/cognitive-services/ |
| | 13 | | /// </summary> |
| | 14 | | public readonly struct EntityCategory : IEquatable<EntityCategory> |
| | 15 | | { |
| | 16 | | /// <summary> |
| | 17 | | /// Specifies that the entity corresponds to a Person. |
| | 18 | | /// </summary> |
| 0 | 19 | | public static readonly EntityCategory Person = new EntityCategory("Person"); |
| | 20 | |
|
| | 21 | | /// <summary> |
| | 22 | | /// Specifies that the entity corresponds to a job type or role held by a person. |
| | 23 | | /// </summary> |
| 0 | 24 | | public static readonly EntityCategory PersonType = new EntityCategory("PersonType"); |
| | 25 | |
|
| | 26 | | /// <summary> |
| | 27 | | /// Specifies that the entity contains natural or human-made landmarks, structures, or geographical features. |
| | 28 | | /// </summary> |
| 0 | 29 | | public static readonly EntityCategory Location = new EntityCategory("Location"); |
| | 30 | |
|
| | 31 | | /// <summary> |
| | 32 | | /// Specifies that the entity contains the name of an organization, corporation, agency, or other group of peopl |
| | 33 | | /// </summary> |
| 0 | 34 | | public static readonly EntityCategory Organization = new EntityCategory("Organization"); |
| | 35 | |
|
| | 36 | | /// <summary> |
| | 37 | | /// Specifies that the entity contains historical, social and natural-occuring events. |
| | 38 | | /// </summary> |
| 0 | 39 | | public static readonly EntityCategory Event = new EntityCategory("Event"); |
| | 40 | |
|
| | 41 | | /// <summary> |
| | 42 | | /// Specifies that the entity contains physical objects of various categories. |
| | 43 | | /// </summary> |
| 0 | 44 | | public static readonly EntityCategory Product = new EntityCategory("Product"); |
| | 45 | |
|
| | 46 | | /// <summary> |
| | 47 | | /// Specifies an entity describing a capability or expertise. |
| | 48 | | /// </summary> |
| 0 | 49 | | public static readonly EntityCategory Skill = new EntityCategory("Skill"); |
| | 50 | |
|
| | 51 | | /// <summary> |
| | 52 | | /// Specifies that the entity contains a date, time or duration. |
| | 53 | | /// </summary> |
| 0 | 54 | | public static readonly EntityCategory DateTime = new EntityCategory("DateTime"); |
| | 55 | |
|
| | 56 | | /// <summary> |
| | 57 | | /// Specifies that the entity contains a phone number (US phone numbers only). |
| | 58 | | /// </summary> |
| 0 | 59 | | public static readonly EntityCategory PhoneNumber = new EntityCategory("PhoneNumber"); |
| | 60 | |
|
| | 61 | | /// <summary> |
| | 62 | | /// Specifies that the entity contains an email address. |
| | 63 | | /// </summary> |
| 0 | 64 | | public static readonly EntityCategory Email = new EntityCategory("Email"); |
| | 65 | |
|
| | 66 | | /// <summary> |
| | 67 | | /// Specifies that the entity contains an Internet URL. |
| | 68 | | /// </summary> |
| 0 | 69 | | public static readonly EntityCategory Url = new EntityCategory("URL"); |
| | 70 | |
|
| | 71 | | /// <summary> |
| | 72 | | /// Specifies that the entity contains an Internet Protocol Address. |
| | 73 | | /// </summary> |
| 0 | 74 | | public static readonly EntityCategory IPAddress = new EntityCategory("IP"); |
| | 75 | |
|
| | 76 | | /// <summary> |
| | 77 | | /// Specifies that the entity contains a number or numeric quantity. |
| | 78 | | /// </summary> |
| 0 | 79 | | public static readonly EntityCategory Quantity = new EntityCategory("Quantity"); |
| | 80 | |
|
| | 81 | | /// <summary> |
| | 82 | | /// Specifies that the entity contains an address. |
| | 83 | | /// </summary> |
| 0 | 84 | | public static readonly EntityCategory Address = new EntityCategory("Address"); |
| | 85 | |
|
| | 86 | | private readonly string _value; |
| | 87 | |
|
| | 88 | | private EntityCategory(string category) |
| | 89 | | { |
| 196 | 90 | | Argument.AssertNotNull(category, nameof(category)); |
| 196 | 91 | | _value = category; |
| 196 | 92 | | } |
| | 93 | |
|
| | 94 | | /// <summary> |
| | 95 | | /// Defines implicit conversion from string to EntityCategory. |
| | 96 | | /// </summary> |
| | 97 | | /// <param name="category">string to convert.</param> |
| | 98 | | /// <returns>The string as an EntityCategory.</returns> |
| 196 | 99 | | public static implicit operator EntityCategory(string category) => new EntityCategory(category); |
| | 100 | |
|
| | 101 | | /// <summary> |
| | 102 | | /// Defines explicit conversion from EntityCategory to string. |
| | 103 | | /// </summary> |
| | 104 | | /// <param name="category">EntityCategory to convert.</param> |
| | 105 | | /// <returns>The EntityCategory as a string.</returns> |
| 0 | 106 | | public static explicit operator string(EntityCategory category) => category._value; |
| | 107 | |
|
| | 108 | | /// <summary> |
| | 109 | | /// Compares two EntityCategory values for equality. |
| | 110 | | /// </summary> |
| | 111 | | /// <param name="left">The first EntityCategory to compare.</param> |
| | 112 | | /// <param name="right">The second EntityCategory to compare.</param> |
| | 113 | | /// <returns>true if the EntityCategory objects are equal or are both null; false otherwise.</returns> |
| 0 | 114 | | public static bool operator ==(EntityCategory left, EntityCategory right) => Equals(left, right); |
| | 115 | |
|
| | 116 | | /// <summary> |
| | 117 | | /// Compares two EntityCategory values for inequality. |
| | 118 | | /// </summary> |
| | 119 | | /// <param name="left">The first EntityCategory to compare.</param> |
| | 120 | | /// <param name="right">The second EntityCategory to compare.</param> |
| | 121 | | /// <returns>true if the EntityCategory objects are not equal; false otherwise.</returns> |
| 0 | 122 | | public static bool operator !=(EntityCategory left, EntityCategory right) => !Equals(left, right); |
| | 123 | |
|
| | 124 | | /// <summary> |
| | 125 | | /// Compares the EntityCategory for equality with another EntityCategory. |
| | 126 | | /// </summary> |
| | 127 | | /// <param name="other">The EntityCategory with which to compare.</param> |
| | 128 | | /// <returns><c>true</c> if the EntityCategory objects are equal; otherwise, <c>false</c>.</returns> |
| 0 | 129 | | public bool Equals(EntityCategory other) => _value == other._value; |
| | 130 | |
|
| | 131 | | /// <summary> |
| | 132 | | /// Determines whether the specified object is equal to the current object. |
| | 133 | | /// </summary> |
| | 134 | | /// <param name="obj">The object to compare with the current object.</param> |
| | 135 | | /// <returns><c>true</c> if the specified object is equal to the current object; otherwise, <c>false</c>.</retur |
| | 136 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| 0 | 137 | | public override bool Equals(object obj) => obj is EntityCategory category && Equals(category); |
| | 138 | |
|
| | 139 | | /// <summary> |
| | 140 | | /// Serves as the default hash function. |
| | 141 | | /// </summary> |
| | 142 | | /// <returns>A hash code for the current object.</returns> |
| | 143 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| 0 | 144 | | public override int GetHashCode() => _value.GetHashCode(); |
| | 145 | |
|
| | 146 | | /// <summary> |
| | 147 | | /// Returns a string representation of the EntityCategory. |
| | 148 | | /// </summary> |
| | 149 | | /// <returns>The EntityCategory as a string.</returns> |
| 0 | 150 | | public override string ToString() => _value; |
| | 151 | | } |
| | 152 | | } |