decider-ref 1.22.2__py3-none-any.whl

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.
Files changed (48) hide show
  1. decider_abb/__init__.py +29 -0
  2. decider_abb/cli.py +46 -0
  3. decider_abb/features/__init__.py +8 -0
  4. decider_abb/features/table.py +147 -0
  5. decider_abb/path.py +16 -0
  6. decider_bib/__init__.py +19 -0
  7. decider_bib/cli.py +75 -0
  8. decider_bib/features/__init__.py +8 -0
  9. decider_bib/features/label.py +306 -0
  10. decider_bib/features/plot.py +73 -0
  11. decider_bib/features/table.py +261 -0
  12. decider_bib/order.py +53 -0
  13. decider_bib/path.py +20 -0
  14. decider_bib/reference.py +87 -0
  15. decider_bib/serialize.py +32 -0
  16. decider_bib/table.py +83 -0
  17. decider_bib/utils.py +75 -0
  18. decider_cap/__init__.py +17 -0
  19. decider_cap/basic.py +148 -0
  20. decider_cap/cli.py +72 -0
  21. decider_cap/driver.py +31 -0
  22. decider_cap/features/__init__.py +8 -0
  23. decider_cap/features/basic.py +154 -0
  24. decider_cap/features/missing.py +143 -0
  25. decider_cap/features/style.py +52 -0
  26. decider_ref/__init__.py +16 -0
  27. decider_ref/listdiff.py +50 -0
  28. decider_ref-1.22.2.dist-info/METADATA +50 -0
  29. decider_ref-1.22.2.dist-info/RECORD +48 -0
  30. decider_ref-1.22.2.dist-info/WHEEL +5 -0
  31. decider_ref-1.22.2.dist-info/entry_points.txt +6 -0
  32. decider_ref-1.22.2.dist-info/licenses/LICENSE +21 -0
  33. decider_ref-1.22.2.dist-info/top_level.txt +5 -0
  34. decider_toc/__init__.py +20 -0
  35. decider_toc/balance.py +247 -0
  36. decider_toc/cli.py +84 -0
  37. decider_toc/duplicated.py +155 -0
  38. decider_toc/features/__init__.py +69 -0
  39. decider_toc/features/basic.py +159 -0
  40. decider_toc/features/complexity.py +194 -0
  41. decider_toc/features/rules.py +147 -0
  42. decider_toc/features/style.py +100 -0
  43. decider_toc/features/sync.py +137 -0
  44. decider_toc/length.py +31 -0
  45. decider_toc/level.py +79 -0
  46. decider_toc/marks.py +52 -0
  47. decider_toc/path.py +8 -0
  48. decider_toc/utils.py +42 -0
