Azure / azure-sdk-for-python

This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.
MIT License
4.55k stars 2.77k forks source link

[formrecognizer] Documentation implies Form Recognizer will return Key-Value Pairs that may lack keys and/or values #36892

Open edrogers opened 1 month ago

edrogers commented 1 month ago

The documentation for Azure Form Recognizer includes example snippets on usage. (Many thanks to @kristapratico, @catalinaperalta, and @maririos for working to add those in #20996 and #29193!)

In those snippets is a pair of if-statements: if kv_pair.key: here and if kv_pair.value here. Is there any chance that either of kv_pair.key or kv_pair.value will come back "falsy" or missing?

If so, is there somewhere in the documentation that could help me understand the usage of key-value pairs that are missing either the key, the value, or both?

(On the other hand, if they'll never be missing, could those conditionals be removed?)

github-actions[bot] commented 1 month ago

Thank you for your feedback. Tagging and routing to the team member best able to assist.

YalinLi0312 commented 1 month ago

@edrogers Thanks for your contact! This is the documentation of DocumentKeyValuePair class: https://learn.microsoft.com/en-us/python/api/azure-ai-formrecognizer/azure.ai.formrecognizer.documentkeyvaluepair?view=azure-python#attributes key and confidence properties are required, value could be None.

github-actions[bot] commented 1 month ago

Hi @edrogers. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

edrogers commented 1 month ago

Ah, thanks for this clarification & link to the documentation @YalinLi0312!

So, this means the first if-statement is unnecessary (since key is a required property), but the second if-statement is important since kv_pair.value may be None. Is my understanding correct?

If so, would you be willing to review/accept a pull request that removes the first if-statement?

YalinLi0312 commented 1 week ago

Hi @edrogers , sure thing, we would review your PR and welcome any contributions. Thanks in advance! One more thing you may don't know for this sample - you can update the sample_analyze_general_documents.py and use the snippet in README.md.

github-actions[bot] commented 1 week ago

Hi @edrogers. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

github-actions[bot] commented 4 days ago

Hi @edrogers, we're sending this friendly reminder because we haven't heard back from you in 7 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!