rawmaker 2.40.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rawmaker-2.40.3/LICENSE +21 -0
- rawmaker-2.40.3/PKG-INFO +51 -0
- rawmaker-2.40.3/README +22 -0
- rawmaker-2.40.3/letty/__init__.py +46 -0
- rawmaker-2.40.3/letty/cli.py +63 -0
- rawmaker-2.40.3/letty/optimizer.py +138 -0
- rawmaker-2.40.3/letty/quality/__init__.py +8 -0
- rawmaker-2.40.3/letty/quality/whitespace.py +50 -0
- rawmaker-2.40.3/letty/strategy.py +8 -0
- rawmaker-2.40.3/pyproject.toml +107 -0
- rawmaker-2.40.3/rawmaker/__init__.py +29 -0
- rawmaker-2.40.3/rawmaker/__main__.py +13 -0
- rawmaker-2.40.3/rawmaker/__patch__.py +36 -0
- rawmaker-2.40.3/rawmaker/cli.py +206 -0
- rawmaker-2.40.3/rawmaker/cli_automate.py +69 -0
- rawmaker-2.40.3/rawmaker/converter/__init__.py +8 -0
- rawmaker-2.40.3/rawmaker/converter/basic.py +174 -0
- rawmaker-2.40.3/rawmaker/converter/images.py +168 -0
- rawmaker-2.40.3/rawmaker/date.py +83 -0
- rawmaker-2.40.3/rawmaker/destination.py +202 -0
- rawmaker-2.40.3/rawmaker/error.py +34 -0
- rawmaker-2.40.3/rawmaker/features/__init__.py +138 -0
- rawmaker-2.40.3/rawmaker/features/annotation.py +254 -0
- rawmaker-2.40.3/rawmaker/features/border.py +172 -0
- rawmaker-2.40.3/rawmaker/features/boxes.py +153 -0
- rawmaker-2.40.3/rawmaker/features/figures.py +24 -0
- rawmaker-2.40.3/rawmaker/features/fonts.py +229 -0
- rawmaker-2.40.3/rawmaker/features/formula.py +16 -0
- rawmaker-2.40.3/rawmaker/features/horizontals.py +132 -0
- rawmaker-2.40.3/rawmaker/features/images.py +155 -0
- rawmaker-2.40.3/rawmaker/features/line.py +337 -0
- rawmaker-2.40.3/rawmaker/features/outlines.py +123 -0
- rawmaker-2.40.3/rawmaker/features/text.py +91 -0
- rawmaker-2.40.3/rawmaker/fonts/__init__.py +8 -0
- rawmaker-2.40.3/rawmaker/fonts/parser.py +354 -0
- rawmaker-2.40.3/rawmaker/images/__init__.py +8 -0
- rawmaker-2.40.3/rawmaker/images/info.py +35 -0
- rawmaker-2.40.3/rawmaker/miner/__init__.py +8 -0
- rawmaker-2.40.3/rawmaker/miner/char.py +42 -0
- rawmaker-2.40.3/rawmaker/miner/colorspace.py +75 -0
- rawmaker-2.40.3/rawmaker/miner/images.py +448 -0
- rawmaker-2.40.3/rawmaker/miner/position.py +121 -0
- rawmaker-2.40.3/rawmaker/miner/rawchar.py +207 -0
- rawmaker-2.40.3/rawmaker/miner/text.py +833 -0
- rawmaker-2.40.3/rawmaker/miner/underline.py +66 -0
- rawmaker-2.40.3/rawmaker/parameter.py +130 -0
- rawmaker-2.40.3/rawmaker/patch/__init__.py +8 -0
- rawmaker-2.40.3/rawmaker/patch/ltchar.py +79 -0
- rawmaker-2.40.3/rawmaker/reader.py +97 -0
- rawmaker-2.40.3/rawmaker/text/__init__.py +8 -0
- rawmaker-2.40.3/rawmaker/text/chars.py +24 -0
- rawmaker-2.40.3/rawmaker/text/data.py +47 -0
- rawmaker-2.40.3/rawmaker/text/superfast.py +91 -0
- rawmaker-2.40.3/rawmaker/text/wordbox.py +95 -0
- rawmaker-2.40.3/rawmaker/utils.py +44 -0
- rawmaker-2.40.3/rawmaker.egg-info/PKG-INFO +51 -0
- rawmaker-2.40.3/rawmaker.egg-info/SOURCES.txt +78 -0
- rawmaker-2.40.3/rawmaker.egg-info/dependency_links.txt +1 -0
- rawmaker-2.40.3/rawmaker.egg-info/entry_points.txt +6 -0
- rawmaker-2.40.3/rawmaker.egg-info/requires.txt +15 -0
- rawmaker-2.40.3/rawmaker.egg-info/top_level.txt +3 -0
- rawmaker-2.40.3/setup.cfg +4 -0
- rawmaker-2.40.3/spacestation/__init__.py +18 -0
- rawmaker-2.40.3/spacestation/cli.py +51 -0
- rawmaker-2.40.3/spacestation/features/__init__.py +8 -0
- rawmaker-2.40.3/spacestation/features/chardist.py +85 -0
- rawmaker-2.40.3/spacestation/features/worddist.py +57 -0
- rawmaker-2.40.3/spacestation/features/wspace.py +130 -0
- rawmaker-2.40.3/tests/test_annotation.py +76 -0
- rawmaker-2.40.3/tests/test_border.py +115 -0
- rawmaker-2.40.3/tests/test_boxes.py +141 -0
- rawmaker-2.40.3/tests/test_cli.py +112 -0
- rawmaker-2.40.3/tests/test_horizontals.py +115 -0
- rawmaker-2.40.3/tests/test_layout_extraction.py +42 -0
- rawmaker-2.40.3/tests/test_line.py +91 -0
- rawmaker-2.40.3/tests/test_master.py +34 -0
- rawmaker-2.40.3/tests/test_pdfminer.py +43 -0
- rawmaker-2.40.3/tests/test_position.py +67 -0
- rawmaker-2.40.3/tests/test_superfast.py +48 -0
- rawmaker-2.40.3/tests/test_text.py +183 -0
rawmaker-2.40.3/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Helmut Konrad Schewe
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
rawmaker-2.40.3/PKG-INFO
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: rawmaker
|
|
3
|
+
Version: 2.40.3
|
|
4
|
+
Author-email: Helmut Konrad Schewe <helmutus@outlook.com>
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/anaticulae/rawmaker
|
|
7
|
+
Project-URL: Repository, https://github.com/anaticulae/rawmaker
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
11
|
+
Requires-Python: >=3.12
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: pdfminer.six<20270000,>=20260107
|
|
15
|
+
Requires-Dist: pillow<13.0.0,>=12.2.0
|
|
16
|
+
Requires-Dist: camelot_py<2.0.0,>=1.0.9
|
|
17
|
+
Requires-Dist: utilo<3.0.0,>=2.105.0
|
|
18
|
+
Requires-Dist: configos<2.0.0,>=1.0.4
|
|
19
|
+
Requires-Dist: iamraw<5.0.0,>=4.91.0
|
|
20
|
+
Requires-Dist: protoerror<4.0.0,>=3.20.2
|
|
21
|
+
Requires-Dist: ughost<2.0.0,>=1.0.1
|
|
22
|
+
Requires-Dist: pdflog<2.0.0,>=1.0.2
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: hoverpower<2.0.0,>=1.1.0; extra == "dev"
|
|
25
|
+
Requires-Dist: jamer<2.0.0,>=1.0.1; extra == "dev"
|
|
26
|
+
Requires-Dist: utilotest<2.0.0,>=1.0.2; extra == "dev"
|
|
27
|
+
Requires-Dist: gennex<2.0.0,>=1.0.1; extra == "dev"
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
# rawmaker - convert PDF to raw data
|
|
31
|
+
|
|
32
|
+
This package extract information out of a pdf-file and write them to
|
|
33
|
+
yaml-files.
|
|
34
|
+
|
|
35
|
+
## Introduction
|
|
36
|
+
|
|
37
|
+
Supported functions:
|
|
38
|
+
|
|
39
|
+
* border: get outline of pdf content
|
|
40
|
+
* boxes: determine boxes which are constructed from lines
|
|
41
|
+
* fonts: extract used fonts of text data
|
|
42
|
+
* text: extract text blocks per page
|
|
43
|
+
* toc: determine table of content of pdf file
|
|
44
|
+
|
|
45
|
+
## Supported PDF version
|
|
46
|
+
|
|
47
|
+
PDF 1.5?
|
|
48
|
+
|
|
49
|
+
## Glossary
|
|
50
|
+
|
|
51
|
+
* TOC - table of content
|
rawmaker-2.40.3/README
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# rawmaker - convert PDF to raw data
|
|
2
|
+
|
|
3
|
+
This package extract information out of a pdf-file and write them to
|
|
4
|
+
yaml-files.
|
|
5
|
+
|
|
6
|
+
## Introduction
|
|
7
|
+
|
|
8
|
+
Supported functions:
|
|
9
|
+
|
|
10
|
+
* border: get outline of pdf content
|
|
11
|
+
* boxes: determine boxes which are constructed from lines
|
|
12
|
+
* fonts: extract used fonts of text data
|
|
13
|
+
* text: extract text blocks per page
|
|
14
|
+
* toc: determine table of content of pdf file
|
|
15
|
+
|
|
16
|
+
## Supported PDF version
|
|
17
|
+
|
|
18
|
+
PDF 1.5?
|
|
19
|
+
|
|
20
|
+
## Glossary
|
|
21
|
+
|
|
22
|
+
* TOC - table of content
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# C O P Y R I G H T
|
|
3
|
+
# -----------------------------------------------------------------------------
|
|
4
|
+
# Copyright (c) 2020-2023 by Helmut Konrad Schewe. All rights reserved.
|
|
5
|
+
# This file is property of Helmut Konrad Schewe. Any unauthorized copy,
|
|
6
|
+
# use or distribution is an offensive act against international law and may
|
|
7
|
+
# be prosecuted under federal law. Its content is company confidential.
|
|
8
|
+
# =============================================================================
|
|
9
|
+
"""Layout Estimator Tool t.y.
|
|
10
|
+
==========================
|
|
11
|
+
|
|
12
|
+
Variation Strategy
|
|
13
|
+
------------------
|
|
14
|
+
|
|
15
|
+
Static
|
|
16
|
+
~~~~~~
|
|
17
|
+
|
|
18
|
+
Dynamic
|
|
19
|
+
~~~~~~~
|
|
20
|
+
|
|
21
|
+
Result: Points
|
|
22
|
+
~~~~~~~~~~~~~~
|
|
23
|
+
|
|
24
|
+
Judger
|
|
25
|
+
-------
|
|
26
|
+
|
|
27
|
+
Optimizer
|
|
28
|
+
---------
|
|
29
|
+
|
|
30
|
+
.. code-block:: none
|
|
31
|
+
|
|
32
|
+
Optimizer -> Strategy -> Points -> Tool(Points) -> Result -> Judger(Result)
|
|
33
|
+
! ! |
|
|
34
|
+
! ! |
|
|
35
|
+
< < < < < < < < < < < < < < < < < < < < < < < < < < < < < </
|
|
36
|
+
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
import os
|
|
40
|
+
|
|
41
|
+
import rawmaker
|
|
42
|
+
|
|
43
|
+
__version__ = rawmaker.__version__
|
|
44
|
+
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
|
|
45
|
+
|
|
46
|
+
PROCESS = 'letty'
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# C O P Y R I G H T
|
|
3
|
+
# -----------------------------------------------------------------------------
|
|
4
|
+
# Copyright (c) 2019-2023 by Helmut Konrad Schewe. All rights reserved.
|
|
5
|
+
# This file is property of Helmut Konrad Schewe. Any unauthorized copy,
|
|
6
|
+
# use or distribution is an offensive act against international law and may
|
|
7
|
+
# be prosecuted under federal law. Its content is company confidential.
|
|
8
|
+
# =============================================================================
|
|
9
|
+
|
|
10
|
+
import utilo
|
|
11
|
+
import utilo.cli
|
|
12
|
+
|
|
13
|
+
import letty
|
|
14
|
+
import letty.quality.whitespace
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@utilo.saveme
|
|
18
|
+
def main() -> int:
|
|
19
|
+
parser = create_parser()
|
|
20
|
+
args = utilo.parse(parser) # pylint:disable=W0612
|
|
21
|
+
inpath, pages, whitespace = parse_args(args)
|
|
22
|
+
if whitespace:
|
|
23
|
+
white_spaces = letty.quality.whitespace.determine(inpath, pages=pages)
|
|
24
|
+
utilo.log(white_spaces)
|
|
25
|
+
return utilo.SUCCESS
|
|
26
|
+
parser.print_help()
|
|
27
|
+
return utilo.FAILURE
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def parse_args(args) -> tuple:
|
|
31
|
+
"""\
|
|
32
|
+
>>> parse_args({})
|
|
33
|
+
('...', None, False)
|
|
34
|
+
>>> parse_args(dict(pages=['3:10']))
|
|
35
|
+
('...', (3, 4, 5, 6, 7, 8, 9), False)
|
|
36
|
+
"""
|
|
37
|
+
inpath, _ = utilo.cli.sources(args, singleinput=True) # pylint:disable=W0632
|
|
38
|
+
inpath = inpath[0]
|
|
39
|
+
pages = None
|
|
40
|
+
if args.get('pages', None) is not None:
|
|
41
|
+
pages = utilo.parse_pages(','.join(args['pages']))
|
|
42
|
+
whitespace = args.get('whitespace', False)
|
|
43
|
+
result = (inpath, pages, whitespace)
|
|
44
|
+
return result
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def create_parser():
|
|
48
|
+
commands = [
|
|
49
|
+
utilo.cli.Flag('--whitespace', message='evalute number of whitespaces'),
|
|
50
|
+
]
|
|
51
|
+
parser = utilo.cli.create_parser(
|
|
52
|
+
todo=commands,
|
|
53
|
+
config=utilo.ParserConfiguration(
|
|
54
|
+
inputparameter=True,
|
|
55
|
+
outputparameter=False,
|
|
56
|
+
pages=True,
|
|
57
|
+
prefix=False,
|
|
58
|
+
verboseflag=True,
|
|
59
|
+
),
|
|
60
|
+
version=letty.__version__,
|
|
61
|
+
prog=letty.PROCESS,
|
|
62
|
+
)
|
|
63
|
+
return parser
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# C O P Y R I G H T
|
|
3
|
+
# -----------------------------------------------------------------------------
|
|
4
|
+
# Copyright (c) 2020-2023 by Helmut Konrad Schewe. All rights reserved.
|
|
5
|
+
# This file is property of Helmut Konrad Schewe. Any unauthorized copy,
|
|
6
|
+
# use or distribution is an offensive act against international law and may
|
|
7
|
+
# be prosecuted under federal law. Its content is company confidential.
|
|
8
|
+
# =============================================================================
|
|
9
|
+
|
|
10
|
+
import collections
|
|
11
|
+
import concurrent
|
|
12
|
+
import itertools
|
|
13
|
+
import math
|
|
14
|
+
import os
|
|
15
|
+
import sys
|
|
16
|
+
|
|
17
|
+
import configos
|
|
18
|
+
import utilo
|
|
19
|
+
|
|
20
|
+
import letty.quality.whitespace
|
|
21
|
+
|
|
22
|
+
OptimizerResult = collections.namedtuple('OptimizerResult', 'value, config')
|
|
23
|
+
WORKER = 12
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def run(
|
|
27
|
+
path: str,
|
|
28
|
+
pages: tuple = None,
|
|
29
|
+
boxes: int = 1,
|
|
30
|
+
chars: int = 10,
|
|
31
|
+
lines: int = 1,
|
|
32
|
+
words: int = 1,
|
|
33
|
+
*,
|
|
34
|
+
multicore: bool = True,
|
|
35
|
+
) -> OptimizerResult:
|
|
36
|
+
todo = strategy(chars=chars, words=words, lines=lines, boxes=boxes)
|
|
37
|
+
runner = threadpool if multicore else singlecore
|
|
38
|
+
result = runner(todo, path, pages)
|
|
39
|
+
judged = judge(result)
|
|
40
|
+
return judged
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def singlecore(todo: list, path: str, pages: tuple):
|
|
44
|
+
result = []
|
|
45
|
+
for config in todo:
|
|
46
|
+
quality = run_single(path, pages, config)
|
|
47
|
+
result.append(quality)
|
|
48
|
+
return result
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def threadpool(todo: list, path: str, pages: tuple):
|
|
52
|
+
result = []
|
|
53
|
+
with concurrent.futures.ThreadPoolExecutor(max_workers=WORKER) as executor:
|
|
54
|
+
futures = {
|
|
55
|
+
executor.submit(run_single, path, pages, config): config
|
|
56
|
+
for config in todo
|
|
57
|
+
}
|
|
58
|
+
for future in concurrent.futures.as_completed(futures):
|
|
59
|
+
try:
|
|
60
|
+
quality = future.result()
|
|
61
|
+
result.append(quality)
|
|
62
|
+
except Exception as error: # pylint:disable=broad-except
|
|
63
|
+
utilo.error(f'{future} failed.')
|
|
64
|
+
utilo.error(error)
|
|
65
|
+
return result
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def run_single(path: str, pages: tuple, config: dict):
|
|
69
|
+
config = ' '.join([f'--{key}={value}' for key, value in config.items()])
|
|
70
|
+
pages_raw = ','.join([str(item) for item in pages])
|
|
71
|
+
pages_raw = f'--pages={pages_raw}' if pages is not None else ''
|
|
72
|
+
with utilo.make_tmpdir(root=configos.tmp()) as cwd:
|
|
73
|
+
cmd = f'rawmaker -i {path} -o {cwd} {pages_raw} --text {config}'
|
|
74
|
+
config_outpath = os.path.join(cwd, 'layout.ini')
|
|
75
|
+
utilo.file_create(config_outpath, config)
|
|
76
|
+
completed = utilo.run(cmd, cwd=cwd)
|
|
77
|
+
if completed.returncode:
|
|
78
|
+
utilo.error(f'could not run: {cmd}')
|
|
79
|
+
utilo.error(completed.stdout)
|
|
80
|
+
utilo.error(completed.stderr)
|
|
81
|
+
sys.exit(utilo.FAILURE)
|
|
82
|
+
quality = letty.quality.whitespace.determine(cwd, pages=pages)
|
|
83
|
+
return OptimizerResult(quality, config)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def judge(result):
|
|
87
|
+
ratio, best = result[0]
|
|
88
|
+
utilo.log(result[0])
|
|
89
|
+
for item in result[1:]:
|
|
90
|
+
utilo.log(item)
|
|
91
|
+
if item[0] < ratio:
|
|
92
|
+
ratio, best = item
|
|
93
|
+
return ratio, best
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def strategy(
|
|
97
|
+
chars: int = 10,
|
|
98
|
+
words: int = 1,
|
|
99
|
+
lines: int = 1,
|
|
100
|
+
boxes: int = 1,
|
|
101
|
+
):
|
|
102
|
+
boxes_flow = ranges(0.5, 1.0, boxes)
|
|
103
|
+
char_margin = ranges(0.5, 20.0, chars)
|
|
104
|
+
line_margin = ranges(0.01, 5.0, lines)
|
|
105
|
+
word_margin = ranges(1.5, 5.0, words)
|
|
106
|
+
result = []
|
|
107
|
+
for char, word, box, line, in itertools.product(
|
|
108
|
+
char_margin,
|
|
109
|
+
word_margin,
|
|
110
|
+
boxes_flow,
|
|
111
|
+
line_margin,
|
|
112
|
+
):
|
|
113
|
+
result.append({
|
|
114
|
+
'boxes_flow': box,
|
|
115
|
+
'char_margin': char,
|
|
116
|
+
'word_margin': word,
|
|
117
|
+
'line_margin': line,
|
|
118
|
+
})
|
|
119
|
+
return result
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
# TODO: REPLACE WITH utilo CODE
|
|
123
|
+
def ranges(mini: float, maxi: float, steps: int = 15):
|
|
124
|
+
"""Compute parameter.
|
|
125
|
+
|
|
126
|
+
>>> utilo.roundme(ranges(0.1, 100, steps=10))
|
|
127
|
+
[0.1, 0.12, 0.18, 0.34, 0.76, 1.92, 5.06, 13.61, 36.84, 99.99]
|
|
128
|
+
>>> utilo.roundme(ranges(0.1, 20, steps=5))
|
|
129
|
+
[0.1, 0.73, 2.43, 7.06, 19.64]
|
|
130
|
+
"""
|
|
131
|
+
func = math.exp
|
|
132
|
+
maxed = func(steps - 1) / (maxi - mini)
|
|
133
|
+
result = []
|
|
134
|
+
for index in range(steps):
|
|
135
|
+
value = mini + (math.exp(index) - 1) / maxed
|
|
136
|
+
value = utilo.roundme(value, digits=5) # pylint:disable=R0204
|
|
137
|
+
result.append(value)
|
|
138
|
+
return result
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# C O P Y R I G H T
|
|
3
|
+
# -----------------------------------------------------------------------------
|
|
4
|
+
# Copyright (c) 2020-2023 by Helmut Konrad Schewe. All rights reserved.
|
|
5
|
+
# This file is property of Helmut Konrad Schewe. Any unauthorized copy,
|
|
6
|
+
# use or distribution is an offensive act against international law and may
|
|
7
|
+
# be prosecuted under federal law. Its content is company confidential.
|
|
8
|
+
# =============================================================================
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# C O P Y R I G H T
|
|
3
|
+
# -----------------------------------------------------------------------------
|
|
4
|
+
# Copyright (c) 2020-2023 by Helmut Konrad Schewe. All rights reserved.
|
|
5
|
+
# This file is property of Helmut Konrad Schewe. Any unauthorized copy,
|
|
6
|
+
# use or distribution is an offensive act against international law and may
|
|
7
|
+
# be prosecuted under federal law. Its content is company confidential.
|
|
8
|
+
# =============================================================================
|
|
9
|
+
|
|
10
|
+
import collections
|
|
11
|
+
import re
|
|
12
|
+
|
|
13
|
+
import serializeraw
|
|
14
|
+
import utilo
|
|
15
|
+
|
|
16
|
+
PageWhitespace = collections.namedtuple('PageWhitespaces', 'page, content')
|
|
17
|
+
PageWhitespaces = list[PageWhitespace]
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def determine(path: str, pages: tuple = None) -> PageWhitespaces:
|
|
21
|
+
data = serializeraw.ptn_frompath(
|
|
22
|
+
path,
|
|
23
|
+
pages=pages,
|
|
24
|
+
logging=False,
|
|
25
|
+
)
|
|
26
|
+
analyzed = [analyse_page(item) for item in data]
|
|
27
|
+
result = quality(analyzed)
|
|
28
|
+
return result
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
INNER_WHITESPACE = r'\b\s{2,}\b'
|
|
32
|
+
CONTENT_ENDING = r'\b\n'
|
|
33
|
+
|
|
34
|
+
COMMON = '(' + INNER_WHITESPACE + '|' + CONTENT_ENDING + ')'
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def analyse_page(page) -> PageWhitespace:
|
|
38
|
+
counter = collections.Counter()
|
|
39
|
+
for line in page:
|
|
40
|
+
text = line.text
|
|
41
|
+
for item in re.finditer(COMMON, text):
|
|
42
|
+
counter[len(utilo.extract_match(item))] += 1
|
|
43
|
+
counter[2] += len(page)
|
|
44
|
+
result = PageWhitespace(page=page.page, content=counter.most_common())
|
|
45
|
+
return result
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def quality(pages) -> int:
|
|
49
|
+
result = sum([page.content[0][1] for page in pages if page.content], 0)
|
|
50
|
+
return result
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# C O P Y R I G H T
|
|
3
|
+
# -----------------------------------------------------------------------------
|
|
4
|
+
# Copyright (c) 2020-2023 by Helmut Konrad Schewe. All rights reserved.
|
|
5
|
+
# This file is property of Helmut Konrad Schewe. Any unauthorized copy,
|
|
6
|
+
# use or distribution is an offensive act against international law and may
|
|
7
|
+
# be prosecuted under federal law. Its content is company confidential.
|
|
8
|
+
# =============================================================================
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "rawmaker"
|
|
3
|
+
version = "2.40.3"
|
|
4
|
+
description = ""
|
|
5
|
+
requires-python = ">=3.12"
|
|
6
|
+
authors = [
|
|
7
|
+
{ name = "Helmut Konrad Schewe", email = "helmutus@outlook.com" },
|
|
8
|
+
]
|
|
9
|
+
dependencies = [
|
|
10
|
+
"pdfminer.six>=20260107,<20270000",
|
|
11
|
+
"pillow>=12.2.0,<13.0.0",
|
|
12
|
+
"camelot_py>=1.0.9,<2.0.0",
|
|
13
|
+
"utilo>=2.105.0,<3.0.0",
|
|
14
|
+
"configos>=1.0.4,<2.0.0",
|
|
15
|
+
"iamraw>=4.91.0,<5.0.0",
|
|
16
|
+
"protoerror>=3.20.2,<4.0.0",
|
|
17
|
+
"ughost>=1.0.1,<2.0.0",
|
|
18
|
+
"pdflog>=1.0.2,<2.0.0",
|
|
19
|
+
]
|
|
20
|
+
keywords = []
|
|
21
|
+
classifiers = [
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Programming Language :: Python :: 3.13",
|
|
24
|
+
"Programming Language :: Python :: 3.14",
|
|
25
|
+
]
|
|
26
|
+
license = "MIT"
|
|
27
|
+
license-files = [
|
|
28
|
+
"LICENSE",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[project.readme]
|
|
32
|
+
file = "README"
|
|
33
|
+
content-type = "text/markdown"
|
|
34
|
+
|
|
35
|
+
[project.optional-dependencies]
|
|
36
|
+
dev = [
|
|
37
|
+
"hoverpower>=1.1.0,<2.0.0",
|
|
38
|
+
"jamer>=1.0.1,<2.0.0",
|
|
39
|
+
"utilotest>=1.0.2,<2.0.0",
|
|
40
|
+
"gennex>=1.0.1,<2.0.0",
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
[project.urls]
|
|
44
|
+
Homepage = "https://github.com/anaticulae/rawmaker"
|
|
45
|
+
Repository = "https://github.com/anaticulae/rawmaker"
|
|
46
|
+
|
|
47
|
+
[project.scripts]
|
|
48
|
+
letty = "letty.cli:main"
|
|
49
|
+
rawmaker = "rawmaker.cli:main"
|
|
50
|
+
rawmaker_automate = "rawmaker.cli_automate:main"
|
|
51
|
+
rawmaker_cleanup = "cleanup.cli:main"
|
|
52
|
+
spacestation = "spacestation.cli:main"
|
|
53
|
+
|
|
54
|
+
[build-system]
|
|
55
|
+
requires = [
|
|
56
|
+
"setuptools>=82.0.1",
|
|
57
|
+
"wheel>=0.47.0",
|
|
58
|
+
]
|
|
59
|
+
build-backend = "setuptools.build_meta"
|
|
60
|
+
|
|
61
|
+
[tool.semantic_release]
|
|
62
|
+
version_toml = [
|
|
63
|
+
"pyproject.toml:project.version",
|
|
64
|
+
]
|
|
65
|
+
|
|
66
|
+
[tool.semantic_release.changelog]
|
|
67
|
+
mode = "init"
|
|
68
|
+
output_format = "md"
|
|
69
|
+
|
|
70
|
+
[tool.semantic_release.changelog.default_templates]
|
|
71
|
+
changelog_file = "CHANGELOG"
|
|
72
|
+
|
|
73
|
+
[tool.semantic_release.commit_parser_options]
|
|
74
|
+
patch_tags = [
|
|
75
|
+
"fix",
|
|
76
|
+
"perf",
|
|
77
|
+
"build",
|
|
78
|
+
"chore",
|
|
79
|
+
"ci",
|
|
80
|
+
"docs",
|
|
81
|
+
"style",
|
|
82
|
+
"refactor",
|
|
83
|
+
"test",
|
|
84
|
+
"deps",
|
|
85
|
+
]
|
|
86
|
+
|
|
87
|
+
[tool.setuptools.packages.find]
|
|
88
|
+
where = [
|
|
89
|
+
".",
|
|
90
|
+
]
|
|
91
|
+
include = [
|
|
92
|
+
"letty",
|
|
93
|
+
"letty.quality",
|
|
94
|
+
"rawmaker",
|
|
95
|
+
"rawmaker.converter",
|
|
96
|
+
"rawmaker.features",
|
|
97
|
+
"rawmaker.fonts",
|
|
98
|
+
"rawmaker.images",
|
|
99
|
+
"rawmaker.miner",
|
|
100
|
+
"rawmaker.patch",
|
|
101
|
+
"rawmaker.text",
|
|
102
|
+
"spacestation",
|
|
103
|
+
"spacestation.features",
|
|
104
|
+
]
|
|
105
|
+
exclude = [
|
|
106
|
+
"tests*",
|
|
107
|
+
]
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#==============================================================================
|
|
2
|
+
# C O P Y R I G H T
|
|
3
|
+
#------------------------------------------------------------------------------
|
|
4
|
+
# Copyright (c) 2019-2023 by Helmut Konrad Schewe. All rights reserved.
|
|
5
|
+
# This file is property of Helmut Konrad Schewe. Any unauthorized copy,
|
|
6
|
+
# use or distribution is an offensive act against international law and may
|
|
7
|
+
# be prosecuted under federal law. Its content is company confidential.
|
|
8
|
+
#==============================================================================
|
|
9
|
+
"""The rawmaker converts pdf to kiwi-internal project format
|
|
10
|
+
|
|
11
|
+
Hint: Pay attention to the public API on this file!
|
|
12
|
+
Breaking changes are breaking!
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
import os
|
|
16
|
+
|
|
17
|
+
import configos
|
|
18
|
+
|
|
19
|
+
# pylint:disable=W0613
|
|
20
|
+
import rawmaker.__patch__
|
|
21
|
+
from rawmaker.parameter import LAYOUT
|
|
22
|
+
from rawmaker.parameter import ONELINE
|
|
23
|
+
|
|
24
|
+
__version__ = '2.40.2'
|
|
25
|
+
|
|
26
|
+
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
|
|
27
|
+
PROCESS = 'rawmaker'
|
|
28
|
+
|
|
29
|
+
configos.cloud_lookup(PROCESS)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#==============================================================================
|
|
2
|
+
# C O P Y R I G H T
|
|
3
|
+
#------------------------------------------------------------------------------
|
|
4
|
+
# Copyright (c) 2019-2023 by Helmut Konrad Schewe. All rights reserved.
|
|
5
|
+
# This file is property of Helmut Konrad Schewe. Any unauthorized copy,
|
|
6
|
+
# use or distribution is an offensive act against international law and may
|
|
7
|
+
# be prosecuted under federal law. Its content is company confidential.
|
|
8
|
+
#==============================================================================
|
|
9
|
+
|
|
10
|
+
from rawmaker.cli import main
|
|
11
|
+
|
|
12
|
+
if __name__ == "__main__":
|
|
13
|
+
main()
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# C O P Y R I G H T
|
|
3
|
+
# -----------------------------------------------------------------------------
|
|
4
|
+
# Copyright (c) 2020-2023 by Helmut Konrad Schewe. All rights reserved.
|
|
5
|
+
# This file is property of Helmut Konrad Schewe. Any unauthorized copy,
|
|
6
|
+
# use or distribution is an offensive act against international law and may
|
|
7
|
+
# be prosecuted under federal law. Its content is company confidential.
|
|
8
|
+
# =============================================================================
|
|
9
|
+
|
|
10
|
+
import sys
|
|
11
|
+
|
|
12
|
+
import pdfminer.glyphlist
|
|
13
|
+
import pdfminer.pdfpage
|
|
14
|
+
import utilo
|
|
15
|
+
|
|
16
|
+
before = pdfminer.pdfpage.PDFPage.create_pages # pylint:disable=C0103
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def create_pages(document):
|
|
20
|
+
try:
|
|
21
|
+
yield from before(document)
|
|
22
|
+
except IndexError:
|
|
23
|
+
utilo.error('pdfminer parsing error: IndexError')
|
|
24
|
+
sys.exit(1)
|
|
25
|
+
except RecursionError:
|
|
26
|
+
utilo.error('pdfminer parsing error: RecursionError')
|
|
27
|
+
sys.exit(1)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
pdfminer.pdfpage.PDFPage.create_pages = create_pages
|
|
31
|
+
|
|
32
|
+
# TODO HACK HACK HACK
|
|
33
|
+
# bachelor090 REGISTERED SIGN
|
|
34
|
+
# circlecopyrt
|
|
35
|
+
# pdfminer.glyphlist.glyphname2unicode['circlecopyrt'] = '\u25CF'
|
|
36
|
+
pdfminer.glyphlist.glyphname2unicode['circlecopyrt'] = '\r'
|