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

[formrecognizer] Rename DocumentElement to DocumentContentElement #21323

Merged
merged 2 commits into from
Oct 22, 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
1 change: 1 addition & 0 deletions sdk/formrecognizer/azure-ai-formrecognizer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Features Added

### Breaking Changes
- Renamed `DocumentElement` to `DocumentContentElement`.
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm open if there are better names, but I wanted to get this updated since it seems most likely that it wont stay as a general DocumentElement

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense to me


### Bugs Fixed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
AnalyzeResult,
AnalyzedDocument,
BoundingRegion,
DocumentElement,
DocumentContentElement,
DocumentEntity,
DocumentField,
DocumentKeyValuePair,
Expand Down Expand Up @@ -100,7 +100,7 @@
"AnalyzeResult",
"AnalyzedDocument",
"BoundingRegion",
"DocumentElement",
"DocumentContentElement",
"DocumentEntity",
"DocumentField",
"DocumentKeyValueElement",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2125,8 +2125,8 @@ def from_dict(cls, data):
)


class DocumentElement(object):
"""A DocumentElement.
class DocumentContentElement(object):
"""A DocumentContentElement.

:ivar content: Text content of the word.
:vartype content: str
Expand All @@ -2143,13 +2143,13 @@ def __init__(self, **kwargs):
self.kind = kwargs.get("kind", None)

def __repr__(self):
return "DocumentElement(content={}, bounding_box={}, kind={})".format(
return "DocumentContentElement(content={}, bounding_box={}, kind={})".format(
self.content, self.bounding_box, self.kind
)

def to_dict(self):
# type: () -> dict
"""Returns a dict representation of DocumentElement.
"""Returns a dict representation of DocumentContentElement.

:return: dict
:rtype: dict
Expand All @@ -2164,12 +2164,12 @@ def to_dict(self):

@classmethod
def from_dict(cls, data):
# type: (dict) -> DocumentElement
"""Converts a dict in the shape of a DocumentElement to the model itself.
# type: (dict) -> DocumentContentElement
"""Converts a dict in the shape of a DocumentContentElement to the model itself.

:param dict data: A dictionary in the shape of DocumentElement.
:return: DocumentElement
:rtype: DocumentElement
:param dict data: A dictionary in the shape of DocumentContentElement.
:return: DocumentContentElement
:rtype: DocumentContentElement
"""
return cls(
content=data.get("content", None),
Expand Down Expand Up @@ -2844,7 +2844,7 @@ def from_dict(cls, data):
)


class DocumentSelectionMark(DocumentElement):
class DocumentSelectionMark(DocumentContentElement):
Copy link
Member

Choose a reason for hiding this comment

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

Just wanted to make sure with .NET here if we do have an inheritance currently built-in between these elements (DocumentWord, DocumentSelectionMark)?
@maririos?

Copy link
Member

Choose a reason for hiding this comment

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

We currently don't https://apiview.dev/Assemblies/Review/cf2c57b3d4c44ef08c2e8284f7441a2d#Azure.AI.FormRecognizer.DocumentAnalysis.DocumentWord

I have to admit that we haven't spent time looking into this with a design perspective, so the reason why it currently isn't is that there is no explicit dependency in the swagger

"""A selection mark object representing check boxes, radio buttons, and other elements indicating a selection.

:ivar state: State of the selection mark. Possible values include: "selected",
Expand Down Expand Up @@ -3408,7 +3408,7 @@ def _from_generated(cls, op, api_version): # pylint: disable=arguments-differ
)


class DocumentWord(DocumentElement):
class DocumentWord(DocumentContentElement):
"""A word object consisting of a contiguous sequence of characters. For non-space delimited languages,
such as Chinese, Japanese, and Korean, each character is represented as its own word.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ def bounding_region(bounding_box):

@pytest.fixture
def document_element(bounding_box):
model = _models.DocumentElement(content="content", kind="word", bounding_box=bounding_box[0])
model_repr = "DocumentElement(content=content, bounding_box={}, kind=word)".format(bounding_box[1])
model = _models.DocumentContentElement(content="content", kind="word", bounding_box=bounding_box[0])
model_repr = "DocumentContentElement(content=content, bounding_box={}, kind=word)".format(bounding_box[1])
assert repr(model) == model_repr
return model, model_repr

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_document_span_to_dict(self):
assert d == final

def test_document_element_to_dict(self):
model = _models.DocumentElement(
model = _models.DocumentContentElement(
content="sample",
bounding_box=[
_models.Point(1427.0, 1669.0),
Expand Down