1 |
# -*- Mode: Perl -*- |
2 |
# Bibdb.pm -- |
3 |
# ITIID : $ITI$ $Header $__Header$ |
4 |
# Author : Ulrich Pfeifer |
5 |
# Created On : Thu Sep 5 16:17:38 1996 |
6 |
# Last Modified By: Ulrich Pfeifer |
7 |
# Last Modified On: Sun Nov 22 18:44:42 1998 |
8 |
# Language : CPerl |
9 |
# Update Count : 50 |
10 |
# Status : Unknown, Use with caution! |
11 |
# |
12 |
# Copyright (c) 1996-1997, Ulrich Pfeifer |
13 |
# |
14 |
|
15 |
package WAIT::Parse::Bibdb; |
16 |
require WAIT::Parse::Base; |
17 |
use strict; |
18 |
use vars qw(@ISA); |
19 |
|
20 |
@ISA = qw(WAIT::Parse::Base); |
21 |
|
22 |
sub split { # called as method |
23 |
my %result; |
24 |
my $fld; |
25 |
|
26 |
for (split /\n/, $_[1]) { |
27 |
if (s/^(\S+):\s*//) { |
28 |
$fld = lc $1; |
29 |
$result{$fld} = '' unless exists $result{$fld} # -w |
30 |
} |
31 |
$result{$fld} .= WAIT::Filter::detex($_) if defined $fld; |
32 |
} |
33 |
return \%result; # we go for speed |
34 |
} |
35 |
|
36 |
|
37 |
sub tag { # called as method |
38 |
my @result; |
39 |
my $tag; |
40 |
|
41 |
for (split /\n/, $_[1]) { |
42 |
next if /^\w\w:\s*$/; |
43 |
if (s/^(\S+)://) { |
44 |
push @result, {_b => 1}, "$1:"; |
45 |
$tag = lc $1; |
46 |
} |
47 |
if (defined $tag) { # detex changes character positions; |
48 |
# it *must* be applied therefore |
49 |
push @result, {$tag => 1}, WAIT::Filter::detex("$_\n"); |
50 |
} else { |
51 |
push @result, {}, WAIT::Filter::detex("$_\n"); |
52 |
} |
53 |
} |
54 |
return @result; # we don't go for speed |
55 |
} |
56 |
|
57 |
# Cusomized filters |
58 |
package WAIT::Filter; |
59 |
|
60 |
sub cctr { |
61 |
my $text = shift; |
62 |
$text =~ tr/A-Z/a-z/; |
63 |
$text =~ tr/a-z0-9./ /c; # don't squeeze |
64 |
$text; |
65 |
} |
66 |
|
67 |
# Filter changes character position. It *must* be applied in the |
68 |
# tagging function to yield propper hilighting! |
69 |
sub detex { |
70 |
local($_) = @_; |
71 |
|
72 |
return '' unless defined $_; |
73 |
s/\\\"a/\344/g; # ä |
74 |
s/\\\"A/\344/g; # ä |
75 |
s/\\\"o/\366/g; # ö |
76 |
s/\\\"O/\366/g; # ö |
77 |
s/\\\"u/\374/g; # ü |
78 |
s/\\\"U/\374/g; # ü |
79 |
s/\\\"s/\337/g; # ß |
80 |
s/\\ss\{\}/\337/g; # ß |
81 |
$_; |
82 |
} |
83 |
|
84 |
1; |
85 |
|