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
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ jobs:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-docs-${{ hashFiles('setup.cfg') }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/license.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ jobs:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-lic-${{ hashFiles('**/setup.cfg') }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ jobs:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-dev-${{ hashFiles('setup.cfg') }}
Expand All @@ -36,7 +36,7 @@ jobs:
pip install -e .[dev]

- name: Cache pre-commit
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: ${{ runner.os }}-prec-${{ hashFiles('.pre-commit-config.yaml') }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ jobs:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-build-${{ hashFiles('setup.cfg') }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-code-samples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ jobs:
submodules: recursive

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-samples-${{ hashFiles('**/setup.cfg') }}
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/test-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ on:
pull_request:
workflow_run:
workflows: ["Test Code Samples"]
branches:
- '*'
types:
- completed

Expand All @@ -32,12 +30,12 @@ jobs:
submodules: recursive

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-dev-${{ hashFiles('setup.cfg') }}
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/test-regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ on:
pull_request:
workflow_run:
workflows: ["Test Code Samples"]
branches:
- '*'
types:
- completed

Expand All @@ -32,12 +30,12 @@ jobs:
submodules: recursive

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-dev-${{ hashFiles('setup.cfg') }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ jobs:
submodules: recursive

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-dev-${{ hashFiles('setup.cfg') }}
Expand Down
10 changes: 9 additions & 1 deletion docs/extras/guide/generated_v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,20 @@ Generated builds always have access to at least two attributes:

## Fields

**fields** (`Dict[str`: `List[Union[`[GeneratedListField](#generated-list-field)[GeneratedObjectField](#generated-object-field), `(#stringfield)[StringField]]]`):
**fields** (`Dict[str`: `List[Union[`[GeneratedListField](#generated-list-field), [GeneratedObjectField](#generated-object-field), `(#stringfield)[StringField]]]`):

```python
print(str(result.document.inference.prediction.fields["my-field"]))
```

### Nested fields

If your field `my-field` is a `GeneratedObjectField`, you can access its individual properties using the following syntax:

```python
print(str(result.document.inference.prediction.fields["my-field"].my_attribute))
```

# Questions?

[Join our Slack](https://join.slack.com/t/mindee-community/shared_invite/zt-2d0ds7dtz-DPAF81ZqTy20chsYpQBW5g)
2 changes: 1 addition & 1 deletion examples/auto_invoice_splitter_extraction.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os

from mindee import Client
from mindee.extraction.common.pdf_extractor import PdfExtractor
from mindee.extraction.pdf_extractor import PdfExtractor
from mindee.input import PathInput
from mindee.product import InvoiceSplitterV1, InvoiceV4

Expand Down
2 changes: 1 addition & 1 deletion mindee/product/generated/generated_v1_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ def __init__(self, raw_prediction: StringDict) -> None:
):
field_contents_str["value"] = str(
field_contents_str["value"]
) # str cohersion for numbers
) # str coercion for numbers
self.fields[field_name] = StringField(field_contents_str)
Empty file added tests/api/__init__.py
Empty file.
3 changes: 2 additions & 1 deletion tests/extraction/test_invoice_splitter_auto_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from mindee.product import InvoiceSplitterV1, InvoiceV4
from tests.product import get_id, get_version
from tests.test_inputs import PRODUCT_DATA_DIR
from tests.utils import levenshtein_ratio


@pytest.fixture
Expand Down Expand Up @@ -52,4 +53,4 @@ def test_pdf_should_extract_invoices_strict():
PRODUCT_DATA_DIR / "invoices" / "response_v4" / "summary_full_invoice_p1.rst",
invoice_0.document,
)
assert test_string_rst_invoice_0 == str(invoice_0.document)
assert levenshtein_ratio(test_string_rst_invoice_0, str(invoice_0.document)) >= 0.97
Empty file added tests/input/__init__.py
Empty file.
File renamed without changes.
Empty file added tests/mindee_http/__init__.py
Empty file.
11 changes: 11 additions & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from difflib import SequenceMatcher
from pathlib import Path

from mindee.mindee_http.mindee_api import (
Expand Down Expand Up @@ -25,3 +26,13 @@ def dummy_envvars(monkeypatch) -> None:


EXTRAS_DIR = Path("./tests/data/extras/")


def levenshtein_ratio(ref_str: str, target_str: str) -> float:
"""
Calculates the Levenshtein ratio between two strings.
:param ref_str: Reference string.
:param target_str: Target String.
:return: Ratio between the two strings
"""
return SequenceMatcher(None, ref_str, target_str).ratio()