-
Notifications
You must be signed in to change notification settings - Fork 0
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 #1 from dhdaines/pdfminer_compat
Implement a mostly pdfminer.six-compatible layout analyzer
- Loading branch information
Showing
10 changed files
with
1,740 additions
and
38 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[flake8] | ||
max-line-length = 88 | ||
extend-ignore = | ||
# See https://github.com/PyCQA/pycodestyle/issues/373 | ||
E203, |
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
"""Benchmark pdfminer.six against PAVÉS""" | ||
|
||
import time | ||
from typing import Union | ||
from pdfminer.high_level import extract_pages | ||
from paves.miner import extract, LAParams | ||
from pathlib import Path | ||
|
||
|
||
def benchmark_single(path: Path): | ||
for page in extract_pages(path): | ||
pass | ||
|
||
|
||
def benchmark_multi(path: Path, ncpu: Union[int, None]): | ||
for page in extract(path, laparams=LAParams(), max_workers=ncpu): | ||
pass | ||
|
||
|
||
if __name__ == "__main__": | ||
import argparse | ||
|
||
parser = argparse.ArgumentParser(description=__doc__) | ||
parser.add_argument("-n", "--ncpu", type=int, default=None) | ||
parser.add_argument("pdf", type=Path) | ||
args = parser.parse_args() | ||
|
||
start = time.time() | ||
benchmark_multi(args.pdf, args.ncpu) | ||
multi_time = time.time() - start | ||
print( | ||
"PAVÉS (%r CPUs) took %.2fs" | ||
% ( | ||
"all" if args.ncpu is None else args.ncpu, | ||
multi_time, | ||
) | ||
) | ||
|
||
start = time.time() | ||
benchmark_single(args.pdf) | ||
single_time = time.time() - start | ||
print("pdfminer.six (single) took %.2fs" % (single_time,)) |
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
Oops, something went wrong.