-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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] add bing_id property to LinkedEntity class #13446
Changes from all commits
2bbcf2b
871d70f
0541196
7b8d38f
3657828
1b37ab9
23d9197
9f26362
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
interactions: | ||
- request: | ||
body: '{"documents": [{"id": "0", "text": "Microsoft was founded by Bill Gates | ||
and Paul Allen", "language": "en"}]}' | ||
headers: | ||
Accept: | ||
- application/json, text/json | ||
Accept-Encoding: | ||
- gzip, deflate | ||
Connection: | ||
- keep-alive | ||
Content-Length: | ||
- '108' | ||
Content-Type: | ||
- application/json | ||
User-Agent: | ||
- azsdk-python-ai-textanalytics/5.0.1 Python/3.8.5 (macOS-10.13.6-x86_64-i386-64bit) | ||
method: POST | ||
uri: https://cognitiveusw2dev.azure-api.net/text/analytics/v3.1-preview.2/entities/linking?showStats=false&stringIndexType=UnicodeCodePoint | ||
response: | ||
body: | ||
string: '{"documents":[{"id":"0","entities":[{"bingId":"0d47c987-0042-5576-15e8-97af601614fa","name":"Bill | ||
Gates","matches":[{"text":"Bill Gates","offset":25,"length":10,"confidenceScore":0.52}],"language":"en","id":"Bill | ||
Gates","url":"https://en.wikipedia.org/wiki/Bill_Gates","dataSource":"Wikipedia"},{"bingId":"df2c4376-9923-6a54-893f-2ee5a5badbc7","name":"Paul | ||
Allen","matches":[{"text":"Paul Allen","offset":40,"length":10,"confidenceScore":0.54}],"language":"en","id":"Paul | ||
Allen","url":"https://en.wikipedia.org/wiki/Paul_Allen","dataSource":"Wikipedia"},{"bingId":"a093e9b9-90f5-a3d5-c4b8-5855e1b01f85","name":"Microsoft","matches":[{"text":"Microsoft","offset":0,"length":9,"confidenceScore":0.49}],"language":"en","id":"Microsoft","url":"https://en.wikipedia.org/wiki/Microsoft","dataSource":"Wikipedia"}],"warnings":[]}],"errors":[],"modelVersion":"2020-02-01"}' | ||
headers: | ||
apim-request-id: | ||
- 34b34e81-fcc2-4c1e-85b2-116f85196a4c | ||
content-type: | ||
- application/json; charset=utf-8 | ||
csp-billing-usage: | ||
- CognitiveServices.TextAnalytics.BatchScoring=1 | ||
date: | ||
- Mon, 31 Aug 2020 18:48:40 GMT | ||
strict-transport-security: | ||
- max-age=31536000; includeSubDomains; preload | ||
transfer-encoding: | ||
- chunked | ||
x-content-type-options: | ||
- nosniff | ||
x-envoy-upstream-service-time: | ||
- '27' | ||
status: | ||
code: 200 | ||
message: OK | ||
version: 1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
interactions: | ||
- request: | ||
body: '{"documents": [{"id": "0", "text": "Microsoft was founded by Bill Gates | ||
and Paul Allen", "language": "en"}]}' | ||
headers: | ||
Accept: | ||
- application/json, text/json | ||
Content-Length: | ||
- '108' | ||
Content-Type: | ||
- application/json | ||
User-Agent: | ||
- azsdk-python-ai-textanalytics/5.0.1 Python/3.8.5 (macOS-10.13.6-x86_64-i386-64bit) | ||
method: POST | ||
uri: https://cognitiveusw2dev.azure-api.net/text/analytics/v3.1-preview.2/entities/linking?showStats=false&stringIndexType=UnicodeCodePoint | ||
response: | ||
body: | ||
string: '{"documents":[{"id":"0","entities":[{"bingId":"0d47c987-0042-5576-15e8-97af601614fa","name":"Bill | ||
Gates","matches":[{"text":"Bill Gates","offset":25,"length":10,"confidenceScore":0.52}],"language":"en","id":"Bill | ||
Gates","url":"https://en.wikipedia.org/wiki/Bill_Gates","dataSource":"Wikipedia"},{"bingId":"df2c4376-9923-6a54-893f-2ee5a5badbc7","name":"Paul | ||
Allen","matches":[{"text":"Paul Allen","offset":40,"length":10,"confidenceScore":0.54}],"language":"en","id":"Paul | ||
Allen","url":"https://en.wikipedia.org/wiki/Paul_Allen","dataSource":"Wikipedia"},{"bingId":"a093e9b9-90f5-a3d5-c4b8-5855e1b01f85","name":"Microsoft","matches":[{"text":"Microsoft","offset":0,"length":9,"confidenceScore":0.49}],"language":"en","id":"Microsoft","url":"https://en.wikipedia.org/wiki/Microsoft","dataSource":"Wikipedia"}],"warnings":[]}],"errors":[],"modelVersion":"2020-02-01"}' | ||
headers: | ||
apim-request-id: 70ab796e-3da1-4a55-86b4-16c4b19a97a8 | ||
content-type: application/json; charset=utf-8 | ||
csp-billing-usage: CognitiveServices.TextAnalytics.BatchScoring=1 | ||
date: Mon, 31 Aug 2020 18:48:41 GMT | ||
strict-transport-security: max-age=31536000; includeSubDomains; preload | ||
transfer-encoding: chunked | ||
x-content-type-options: nosniff | ||
x-envoy-upstream-service-time: '26' | ||
status: | ||
code: 200 | ||
message: OK | ||
url: https://cognitiveusw2dev.azure-api.net/text/analytics/v3.1-preview.2/entities/linking?showStats=false&stringIndexType=UnicodeCodePoint | ||
version: 1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
# ------------------------------------ | ||
|
||
import os | ||
import pytest | ||
import platform | ||
import functools | ||
|
@@ -586,3 +586,17 @@ def test_string_index_type_not_fail_v3(self, client): | |
# make sure that the addition of the string_index_type kwarg for v3.1-preview.1 doesn't | ||
# cause v3.0 calls to fail | ||
client.recognize_linked_entities(["please don't fail"]) | ||
|
||
# currently only have this as playback since the dev endpoint is unreliable | ||
@pytest.mark.playback_test_only | ||
@GlobalTextAnalyticsAccountPreparer() | ||
@TextAnalyticsClientPreparer(client_kwargs={ | ||
"api_version": TextAnalyticsApiVersion.V3_1_PREVIEW_2, | ||
"text_analytics_account_key": os.environ.get('AZURE_TEXT_ANALYTICS_KEY'), | ||
"text_analytics_account": "https://cognitiveusw2dev.azure-api.net/" | ||
}) | ||
def test_bing_id(self, client): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What are u testing here? not sure I understand the purpose of the test. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this one is just to check that I've correctly set the bing ID I get back from the service. I didn't tie it to the actual bing ID returned from the service though, I'm not sure how arbitrary that number is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do u know if the bingId property will always be populated? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should be populated by the server for v3.1-preview.2 and up (it's not shown as an optional parameter). I'm confused by "worth adding a test checking that the property has content on it", I believe that's what I'm checking in this test There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be me and not knowing ton of Python, but There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. assert checks that it's not |
||
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we open an issue to remove playback marker when endpoint works reliably? (sorry for nit, I feel like these kinds of things are too easy to forget about)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
np, good point here you go bb