-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #363 from VikParuchuri/dev-mose/marker-v2
Cleanup and speed up tests
- Loading branch information
Showing
9 changed files
with
47 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
from copy import deepcopy | ||
import pytest | ||
|
||
from marker.v2.schema import BlockTypes | ||
from marker.v2.processors.equation import EquationProcessor | ||
|
||
|
||
@pytest.mark.config({"page_range": [0]}) | ||
def test_equation_processor(pdf_document, texify_model): | ||
processor = EquationProcessor(texify_model) | ||
processor(pdf_document) | ||
|
||
new_document = deepcopy(pdf_document) | ||
new_document.pages = [new_document.pages[0]] | ||
processor(new_document) | ||
|
||
for block in new_document.pages[0].children: | ||
for block in pdf_document.pages[0].children: | ||
if block.block_type == BlockTypes.Equation: | ||
assert block.latex is not None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,17 @@ | ||
import tempfile | ||
import pytest | ||
|
||
import datasets | ||
|
||
from marker.v2.providers.pdf import PdfProvider | ||
@pytest.mark.config({"page_range": [0]}) | ||
def test_pdf_provider(pdf_provider): | ||
assert len(pdf_provider) == 12 | ||
assert pdf_provider.get_image(0, 72).size == (612, 792) | ||
assert pdf_provider.get_image(0, 96).size == (816, 1056) | ||
|
||
|
||
def test_pdf_provider(): | ||
dataset = datasets.load_dataset("datalab-to/pdfs", split="train") | ||
idx = dataset['filename'].index('adversarial.pdf') | ||
|
||
temp_pdf = tempfile.NamedTemporaryFile(suffix=".pdf") | ||
temp_pdf.write(dataset['pdf'][idx]) | ||
temp_pdf.flush() | ||
|
||
provider = PdfProvider(temp_pdf.name) | ||
assert len(provider) == 12 | ||
assert provider.get_image(0, 72).size == (612, 792) | ||
assert provider.get_image(0, 96).size == (816, 1056) | ||
|
||
spans_list = provider.get_page_spans(0) | ||
spans_list = pdf_provider.get_page_spans(0) | ||
assert len(spans_list) == 93 | ||
|
||
spans = spans_list[0] | ||
assert len(spans) == 2 | ||
assert spans[0].text == "Subspace Adversarial Training" | ||
assert spans[0].font == "NimbusRomNo9L-Medi" | ||
assert spans[0].formats == ["plain"] | ||
|
||
# for line in provider.get_page_lines(0): | ||
# for span in line.spans: | ||
# print(f"{span=}") | ||
|
||
|
||
if __name__ == "__main__": | ||
test_pdf_provider() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters