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 analytics] bing_id -> bing_entity_search_api_id #13491

Merged
merged 1 commit into from
Sep 1, 2020
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
2 changes: 1 addition & 1 deletion sdk/textanalytics/azure-ai-textanalytics/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pass in `v3.0` to the kwarg `api_version` when creating your TextAnalyticsClient
- `offset` is the offset of the text from the start of the document
- We now have added support for opinion mining. To use this feature, you need to make sure you are using the service's
v3.1-preview.1 API. To get this support pass `show_opinion_mining` as True when calling the `analyze_sentiment` endpoint
- Add property `bing_id` to the `LinkedEntity` class. This property is only available for v3.1-preview.2 and up, and it is to be
- Add property `bing_entity_search_api_id` to the `LinkedEntity` class. This property is only available for v3.1-preview.2 and up, and it is to be
used in conjunction with the Bing Entity Search API to fetch additional relevant information about the returned entity.

## 5.0.0 (2020-07-27)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -630,11 +630,11 @@ class LinkedEntity(DictMixin):
:ivar data_source: Data source used to extract entity linking,
such as Wiki/Bing etc.
:vartype data_source: str
:ivar str bing_id: Bing unique identifier of the recognized entity. Use in conjunction
:ivar str bing_entity_search_api_id: Bing unique identifier of the recognized entity. Use in conjunction
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

late to the party, but consider modifying the docstirng to Bing Entity Search unique identifier ...

with the Bing Entity Search SDK to fetch additional relevant information. Only
available for API version v3.1-preview.2 and up.
.. versionadded:: v3.1-preview.2
The *bing_id* property.
The *bing_entity_search_api_id* property.
"""

def __init__(self, **kwargs):
Expand All @@ -644,31 +644,31 @@ def __init__(self, **kwargs):
self.data_source_entity_id = kwargs.get("data_source_entity_id", None)
self.url = kwargs.get("url", None)
self.data_source = kwargs.get("data_source", None)
self.bing_id = kwargs.get("bing_id", None)
self.bing_entity_search_api_id = kwargs.get("bing_entity_search_api_id", None)

@classmethod
def _from_generated(cls, entity):
bing_id = entity.bing_id if hasattr(entity, "bing_id") else None
bing_entity_search_api_id = entity.bing_id if hasattr(entity, "bing_id") else None
return cls(
name=entity.name,
matches=[LinkedEntityMatch._from_generated(e) for e in entity.matches], # pylint: disable=protected-access
language=entity.language,
data_source_entity_id=entity.id,
url=entity.url,
data_source=entity.data_source,
bing_id=bing_id,
bing_entity_search_api_id=bing_entity_search_api_id,
)

def __repr__(self):
return "LinkedEntity(name={}, matches={}, language={}, data_source_entity_id={}, url={}, " \
"data_source={}, bing_id={})".format(
"data_source={}, bing_entity_search_api_id={})".format(
self.name,
repr(self.matches),
self.language,
self.data_source_entity_id,
self.url,
self.data_source,
self.bing_id,
self.bing_entity_search_api_id,
)[:1024]


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -599,4 +599,4 @@ def test_bing_id(self, client):
result = client.recognize_linked_entities(["Microsoft was founded by Bill Gates and Paul Allen"])
for doc in result:
for entity in doc.entities:
assert entity.bing_id # this checks if it's None and if it's empty
assert entity.bing_entity_search_api_id # this checks if it's None and if it's empty
Original file line number Diff line number Diff line change
Expand Up @@ -635,4 +635,4 @@ async def test_bing_id(self, client):
result = await client.recognize_linked_entities(["Microsoft was founded by Bill Gates and Paul Allen"])
for doc in result:
for entity in doc.entities:
assert entity.bing_id # this checks if it's None and if it's empty
assert entity.bing_entity_search_api_id # this checks if it's None and if it's empty
4 changes: 2 additions & 2 deletions sdk/textanalytics/azure-ai-textanalytics/tests/test_repr.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ def linked_entity(linked_entity_match):
data_source_entity_id="Bill Gates",
url="https://en.wikipedia.org/wiki/Bill_Gates",
data_source="wikipedia",
bing_id="12345678"
bing_entity_search_api_id="12345678"
)
model_repr = (
"LinkedEntity(name=Bill Gates, matches=[{}, {}], "\
"language=English, data_source_entity_id=Bill Gates, "\
"url=https://en.wikipedia.org/wiki/Bill_Gates, data_source=wikipedia, bing_id=12345678)".format(
"url=https://en.wikipedia.org/wiki/Bill_Gates, data_source=wikipedia, bing_entity_search_api_id=12345678)".format(
linked_entity_match[1], linked_entity_match[1]
)
)
Expand Down