-
Notifications
You must be signed in to change notification settings - Fork 291
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Strategy heuristic test & fix (#203)
* fix: add parse tests for every supported extensions * add: each parser has supported FileExtensions * fix: ValueError for unsupported extensions * feat: add heuristic test * fix: strategy * add: native tests * add: ReadMe mention SAFEDOCS as a source
- Loading branch information
Showing
16 changed files
with
24 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# MegaParse CORE | ||
|
||
- Core package of megaparse | ||
|
||
> **Note:** The test files in `tests/pdf/ocr` and `tests/pdf/native` come from SAFEDOCS (CC-MAIN-2021-31-PDF-UNTRUNCATED). You can find more information [here](https://digitalcorpora.org/corpora/file-corpora/cc-main-2021-31-pdf-untruncated/). |
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,10 +1,20 @@ | ||
import os | ||
|
||
import pytest | ||
from megaparse.parser.strategy import determine_strategy | ||
from megaparse_sdk.schema.parser_config import StrategyEnum | ||
|
||
ocr_pdfs = os.listdir("./tests/pdf/ocr") | ||
native_pdfs = os.listdir("./tests/pdf/native") | ||
|
||
|
||
def test_strategy_all(): | ||
pdf = "./tests/pdf/sample_pdf.pdf" | ||
strategy = determine_strategy( | ||
pdf, threshold_pages_ocr=0.2, threshold_image_page=0.3 | ||
) | ||
@pytest.mark.parametrize("hi_res_pdf", ocr_pdfs) | ||
def test_hi_res_strategy(hi_res_pdf): | ||
strategy = determine_strategy(f"./tests/pdf/ocr/{hi_res_pdf}") | ||
assert strategy == StrategyEnum.HI_RES | ||
|
||
|
||
@pytest.mark.parametrize("native_pdf", native_pdfs) | ||
def test_fast_strategy(native_pdf): | ||
strategy = determine_strategy(f"./tests/pdf/native/{native_pdf}") | ||
assert strategy == StrategyEnum.FAST |
Binary file not shown.