Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class FormRecognizerClient(object):

.. admonition:: Example:

.. literalinclude:: ../samples/sample_get_manual_validation_info.py
.. literalinclude:: ../samples/sample_get_bounding_boxes.py
:start-after: [START create_form_recognizer_client]
:end-before: [END create_form_recognizer_client]
:language: python
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class FormTrainingClient(object):

.. admonition:: Example:

.. literalinclude:: ../samples/sample_train_labeled_model.py
.. literalinclude:: ../samples/sample_train_model_with_labels.py
:start-after: [START create_form_training_client]
:end-before: [END create_form_training_client]
:language: python
Expand Down Expand Up @@ -91,7 +91,7 @@ def begin_train_model(self, training_files, use_labels=False, **kwargs):

.. admonition:: Example:

.. literalinclude:: ../samples/sample_train_unlabeled_model.py
.. literalinclude:: ../samples/sample_train_model_without_labels.py
:start-after: [START training]
:end-before: [END training]
:language: python
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Licensed under the MIT License.
# ------------------------------------

import six
from azure.core.exceptions import (
ResourceNotFoundError,
ResourceExistsError,
Expand All @@ -25,8 +26,19 @@ def get_content_type(form):
"""Source: https://en.wikipedia.org/wiki/Magic_number_(programming)#Magic_numbers_in_files
"""

if hasattr(form, "read"):
form = form.read(4)
if isinstance(form, six.binary_type):
return check_beginning_bytes(form)

if hasattr(form, "read") and hasattr(form, "seek"):
beginning_bytes = form.read(4)
form.seek(0)
return check_beginning_bytes(beginning_bytes)

raise ValueError("Content type could not be auto-detected because the stream was not readable/seekable. "
"Please pass the content_type keyword argument.")


def check_beginning_bytes(form):

if len(form) > 3:
if form[:4] == b"\x25\x50\x44\x46":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,12 @@ class FormPage(object):
:ivar list[~azure.ai.formrecognizer.FormTable] tables:
A list of extracted tables contained in a page.
:ivar list[~azure.ai.formrecognizer.FormLine] lines:
When `include_text_content` is set to true, a list of recognized text lines. The
maximum number of lines returned is 300 per page. The lines are sorted top to bottom, left to
right, although in certain cases proximity is treated with higher priority. As the sorting
order depends on the detected text, it may change across images and OCR version updates. Thus,
business logic should be built upon the actual line location instead of order.
When `include_text_content` is set to true, a list of recognized text lines is returned.
For calls to recognize content, this list is always populated. The maximum number of lines
returned is 300 per page. The lines are sorted top to bottom, left to right, although in
certain cases proximity is treated with higher priority. As the sorting order depends on
the detected text, it may change across images and OCR version updates. Thus, business
logic should be built upon the actual line location instead of order.
"""

def __init__(self, **kwargs):
Expand Down Expand Up @@ -513,7 +514,8 @@ class FormTableCell(FormContent):
:ivar int page_number: The 1-based page number in the input document.
:ivar text_content:
When `include_text_content` is set to true, a list of references to the text
elements constituting this cell is returned.
elements constituting this cell is returned. For calls to recognize content,
this list is always populated.
:vartype text_content: list[~azure.ai.formrecognizer.FormWord, ~azure.ai.formrecognizer.FormLine]
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class FormRecognizerClient(object):

.. admonition:: Example:

.. literalinclude:: ../samples/async_samples/sample_get_manual_validation_info_async.py
.. literalinclude:: ../samples/async_samples/sample_get_bounding_boxes_async.py
:start-after: [START create_form_recognizer_client_async]
:end-before: [END create_form_recognizer_client_async]
:language: python
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class FormTrainingClient(object):

.. admonition:: Example:

.. literalinclude:: ../samples/async_samples/sample_train_labeled_model_async.py
.. literalinclude:: ../samples/async_samples/sample_train_model_with_labels_async.py
:start-after: [START create_form_training_client_async]
:end-before: [END create_form_training_client_async]
:language: python
Expand Down Expand Up @@ -97,7 +97,7 @@ async def train_model(

.. admonition:: Example:

.. literalinclude:: ../samples/async_samples/sample_train_unlabeled_model_async.py
.. literalinclude:: ../samples/async_samples/sample_train_model_without_labels_async.py
:start-after: [START training_async]
:end-before: [END training_async]
:language: python
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def recognize_content(self):
cell.text,
format_bounding_box(cell.bounding_box)
))
# [END recognize_content_async]
# [END recognize_content]
for line_idx, line in enumerate(content.lines):
print("Line # {} has text '{}' within bounding box '{}'".format(
line_idx,
Expand Down
Loading