@@ -0,0 +1,29 @@
1
+ # =============================================================================
2
+ # C O P Y R I G H T
3
+ # -----------------------------------------------------------------------------
4
+ # Copyright (c) 2021-2022 by Helmut Konrad Fahrendholz. All rights reserved.
5
+ # This file is property of Helmut Konrad Fahrendholz. 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
+ """Abbreviation Analyzer
10
+ =====================
11
+
12
+ * verify order/sorted
13
+ * check obvious abbrevation and give advice to delete abbreviation
14
+
15
+ TODO: INFORM ABOUT NOT USED ABBREVIATION
16
+ TODO: VERIFY FIRST USAGE
17
+ """
18
+
19
+ import configos
20
+
21
+ import decider_abb.path
22
+ import decider_ref
23
+
24
+ __version__ = decider_ref.__version__
25
+
26
+ ROOT = decider_ref.ROOT
27
+ PROCESS = 'decider_abbrev'
28
+
29
+ configos.cloud_lookup(PROCESS)
decider_abb/cli.py ADDED
@@ -0,0 +1,46 @@
1
+ # =============================================================================
2
+ # C O P Y R I G H T
3
+ # -----------------------------------------------------------------------------
4
+ # Copyright (c) 2021-2022 by Helmut Konrad Fahrendholz. All rights reserved.
5
+ # This file is property of Helmut Konrad Fahrendholz. 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 protoerror
11
+ import utilo
12
+
13
+ import decider_abb
14
+
15
+ DESCRIPTION = ''
16
+
17
+ WORKPLAN = [
18
+ utilo.create_step(
19
+ 'table',
20
+ [
21
+ utilo.ResultFile('reftable', 'abbrev_abbrev'),
22
+ utilo.ResultFile('words', 'abbreviation_detected'),
23
+ ],
24
+ output=protoerror.ResultDefault,
25
+ ),
26
+ ]
27
+
28
+
29
+ def main():
30
+ hook = protoerror.integrate(
31
+ root=decider_abb.ROOT,
32
+ features='decider_abb.features',
33
+ )
34
+ utilo.featurepack(
35
+ workplan=WORKPLAN,
36
+ root=decider_abb.ROOT,
37
+ featurepackage='decider_abb.features',
38
+ config=utilo.FeaturePackConfig(
39
+ cli_hook=hook,
40
+ description=DESCRIPTION,
41
+ multiprocessed=True,
42
+ name=decider_abb.PROCESS,
43
+ pages=True,
44
+ version=decider_abb.__version__,
45
+ ),
46
+ )
@@ -0,0 +1,8 @@
1
+ # =============================================================================
2
+ # C O P Y R I G H T
3
+ # -----------------------------------------------------------------------------
4
+ # Copyright (c) 2021-2022 by Helmut Konrad Fahrendholz. All rights reserved.
5
+ # This file is property of Helmut Konrad Fahrendholz. 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,147 @@
1
+ # =============================================================================
2
+ # C O P Y R I G H T
3
+ # -----------------------------------------------------------------------------
4
+ # Copyright (c) 2021-2022 by Helmut Konrad Fahrendholz. All rights reserved.
5
+ # This file is property of Helmut Konrad Fahrendholz. 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 konradus
12
+ import protoerror
13
+ import serializeraw
14
+ import utilo
15
+
16
+ import decider_ref.listdiff
17
+
18
+
19
+ def work(
20
+ abbrev: str,
21
+ intext: str,
22
+ pages: tuple = None,
23
+ ) -> protoerror.ResultType:
24
+ driver = create_driver(
25
+ abbrev,
26
+ intext,
27
+ pages=pages,
28
+ )
29
+ result = protoerror.run(
30
+ __name__,
31
+ driver,
32
+ )
33
+ return result
34
+
35
+
36
+ def create_driver(abbrev: str, intext: str, pages: tuple = None):
37
+ if utilo.exists(abbrev):
38
+ table = serializeraw.load_abbreviation_table(abbrev)
39
+ else:
40
+ table = iamraw.AbbreviationResult()
41
+ intext = serializeraw.load_text_abbreviations(intext, pages=pages)
42
+ driver = protoerror.driver(
43
+ abbrevtable=table,
44
+ intext=intext,
45
+ )
46
+ return driver
47
+
48
+
49
+ SOLUTION_15010 = """\
50
+ Abkürzungsverzeichnis nicht alphabetisch sortiert
51
+
52
+ Sortieren Sie das Abkürzungsverzeichnis.
53
+
54
+ {{advice}}
55
+
56
+ {elemente/abkuerzungsverzeichnis#alphabetische-sortierung}
57
+ """
58
+
59
+
60
+ def check_15010_not_sorted_alphabetically(linter: callable, driver):
61
+ abbreviations: iamraw.AbbreviationResult = driver.abbrevtable
62
+ current = list(abbreviations)
63
+ expected = sorted(
64
+ abbreviations,
65
+ key=lambda x: utilo.alphabetically(x.short),
66
+ )
67
+ if current == expected:
68
+ # well sorted
69
+ return
70
+ location = pagelocation(current[0])
71
+ # prepare viewable format
72
+ current = [format_abbreviation_line(item) for item in current]
73
+ expected = [format_abbreviation_line(item) for item in expected]
74
+ advice = decider_ref.listdiff.diffview(expected, current)
75
+ linter(
76
+ advice=advice,
77
+ location=location,
78
+ )
79
+
80
+
81
+ SOLUTION_R15015 = """\
82
+ Allgemein gültige Abkürzung
83
+
84
+ Die Abkürzung {{abbreviation}} kann als allgemein gültig angenommen werden und \
85
+ muss nicht separat aufgeführt werden. Entfernen Sie die Abkürzung um die \
86
+ Übersichtlichkeit des Abkürzungsverzeichnisses zu erhöhen.
87
+
88
+ {elemente/abkuerzungsverzeichnis#abkurzungsverzeichnis}
89
+ """
90
+
91
+
92
+ def check_15015_abbreviation_not_required(linter: callable, driver):
93
+ """Inform user to remove common abbreviation (exists in DUDEN)."""
94
+ abbreviations: iamraw.AbbreviationResult = driver.abbrevtable
95
+ for item in abbreviations:
96
+ name = item.short.lower()
97
+ if name not in konradus.ABBREVIATION_LOWER:
98
+ continue
99
+ linter(
100
+ abbreviation=item.short,
101
+ location=pagelocation(item),
102
+ )
103
+
104
+
105
+ SOLUTION_R15016 = """\
106
+ Abkürzung nicht vorhanden
107
+
108
+ Die Abkürzung **{{abbrev}}** ist nicht im Abkürzungsverzeichnis aufgeführt.
109
+
110
+ {elemente/abkuerzungsverzeichnis#abkurzungsverzeichnis}
111
+ """
112
+
113
+
114
+ def check_15016_abbreviation_missing(linter: callable, driver):
115
+ abbreviations: iamraw.AbbreviationResult = driver.abbrevtable
116
+ if len(abbreviations) == 0: # pylint:disable=compare-to-zero
117
+ protoerror.skip_method('no abbreviation table')
118
+ return
119
+ references = utilo.flatten_content(driver.intext)
120
+ references = [
121
+ item for item in references
122
+ if item.short.lower() not in konradus.ABBREVIATION_LOWER
123
+ ]
124
+ single = utilo.Single()
125
+ collected = [
126
+ item for item in references if not single.contains(item.short.lower())
127
+ ]
128
+ pdfpage = abbreviations.pdfpages[0]
129
+ location = iamraw.Location.from_page(page=pdfpage)
130
+ for item in collected:
131
+ if abbreviations.short_inside(item.short):
132
+ continue
133
+ linter(
134
+ abbrev=item.short,
135
+ location=location,
136
+ )
137
+
138
+
139
+ def format_abbreviation_line(item) -> str:
140
+ return f' * {item.short} {item.description}'
141
+
142
+
143
+ def pagelocation(item) -> iamraw.Location:
144
+ pagenumber = protoerror.OVERVIEW
145
+ if item.position:
146
+ pagenumber = iamraw.Location.from_page(item.position.page)
147
+ return pagenumber
decider_abb/path.py ADDED
@@ -0,0 +1,16 @@
1
+ # =============================================================================
2
+ # C O P Y R I G H T
3
+ # -----------------------------------------------------------------------------
4
+ # Copyright (c) 2021-2022 by Helmut Konrad Fahrendholz. All rights reserved.
5
+ # This file is property of Helmut Konrad Fahrendholz. 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 decider_abb
13
+
14
+
15
+ def decider_abb_table_user(path: str, prefix: str = '') -> str:
16
+ return utilo.pathconnector(path, decider_abb.PROCESS, 'table_user', prefix)
@@ -0,0 +1,19 @@
1
+ # =============================================================================
2
+ # C O P Y R I G H T
3
+ # -----------------------------------------------------------------------------
4
+ # Copyright (c) 2020-2022 by Helmut Konrad Fahrendholz. All rights reserved.
5
+ # This file is property of Helmut Konrad Fahrendholz. 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
+
12
+ # ease importing path module when using decider_bib
13
+ import decider_bib.path
14
+ import decider_ref
15
+
16
+ ROOT = decider_ref.ROOT
17
+ PROCESS = 'decider_bibliography'
18
+
19
+ configos.cloud_lookup(PROCESS)
decider_bib/cli.py ADDED
@@ -0,0 +1,75 @@
1
+ #==============================================================================
2
+ # C O P Y R I G H T
3
+ #------------------------------------------------------------------------------
4
+ # Copyright (c) 2019-2022 by Helmut Konrad Fahrendholz. All rights reserved.
5
+ # This file is property of Helmut Konrad Fahrendholz. 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 protoerror
11
+ import utilo
12
+
13
+ import decider_bib
14
+ import decider_ref
15
+
16
+ DESCRIPTION = ''
17
+
18
+ USER = 'user'
19
+ DEVELOPER = 'developer'
20
+
21
+ WORKPLAN = [
22
+ utilo.create_step(
23
+ 'label',
24
+ [
25
+ utilo.ResultFile('detector', 'bibliography_detected'),
26
+ utilo.ResultFile('docref', 'bibliography_parsed'),
27
+ utilo.ResultFile('words', 'headlines_headlines'),
28
+ utilo.ResultFile('words', 'sentences_sentences'),
29
+ utilo.ResultFile('sections', 'section_result'),
30
+ ],
31
+ (USER, DEVELOPER),
32
+ ),
33
+ utilo.create_step(
34
+ 'table',
35
+ [
36
+ utilo.ResultFile('detector', 'bibliography_detected'),
37
+ utilo.ResultFile('detector', 'titlepage_detected'),
38
+ utilo.File('pdflog'),
39
+ ],
40
+ (USER, DEVELOPER),
41
+ ),
42
+ utilo.create_step(
43
+ name='plot',
44
+ inputs=[
45
+ utilo.ResultFile('detector', 'bibliography_detected'),
46
+ ],
47
+ output=[
48
+ ('year_histogram', 'png'),
49
+ ],
50
+ ),
51
+ ]
52
+
53
+
54
+ def main():
55
+ hook = protoerror.integrate(
56
+ root=decider_ref.ROOT,
57
+ features='decider_bib.features',
58
+ )
59
+ docinfo = protoerror.integrate_docinfo()
60
+ utilo.featurepack(
61
+ workplan=WORKPLAN,
62
+ root=decider_ref.ROOT,
63
+ featurepackage='decider_bib.features',
64
+ config=utilo.FeaturePackConfig(
65
+ cli_hook=[
66
+ docinfo,
67
+ hook,
68
+ ],
69
+ description=DESCRIPTION,
70
+ multiprocessed=True,
71
+ name=decider_bib.PROCESS,
72
+ pages=True,
73
+ version=decider_ref.__version__,
74
+ ),
75
+ )
@@ -0,0 +1,8 @@
1
+ # =============================================================================
2
+ # C O P Y R I G H T
3
+ # -----------------------------------------------------------------------------
4
+ # Copyright (c) 2020-2022 by Helmut Konrad Fahrendholz. All rights reserved.
5
+ # This file is property of Helmut Konrad Fahrendholz. 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,306 @@
1
+ # =============================================================================
2
+ # C O P Y R I G H T
3
+ # -----------------------------------------------------------------------------
4
+ # Copyright (c) 2020-2022 by Helmut Konrad Fahrendholz. All rights reserved.
5
+ # This file is property of Helmut Konrad Fahrendholz. 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 docref.biblio.parser
12
+ import iamraw
13
+ import protoerror
14
+ import serializeraw
15
+ import utilo
16
+
17
+ import decider_bib.reference
18
+ import decider_bib.serialize
19
+ import decider_bib.utils
20
+
21
+
22
+ def work( # pylint:disable=W0613
23
+ bibtable: str,
24
+ docreference: str,
25
+ headlines: str,
26
+ text: str,
27
+ sections: str,
28
+ docinfo: iamraw.DocInfo,
29
+ pages: tuple = None,
30
+ ) -> protoerror.ResultType:
31
+ driver = create_driver(**locals())
32
+ if driver.bibliography.references: # pylint:disable=E1101
33
+ result = protoerror.run(
34
+ modulename=__name__,
35
+ driver=driver,
36
+ document=docinfo,
37
+ )
38
+ else:
39
+ utilo.error('no bib table parsed: skip decider_bib:label')
40
+ result = protoerror.RESULT_EMPTY
41
+ return result
42
+
43
+
44
+ def create_driver(
45
+ bibtable: str,
46
+ docreference: str,
47
+ headlines: str,
48
+ text: str,
49
+ sections: str,
50
+ docinfo: iamraw.DocInfo,
51
+ pages: tuple = None,
52
+ ):
53
+ bibliography = decider_bib.serialize.load_bibliography_reference(bibtable)
54
+ docreference = serializeraw.load_docref(docreference, pages=pages)
55
+ headlines = serializeraw.load_headlines(headlines, pages=pages)
56
+ sections = serializeraw.load_sections(sections, pages=pages)
57
+ text = serializeraw.load_text(text, headlines=headlines, pages=pages)
58
+ nobibs = nobibpages(sections)
59
+ # create driver
60
+ result = protoerror.driver(
61
+ bibliography=bibliography,
62
+ bibtextref=docreference,
63
+ text=text,
64
+ nobibs=nobibs,
65
+ docinfo=docinfo,
66
+ )
67
+ return result
68
+
69
+
70
+ def nobibpages(sections: iamraw.sections.Sections) -> set:
71
+ """Determine pages which are not bib-table pages."""
72
+ end = sections[-1].end + 1
73
+ collected = set()
74
+ for part in sections:
75
+ for item in part:
76
+ if not isinstance(item, iamraw.sections.Bibliography):
77
+ continue
78
+ for page in range(int(item.start), int(item.end + 1)):
79
+ collected.add(page)
80
+ result = {item for item in range(end) if item not in collected}
81
+ return result
82
+
83
+
84
+ def missing_bibtable_reference(bibtable) -> bool:
85
+ if not bibtable:
86
+ return True
87
+ if len(bibtable) < 10:
88
+ utilo.error(f'too few bib entry: {len(bibtable)}')
89
+ return True
90
+ invalid_reference = [item for item in bibtable if not item.reference]
91
+ rate = len(invalid_reference) / len(bibtable)
92
+ if rate > 0.2:
93
+ utilo.error(f'too many invalid bib references: {rate}')
94
+ return True
95
+ return False
96
+
97
+
98
+ SOLUTION_6050 = """\
99
+ Quelle nicht gefunden
100
+
101
+ Die Referenz **{{reference}}** fehlt im Quellenverzeichnis.
102
+ """
103
+
104
+
105
+ def check_6050_ref_in_table(linter: callable, driver):
106
+ if missing_bibtable_reference(driver.bibliography.references):
107
+ utilo.log('disable 6050')
108
+ return
109
+ plains = references_plain(driver.bibtextref, driver.text)
110
+ for reference, plain in zip(driver.bibtextref, plains):
111
+ if reference.page not in driver.nobibs:
112
+ # bib table page
113
+ continue
114
+ location = iamraw.Location.from_sentence(
115
+ sentence=reference.sentence,
116
+ page=reference.page,
117
+ )
118
+ for mark, item in zip(reference.marked, plain): # pylint:disable=W0612
119
+ # verify that reference exists
120
+ inside = decider_bib.reference.inside(
121
+ reference=item,
122
+ table=driver.bibliography.references,
123
+ )
124
+ if inside:
125
+ # reference found
126
+ continue
127
+ if inside is None:
128
+ # Could not parse bib label. Do not inform user about
129
+ # missing reference when we are not able to parse the
130
+ # reference.
131
+ continue
132
+ linter(location=location, reference=item)
133
+
134
+
135
+ SOLUTION_6051 = """\
136
+ Quelle überflüssig
137
+
138
+ Die Quelle **{{source}}** wird im Text nicht verwendet.
139
+ """
140
+
141
+
142
+ def check_6051_table_in_text(linter: callable, driver):
143
+ insentence = insentence_reference(driver.text, driver.bibtextref)
144
+ source = list(driver.bibliography.references)
145
+ for item in source:
146
+ if item.reference:
147
+ continue
148
+ utilo.debug(f'None-Reference: {item}')
149
+ not_required = [
150
+ item for item in source
151
+ if not decider_bib.reference.reference_inside(item, insentence)
152
+ ]
153
+ for item in not_required:
154
+ location = iamraw.Location.from_page(item.raw_pdfpage)
155
+ source = item.reference
156
+ if not source:
157
+ # skip None-Reference
158
+ continue
159
+ linter(
160
+ location=location,
161
+ source=source,
162
+ )
163
+
164
+
165
+ def insentence_reference(text, bibliography) -> set:
166
+ """Prepare references which are located inside sentences."""
167
+ insentence_ref = references_plain(bibliography, text)
168
+ insentence_ref = utilo.flat(insentence_ref)
169
+ result = set()
170
+ for item in insentence_ref:
171
+ parsed = docref.biblio.parser.parse(item)
172
+ if not parsed:
173
+ utilo.error(f'could not parse: {item}')
174
+ continue
175
+ # TODO: SUPPORT MORE THAN ONE REFERENCE IN A SENTENCE?
176
+ reference = parsed[0].reference
177
+ if utilo.isint(reference):
178
+ # convert to valid [10]-intext reference
179
+ reference = f'[{reference}]'
180
+ result.add(reference)
181
+ return result
182
+
183
+
184
+ SOLUTION_6061 = """\
185
+ Seitenangabe fehlt
186
+
187
+ Der Quellenverweis **{{reference}}** enthält keine Seitenangabe.
188
+ """
189
+
190
+
191
+ def check_6061_bib_ref_no_page(linter: callable, driver):
192
+ plains = references_plain(driver.bibtextref, driver.text)
193
+ for reference, plain in zip(driver.bibtextref, plains):
194
+ if reference.page not in driver.nobibs:
195
+ # bib table page
196
+ continue
197
+ location = iamraw.Location.from_sentence(
198
+ sentence=reference.sentence,
199
+ page=reference.page,
200
+ )
201
+ for mark, item in zip(reference.marked, plain): # pylint:disable=W0612
202
+ if decider_bib.reference.has_page(item):
203
+ continue
204
+ linter(
205
+ location=location,
206
+ reference=item,
207
+ )
208
+
209
+
210
+ SOLUTION_6062 = """\
211
+ Seitenangabe unkonkret
212
+
213
+ Die Seitenzahl **{{reference}}** sollte durch die konkrete Seitenzahl \
214
+ ersetzt werden.
215
+ """
216
+
217
+
218
+ def check_6062_bib_ref_inaccurate_page(linter: callable, driver):
219
+ plains = references_plain(driver.bibtextref, driver.text)
220
+ for reference, plain in zip(driver.bibtextref, plains):
221
+ location = iamraw.Location.from_sentence(
222
+ sentence=reference.sentence,
223
+ page=reference.page,
224
+ )
225
+ for mark, item in zip(reference.marked, plain): # pylint:disable=W0612
226
+ if decider_bib.reference.precise(item):
227
+ continue
228
+ linter(
229
+ location=location,
230
+ reference=item,
231
+ )
232
+
233
+
234
+ MISSING_PAGENUMBER_RATE_MIN = configos.HV_PERCENT_PLUS(default=20)
235
+
236
+ SOLUTION_I6063 = """\
237
+ Empfehlung: Quellenangaben konkretisieren
238
+
239
+ Es wird empfohlen sämtlichen Quellen eine Seitenangabe zuzufügen.
240
+ """
241
+
242
+
243
+ def check_6063_bib_ref_add_pagination(linter: callable, driver):
244
+ """Add hint to add page numbers.
245
+
246
+ If there are too many lintings, disable this lintings.
247
+ """
248
+ baselinter: protoerror.Linter = linter.func.__self__
249
+ pagenumber_missing = baselinter.count_findings(msgid=6061)
250
+ if pagenumber_missing < 30:
251
+ return
252
+ intext_ref = len(driver.bibtextref)
253
+ rate = pagenumber_missing / intext_ref
254
+ if rate < MISSING_PAGENUMBER_RATE_MIN:
255
+ return
256
+ linter(location=protoerror.OVERVIEW)
257
+
258
+ def disable_6061(findings):
259
+ return [item for item in findings if item.msgid != 6061]
260
+
261
+ baselinter.check_findings(disable_6061)
262
+
263
+
264
+ SOLUTION_6070 = """\
265
+ Label vereinfachen
266
+
267
+ Vereinfachen Sie das Label und entfernen Sie unnötige Klammern.
268
+
269
+ Erkannt: ([WA12])
270
+ Besser: [WAS12]
271
+
272
+ Erkannt: ([HA15], S. 40)
273
+ Besser: [HA15, S. 40]
274
+ """
275
+
276
+ SPECIAL_COUNT_ACTIVE_MIN = configos.HV_INT_PLUS(default=5)
277
+
278
+
279
+ def check_6070_bib_ref_too_complicated(linter: callable, driver):
280
+ plains = references_plain(driver.bibtextref, driver.text)
281
+ collected = []
282
+ for _, plain in zip(driver.bibtextref, plains):
283
+ collected.extend(plain)
284
+ if not collected:
285
+ return
286
+ special = [
287
+ item for item in collected
288
+ if item.startswith('([') and item.endswith(')')
289
+ ]
290
+ if len(special) < SPECIAL_COUNT_ACTIVE_MIN:
291
+ return
292
+ # TODO: ADD HINT FOR EVERY FINDING?
293
+ linter(location=protoerror.OVERVIEW)
294
+
295
+
296
+ def references_plain(references, text) -> list:
297
+ result = []
298
+ sentences = decider_bib.utils.sentence_lookup(text)
299
+ for ref in references:
300
+ page, sentenceid, marked = ref.page, ref.sentence, ref.marked
301
+ selected = decider_bib.utils.sentence_plain( # pylint:disable=E1101
302
+ sentences[page][sentenceid],
303
+ marks=marked,
304
+ )
305
+ result.append(selected)
306
+ return result