forked from Drahflow/jura-parse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
basic-rights-exceptions
executable file
·92 lines (77 loc) · 2.67 KB
/
basic-rights-exceptions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/perl
use strict;
use warnings;
use encoding 'utf-8';
use Parse;
use Data::Dumper;
for my $lawFile (glob 'data/laws/*.html') {
Parse::parseHTML($lawFile, 1);
}
my %exceptions;
my %exceptingLaws;
foreach my $law (values %{Parse::all()}) {
next if $law->{'veryshorthand'} eq 'GG';
foreach my $par (@{$law->{'paragraph'}}) {
foreach my $abs (@{$par->{'absatz'}}) {
my $text = $abs->{'text'};
if($text =~ /Grundrecht.*eingeschränkt/) {
# print "\n" . $law->{'veryshorthand'} . ' ' . $par->{'number'} . ' Abs. ' . ($abs->{'number'} or '') . "\n";
# print $abs->{'text'} . "\n";;
if($text =~ /Artikels?\s+(\d+).*?\s+Grundgesetz/) {
while($text =~ /Artikels?\s+(\d+).*?\s+Grundgesetz(.*)/) {
push @{$exceptions{$1}}, [$law, $par, $abs];
$text = $2;
$exceptingLaws{$law->{'veryshorthand'}} = 1;
}
} else {
push @{$exceptions{0}}, [$law, $par, $abs];
}
} elsif($text =~ /Wohnung.*betreten/) {
if($text =~ /mit (dem |der )?(Einverständnis|Zustimmung)/) {
# ok
} elsif($text =~ /Wohnung der verletzten Person/) {
# ok
} elsif($text =~ /Ausnahme von.*Wohnung/) {
# ok
} elsif($text =~ /auf Wunsch/) {
# ok
} elsif($text =~ /Unter.*Wohnung.*sind.*zu.*verstehen/) {
# ok
} else {
push @{$exceptions{0}}, [$law, $par, $abs];
}
}
}
}
}
my @validErrornousExceptions;
foreach my $exception (@{$exceptions{0}}) {
push @validErrornousExceptions, $exception
unless $exceptingLaws{$exception->[0]->{'veryshorthand'}};
}
$exceptions{0} = \@validErrornousExceptions;
print <<EOHTML;
<html><head>
<title>Grundrechtseingriffe</title>
<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
</head><body>
<h1>Grundrechtseingriffe durch Bundesgesetze</h1>
EOHTML
foreach my $art (sort { $a <=> $b } keys %exceptions) {
if($art) {
print "\n<h2>Ausnahmen zu Artikel $art</h2>\n";
} else {
print "\n<h2>Grundrechtseinschränkungen ohne / mit unklarer Artikelnennung (unvollständig)</h2>\n";
}
print "<ul>\n";
my $lastAbs;
foreach my $exception (sort { $a->[0]->{'veryshorthand'} cmp $b->[0]->{'veryshorthand'} } @{$exceptions{$art}}) {
my ($law, $par, $abs) = @$exception;
next if defined $lastAbs and $abs == $lastAbs;
$lastAbs = $abs;
print '<li>' . $law->{'veryshorthand'} . ' § ' . $par->{'number'} . ($abs->{'number'}? ' Abs. ' . $abs->{'number'}: '') . " - " . $law->{'name'} . "</li>\n";
print '<p style="font-size: 70%;">' . $abs->{'text'} . '</p>';
}
print "</ul>\n";
}
print "</body></html>\n";