bibliographia 1.0.0__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.
- bibliographia-1.0.0/LICENSE +21 -0
- bibliographia-1.0.0/PKG-INFO +30 -0
- bibliographia-1.0.0/README +1 -0
- bibliographia-1.0.0/bibliographia.egg-info/PKG-INFO +30 -0
- bibliographia-1.0.0/bibliographia.egg-info/SOURCES.txt +42 -0
- bibliographia-1.0.0/bibliographia.egg-info/dependency_links.txt +1 -0
- bibliographia-1.0.0/bibliographia.egg-info/entry_points.txt +2 -0
- bibliographia-1.0.0/bibliographia.egg-info/requires.txt +15 -0
- bibliographia-1.0.0/bibliographia.egg-info/top_level.txt +1 -0
- bibliographia-1.0.0/bibliography/__init__.py +16 -0
- bibliographia-1.0.0/bibliography/cli.py +94 -0
- bibliographia-1.0.0/bibliography/features/__init__.py +8 -0
- bibliographia-1.0.0/bibliography/features/alternate.py +64 -0
- bibliographia-1.0.0/bibliography/features/column.py +63 -0
- bibliographia-1.0.0/bibliography/features/legacy.py +15 -0
- bibliographia-1.0.0/bibliography/features/result.py +38 -0
- bibliographia-1.0.0/bibliography/features/vspace.py +63 -0
- bibliographia-1.0.0/bibliography/judge.py +55 -0
- bibliographia-1.0.0/bibliography/label.py +170 -0
- bibliographia-1.0.0/bibliography/layout/__init__.py +8 -0
- bibliographia-1.0.0/bibliography/layout/alternate.py +141 -0
- bibliographia-1.0.0/bibliography/layout/column.py +73 -0
- bibliographia-1.0.0/bibliography/layout/utils.py +34 -0
- bibliographia-1.0.0/bibliography/layout/vspace.py +107 -0
- bibliographia-1.0.0/bibliography/machine/__init__.py +8 -0
- bibliographia-1.0.0/bibliography/machine/author.py +72 -0
- bibliographia-1.0.0/bibliography/machine/runtime.py +73 -0
- bibliographia-1.0.0/bibliography/machine/title.py +40 -0
- bibliographia-1.0.0/bibliography/quotes.py +62 -0
- bibliographia-1.0.0/bibliography/reference/__init__.py +31 -0
- bibliographia-1.0.0/bibliography/reference/freeand.py +281 -0
- bibliographia-1.0.0/bibliography/reference/magic.py +70 -0
- bibliographia-1.0.0/bibliography/reference/number.py +201 -0
- bibliographia-1.0.0/bibliography/reference/tech.py +223 -0
- bibliographia-1.0.0/bibliography/utils.py +61 -0
- bibliographia-1.0.0/pyproject.toml +108 -0
- bibliographia-1.0.0/setup.cfg +4 -0
- bibliographia-1.0.0/tests/test_alternate.py +84 -0
- bibliographia-1.0.0/tests/test_double_column.py +42 -0
- bibliographia-1.0.0/tests/test_headline.py +24 -0
- bibliographia-1.0.0/tests/test_invalid_input.py +25 -0
- bibliographia-1.0.0/tests/test_reference_and.py +341 -0
- bibliographia-1.0.0/tests/test_reference_tech.py +170 -0
- bibliographia-1.0.0/tests/test_validate.py +107 -0
|
@@ -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.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bibliographia
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Author-email: Helmut Konrad Schewe <helmutus@outlook.com>
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/anaticulae/bibliography
|
|
7
|
+
Project-URL: Repository, https://github.com/anaticulae/bibliography
|
|
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: configos<2.0.0,>=1.0.4
|
|
15
|
+
Requires-Dist: elementae<2.0.0,>=1.0.1
|
|
16
|
+
Requires-Dist: exemplum<2.0.0,>=1.0.1
|
|
17
|
+
Requires-Dist: geostrat<2.0.0,>=1.5.1
|
|
18
|
+
Requires-Dist: germania<2.0.0,>=1.32.0
|
|
19
|
+
Requires-Dist: iamraw<5.0.0,>=4.92.0
|
|
20
|
+
Requires-Dist: pictura<2.0.0,>=1.0.1
|
|
21
|
+
Requires-Dist: ughost<2.0.0,>=1.0.1
|
|
22
|
+
Requires-Dist: utilo<3.0.0,>=2.109.1
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: gennex==1.0.3; extra == "dev"
|
|
25
|
+
Requires-Dist: hoverpower==1.5.2; extra == "dev"
|
|
26
|
+
Requires-Dist: rawmaker==2.40.5; extra == "dev"
|
|
27
|
+
Requires-Dist: utilotest==1.0.4; extra == "dev"
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
# bibliography
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# bibliography
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bibliographia
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Author-email: Helmut Konrad Schewe <helmutus@outlook.com>
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/anaticulae/bibliography
|
|
7
|
+
Project-URL: Repository, https://github.com/anaticulae/bibliography
|
|
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: configos<2.0.0,>=1.0.4
|
|
15
|
+
Requires-Dist: elementae<2.0.0,>=1.0.1
|
|
16
|
+
Requires-Dist: exemplum<2.0.0,>=1.0.1
|
|
17
|
+
Requires-Dist: geostrat<2.0.0,>=1.5.1
|
|
18
|
+
Requires-Dist: germania<2.0.0,>=1.32.0
|
|
19
|
+
Requires-Dist: iamraw<5.0.0,>=4.92.0
|
|
20
|
+
Requires-Dist: pictura<2.0.0,>=1.0.1
|
|
21
|
+
Requires-Dist: ughost<2.0.0,>=1.0.1
|
|
22
|
+
Requires-Dist: utilo<3.0.0,>=2.109.1
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: gennex==1.0.3; extra == "dev"
|
|
25
|
+
Requires-Dist: hoverpower==1.5.2; extra == "dev"
|
|
26
|
+
Requires-Dist: rawmaker==2.40.5; extra == "dev"
|
|
27
|
+
Requires-Dist: utilotest==1.0.4; extra == "dev"
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
# bibliography
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README
|
|
3
|
+
pyproject.toml
|
|
4
|
+
bibliographia.egg-info/PKG-INFO
|
|
5
|
+
bibliographia.egg-info/SOURCES.txt
|
|
6
|
+
bibliographia.egg-info/dependency_links.txt
|
|
7
|
+
bibliographia.egg-info/entry_points.txt
|
|
8
|
+
bibliographia.egg-info/requires.txt
|
|
9
|
+
bibliographia.egg-info/top_level.txt
|
|
10
|
+
bibliography/__init__.py
|
|
11
|
+
bibliography/cli.py
|
|
12
|
+
bibliography/judge.py
|
|
13
|
+
bibliography/label.py
|
|
14
|
+
bibliography/quotes.py
|
|
15
|
+
bibliography/utils.py
|
|
16
|
+
bibliography/features/__init__.py
|
|
17
|
+
bibliography/features/alternate.py
|
|
18
|
+
bibliography/features/column.py
|
|
19
|
+
bibliography/features/legacy.py
|
|
20
|
+
bibliography/features/result.py
|
|
21
|
+
bibliography/features/vspace.py
|
|
22
|
+
bibliography/layout/__init__.py
|
|
23
|
+
bibliography/layout/alternate.py
|
|
24
|
+
bibliography/layout/column.py
|
|
25
|
+
bibliography/layout/utils.py
|
|
26
|
+
bibliography/layout/vspace.py
|
|
27
|
+
bibliography/machine/__init__.py
|
|
28
|
+
bibliography/machine/author.py
|
|
29
|
+
bibliography/machine/runtime.py
|
|
30
|
+
bibliography/machine/title.py
|
|
31
|
+
bibliography/reference/__init__.py
|
|
32
|
+
bibliography/reference/freeand.py
|
|
33
|
+
bibliography/reference/magic.py
|
|
34
|
+
bibliography/reference/number.py
|
|
35
|
+
bibliography/reference/tech.py
|
|
36
|
+
tests/test_alternate.py
|
|
37
|
+
tests/test_double_column.py
|
|
38
|
+
tests/test_headline.py
|
|
39
|
+
tests/test_invalid_input.py
|
|
40
|
+
tests/test_reference_and.py
|
|
41
|
+
tests/test_reference_tech.py
|
|
42
|
+
tests/test_validate.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
configos<2.0.0,>=1.0.4
|
|
2
|
+
elementae<2.0.0,>=1.0.1
|
|
3
|
+
exemplum<2.0.0,>=1.0.1
|
|
4
|
+
geostrat<2.0.0,>=1.5.1
|
|
5
|
+
germania<2.0.0,>=1.32.0
|
|
6
|
+
iamraw<5.0.0,>=4.92.0
|
|
7
|
+
pictura<2.0.0,>=1.0.1
|
|
8
|
+
ughost<2.0.0,>=1.0.1
|
|
9
|
+
utilo<3.0.0,>=2.109.1
|
|
10
|
+
|
|
11
|
+
[dev]
|
|
12
|
+
gennex==1.0.3
|
|
13
|
+
hoverpower==1.5.2
|
|
14
|
+
rawmaker==2.40.5
|
|
15
|
+
utilotest==1.0.4
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
bibliography
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#==============================================================================
|
|
2
|
+
# C O P Y R I G H T
|
|
3
|
+
#------------------------------------------------------------------------------
|
|
4
|
+
# Copyright (c) 2022-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 importlib.metadata
|
|
11
|
+
import os
|
|
12
|
+
|
|
13
|
+
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
|
|
14
|
+
PROJECT = 'bibliographia'
|
|
15
|
+
PROCESS = 'bibliography'
|
|
16
|
+
__version__ = importlib.metadata.version(PROJECT)
|
|
@@ -0,0 +1,94 @@
|
|
|
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
|
+
|
|
12
|
+
import bibliography
|
|
13
|
+
|
|
14
|
+
DESCRIPTION = ''
|
|
15
|
+
|
|
16
|
+
WORKPLAN = [
|
|
17
|
+
utilo.create_step(
|
|
18
|
+
'alternate',
|
|
19
|
+
inputs=[
|
|
20
|
+
utilo.ResultFile('rawmaker', 'oneline_text_text'),
|
|
21
|
+
utilo.ResultFile('rawmaker', 'oneline_text_positions'),
|
|
22
|
+
utilo.ResultFile('rawmaker', 'border_pages'),
|
|
23
|
+
utilo.ResultFile('footnote', 'result_result'),
|
|
24
|
+
],
|
|
25
|
+
output=('alternate',),
|
|
26
|
+
),
|
|
27
|
+
utilo.create_step(
|
|
28
|
+
'column',
|
|
29
|
+
inputs=[
|
|
30
|
+
utilo.ResultFile('rawmaker', 'text_text'),
|
|
31
|
+
utilo.ResultFile('rawmaker', 'text_positions'),
|
|
32
|
+
utilo.ResultFile('rawmaker', 'oneline_text_text'),
|
|
33
|
+
utilo.ResultFile('rawmaker', 'oneline_text_positions'),
|
|
34
|
+
utilo.ResultFile('rawmaker', 'border_pages'),
|
|
35
|
+
utilo.ResultFile('footnote', 'result_result'),
|
|
36
|
+
],
|
|
37
|
+
output=('column',),
|
|
38
|
+
),
|
|
39
|
+
utilo.create_step(
|
|
40
|
+
'vspace',
|
|
41
|
+
inputs=[
|
|
42
|
+
utilo.ResultFile('rawmaker', 'oneline_text_text'),
|
|
43
|
+
utilo.ResultFile('rawmaker', 'oneline_text_positions'),
|
|
44
|
+
utilo.ResultFile('rawmaker', 'border_pages'),
|
|
45
|
+
utilo.ResultFile('footnote', 'result_result'),
|
|
46
|
+
],
|
|
47
|
+
output=('vspace',),
|
|
48
|
+
),
|
|
49
|
+
utilo.create_step(
|
|
50
|
+
'result',
|
|
51
|
+
inputs=[
|
|
52
|
+
utilo.ResultFile('bibliography', 'alternate_alternate'),
|
|
53
|
+
utilo.ResultFile('bibliography', 'column_column'),
|
|
54
|
+
utilo.ResultFile('bibliography', 'vspace_vspace'),
|
|
55
|
+
],
|
|
56
|
+
output=('result',),
|
|
57
|
+
),
|
|
58
|
+
utilo.create_step(
|
|
59
|
+
'legacy',
|
|
60
|
+
inputs=[
|
|
61
|
+
utilo.ResultFile('bibliography', 'result_result'),
|
|
62
|
+
],
|
|
63
|
+
output=('result',),
|
|
64
|
+
),
|
|
65
|
+
]
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def main():
|
|
69
|
+
utilo.featurepack(
|
|
70
|
+
workplan=WORKPLAN,
|
|
71
|
+
root=bibliography.ROOT,
|
|
72
|
+
featurepackage='bibliography.features',
|
|
73
|
+
config=utilo.FeaturePackConfig(
|
|
74
|
+
description=DESCRIPTION,
|
|
75
|
+
multiprocessed=True,
|
|
76
|
+
name=bibliography.PROCESS,
|
|
77
|
+
pages=True,
|
|
78
|
+
singleinput=False, # require result folder, ignore single pdf file
|
|
79
|
+
rename=rename,
|
|
80
|
+
version=bibliography.__version__,
|
|
81
|
+
),
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def rename(path):
|
|
86
|
+
if not isinstance(path, str):
|
|
87
|
+
path = [rename(item) for item in path]
|
|
88
|
+
return path
|
|
89
|
+
path = utilo.rreplace(
|
|
90
|
+
path,
|
|
91
|
+
pattern='bibliography__legacy_result',
|
|
92
|
+
replace='detector__bibliography_detected',
|
|
93
|
+
)
|
|
94
|
+
return path
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# C O P Y R I G H T
|
|
3
|
+
# -----------------------------------------------------------------------------
|
|
4
|
+
# Copyright (c) 2022-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,64 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# C O P Y R I G H T
|
|
3
|
+
# -----------------------------------------------------------------------------
|
|
4
|
+
# Copyright (c) 2022-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 iamraw
|
|
11
|
+
import serializeraw
|
|
12
|
+
import utilo
|
|
13
|
+
|
|
14
|
+
import bibliography.judge
|
|
15
|
+
import bibliography.layout.alternate
|
|
16
|
+
import bibliography.utils
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def work( # pylint:disable=R0914
|
|
20
|
+
text_oneline: str,
|
|
21
|
+
textpositions_oneline: str,
|
|
22
|
+
sizeandborder: str,
|
|
23
|
+
headerfooter: str,
|
|
24
|
+
pages: tuple = None,
|
|
25
|
+
) -> str:
|
|
26
|
+
pageslist = bibliography.utils.prepare_pages(pages)
|
|
27
|
+
parts = []
|
|
28
|
+
for selected in pageslist:
|
|
29
|
+
textnavigators = serializeraw.ptcn_fromfile(
|
|
30
|
+
text_oneline,
|
|
31
|
+
textpositions_oneline,
|
|
32
|
+
sizeandborder,
|
|
33
|
+
headerfooter,
|
|
34
|
+
pages=selected,
|
|
35
|
+
)
|
|
36
|
+
alternate = bibliography.layout.alternate.extracts(textnavigators)
|
|
37
|
+
utilo.debug(f'alternate: {bibliography.utils.count(alternate)}')
|
|
38
|
+
alternate = bibliography.judge.judge(alternate)
|
|
39
|
+
utilo.debug(f'alternate judged: {bibliography.utils.count(alternate)}')
|
|
40
|
+
parts.append(alternate)
|
|
41
|
+
# select best bib ref
|
|
42
|
+
best = utilo.longest(parts)
|
|
43
|
+
# remove None items
|
|
44
|
+
without_empty = [utilo.notnone(page) for page in best]
|
|
45
|
+
references = utilo.flat(without_empty)
|
|
46
|
+
headline, pdfpages = None, None
|
|
47
|
+
if references:
|
|
48
|
+
pdfpages = tuple(sorted({item.raw_pdfpage for item in references}))
|
|
49
|
+
headline = bibliography.utils.search_headline(
|
|
50
|
+
text_oneline,
|
|
51
|
+
textpositions_oneline,
|
|
52
|
+
sizeandborder,
|
|
53
|
+
headerfooter,
|
|
54
|
+
page=pdfpages[0],
|
|
55
|
+
)
|
|
56
|
+
result = iamraw.BibliographyTable(
|
|
57
|
+
headline=headline,
|
|
58
|
+
references=references,
|
|
59
|
+
pdfpages=pdfpages,
|
|
60
|
+
)
|
|
61
|
+
result.__strategy__ = 'alternate'
|
|
62
|
+
# dump result
|
|
63
|
+
dumped = serializeraw.dump_bibliography_reference(result)
|
|
64
|
+
return dumped
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# C O P Y R I G H T
|
|
3
|
+
# -----------------------------------------------------------------------------
|
|
4
|
+
# Copyright (c) 2022-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 iamraw
|
|
11
|
+
import serializeraw
|
|
12
|
+
import utilo
|
|
13
|
+
|
|
14
|
+
import bibliography.layout.column
|
|
15
|
+
import bibliography.utils
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def work( # pylint:disable=R0914
|
|
19
|
+
text: str,
|
|
20
|
+
textpositions: str,
|
|
21
|
+
oneline_text: str,
|
|
22
|
+
oneline_textpositions: str,
|
|
23
|
+
sizeandborder: str,
|
|
24
|
+
headerfooter: str,
|
|
25
|
+
pages: tuple = None,
|
|
26
|
+
) -> str:
|
|
27
|
+
pageslist = bibliography.utils.prepare_pages(pages)
|
|
28
|
+
parts = []
|
|
29
|
+
for selected in pageslist:
|
|
30
|
+
textnavigators = serializeraw.ptcn_fromfile(
|
|
31
|
+
text,
|
|
32
|
+
textpositions,
|
|
33
|
+
sizeandborder,
|
|
34
|
+
headerfooter,
|
|
35
|
+
pages=selected,
|
|
36
|
+
)
|
|
37
|
+
extracted = bibliography.layout.column.extracts(textnavigators)
|
|
38
|
+
utilo.debug(f'column: {bibliography.utils.count(extracted)}')
|
|
39
|
+
parts.append(extracted)
|
|
40
|
+
# select best bib ref
|
|
41
|
+
best = utilo.longest(parts)
|
|
42
|
+
# remove None items
|
|
43
|
+
without_empty = [utilo.notnone(page) for page in best]
|
|
44
|
+
references = utilo.flat(without_empty)
|
|
45
|
+
headline, pdfpages = None, None
|
|
46
|
+
if references:
|
|
47
|
+
pdfpages = tuple(sorted({item.raw_pdfpage for item in references}))
|
|
48
|
+
headline = bibliography.utils.search_headline(
|
|
49
|
+
oneline_text,
|
|
50
|
+
oneline_textpositions,
|
|
51
|
+
sizeandborder,
|
|
52
|
+
headerfooter,
|
|
53
|
+
page=pdfpages[0],
|
|
54
|
+
)
|
|
55
|
+
result = iamraw.BibliographyTable(
|
|
56
|
+
headline=headline,
|
|
57
|
+
references=references,
|
|
58
|
+
pdfpages=pdfpages,
|
|
59
|
+
)
|
|
60
|
+
result.__strategy__ = 'column'
|
|
61
|
+
# dump result
|
|
62
|
+
dumped = serializeraw.dump_bibliography_reference(result)
|
|
63
|
+
return dumped
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# C O P Y R I G H T
|
|
3
|
+
# -----------------------------------------------------------------------------
|
|
4
|
+
# Copyright (c) 2022-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
|
+
|
|
12
|
+
|
|
13
|
+
def work(xresult: str) -> str:
|
|
14
|
+
content = utilo.file_read(xresult)
|
|
15
|
+
return content
|
|
@@ -0,0 +1,38 @@
|
|
|
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 serializeraw
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def work(
|
|
14
|
+
xalternate: str,
|
|
15
|
+
xcolumn: str,
|
|
16
|
+
xvspace: str,
|
|
17
|
+
) -> str:
|
|
18
|
+
alternate = serializeraw.load_bibliography_reference(xalternate)
|
|
19
|
+
column = serializeraw.load_bibliography_reference(xcolumn)
|
|
20
|
+
vspace = serializeraw.load_bibliography_reference(xvspace)
|
|
21
|
+
|
|
22
|
+
count_column = len(column.references)
|
|
23
|
+
# alternate extracts a lot of more possible bibs, therefore we
|
|
24
|
+
# have to punish the number of results. HolyValue: 0.5
|
|
25
|
+
count_alternate = len(alternate.references) * 0.7
|
|
26
|
+
count_vspace = len(vspace.references) * 0.5
|
|
27
|
+
|
|
28
|
+
count_best, best = count_column, column
|
|
29
|
+
for value, selected in (
|
|
30
|
+
(count_alternate, alternate),
|
|
31
|
+
(count_vspace, vspace),
|
|
32
|
+
):
|
|
33
|
+
if value < count_best:
|
|
34
|
+
continue
|
|
35
|
+
count_best = value
|
|
36
|
+
best = selected
|
|
37
|
+
dumped = serializeraw.dump_bibliography_reference(best)
|
|
38
|
+
return dumped
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# C O P Y R I G H T
|
|
3
|
+
# -----------------------------------------------------------------------------
|
|
4
|
+
# Copyright (c) 2022-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 iamraw
|
|
11
|
+
import serializeraw
|
|
12
|
+
import utilo
|
|
13
|
+
|
|
14
|
+
import bibliography.layout.vspace
|
|
15
|
+
import bibliography.utils
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def work( # pylint:disable=R0914
|
|
19
|
+
text_oneline: str,
|
|
20
|
+
textpositions_oneline: str,
|
|
21
|
+
sizeandborder: str,
|
|
22
|
+
headerfooter: str,
|
|
23
|
+
pages: tuple = None,
|
|
24
|
+
) -> str:
|
|
25
|
+
pageslist = bibliography.utils.prepare_pages(pages)
|
|
26
|
+
parts = []
|
|
27
|
+
for selected in pageslist:
|
|
28
|
+
textnavigators = serializeraw.ptcn_fromfile(
|
|
29
|
+
text_oneline,
|
|
30
|
+
textpositions_oneline,
|
|
31
|
+
sizeandborder,
|
|
32
|
+
headerfooter,
|
|
33
|
+
pages=selected,
|
|
34
|
+
)
|
|
35
|
+
vspace = bibliography.layout.vspace.extracts(textnavigators)
|
|
36
|
+
utilo.debug(f'vspace: {bibliography.utils.count(vspace)}')
|
|
37
|
+
vspace = bibliography.judge.judge(vspace)
|
|
38
|
+
utilo.debug(f'vspace judged: {bibliography.utils.count(vspace)}')
|
|
39
|
+
parts.append(vspace)
|
|
40
|
+
# select best bib ref
|
|
41
|
+
best = utilo.longest(parts)
|
|
42
|
+
# remove None items
|
|
43
|
+
without_empty = [utilo.notnone(page) for page in best]
|
|
44
|
+
references = utilo.flat(without_empty)
|
|
45
|
+
headline, pdfpages = None, None
|
|
46
|
+
if references:
|
|
47
|
+
pdfpages = tuple(sorted({item.raw_pdfpage for item in references}))
|
|
48
|
+
headline = bibliography.utils.search_headline(
|
|
49
|
+
text_oneline,
|
|
50
|
+
textpositions_oneline,
|
|
51
|
+
sizeandborder,
|
|
52
|
+
headerfooter,
|
|
53
|
+
page=pdfpages[0],
|
|
54
|
+
)
|
|
55
|
+
result = iamraw.BibliographyTable(
|
|
56
|
+
headline=headline,
|
|
57
|
+
references=references,
|
|
58
|
+
pdfpages=pdfpages,
|
|
59
|
+
)
|
|
60
|
+
result.__strategy__ = 'vspace'
|
|
61
|
+
# dump result
|
|
62
|
+
dumped = serializeraw.dump_bibliography_reference(result)
|
|
63
|
+
return dumped
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# C O P Y R I G H T
|
|
3
|
+
# -----------------------------------------------------------------------------
|
|
4
|
+
# Copyright (c) 2021-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 configos
|
|
11
|
+
import iamraw
|
|
12
|
+
import utilo
|
|
13
|
+
|
|
14
|
+
import bibliography.utils
|
|
15
|
+
|
|
16
|
+
TITLE_LENGTH_MIN = configos.HV_INT_PLUS(default=10)
|
|
17
|
+
|
|
18
|
+
INVALID_MAX = configos.HolyTable(items=[
|
|
19
|
+
(5, 0),
|
|
20
|
+
(15, 0),
|
|
21
|
+
(30, 3 / 30),
|
|
22
|
+
(100, 10 / 100),
|
|
23
|
+
])
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def judge(pages: list) -> list:
|
|
27
|
+
counted = bibliography.utils.count(pages)
|
|
28
|
+
if not counted:
|
|
29
|
+
return []
|
|
30
|
+
invalid = 0
|
|
31
|
+
for item in utilo.flat(pages):
|
|
32
|
+
if item is None or invalid_single(item):
|
|
33
|
+
invalid += 1
|
|
34
|
+
# determine invalid ratio
|
|
35
|
+
ratio = invalid / counted
|
|
36
|
+
# use greater instead of greater equal to pass zero findings with
|
|
37
|
+
# ration 0.0 and allowed ratio of 0.0
|
|
38
|
+
if ratio > INVALID_MAX(counted):
|
|
39
|
+
# invalid result
|
|
40
|
+
return []
|
|
41
|
+
return pages
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def invalid_single(
|
|
45
|
+
item: iamraw.BibliographyReference,
|
|
46
|
+
title_length_min: int = TITLE_LENGTH_MIN,
|
|
47
|
+
) -> bool:
|
|
48
|
+
if item.reference:
|
|
49
|
+
# if reference is detected this is a sign for good extraction
|
|
50
|
+
# TODO: VALIDATE REFERENCE HERE?
|
|
51
|
+
return False
|
|
52
|
+
if item.title:
|
|
53
|
+
if len(item.title) < title_length_min:
|
|
54
|
+
return True
|
|
55
|
+
return False
|