File: uniqflag.pl

package info (click to toggle)
hkgerman 1%3A2-39
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 9,620 kB
  • sloc: makefile: 219; sh: 159; perl: 42; sed: 29
file content (45 lines) | stat: -rw-r--r-- 1,040 bytes parent folder | download | duplicates (21)
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
#!/usr/bin/perl

# 2002-05-05 Bjrn Jacke <bjoern@j3e.de>
#
# this script combines flags of equal base words from ispell/myspell:
#
# lachen/D
# lachen/IX
#
# ... will be converted to:
#
# lachen/DIX
#
# this is needed for myspell delivered with OO.o 1.0 which does only
# regard the first occurence of a base word, so lachen/IX would be
# ignored.
#
# Attention:
#
# adjektive.txt:bewiesen/AU
# verben.txt:bewiesen/WX
#
# this would lead to words like "unbewies" :-|


$first=<STDIN>;
chomp($first);
($firstbase,$firstflags)=split("/",$first);
while (<STDIN>) {
	chomp;
	($base,$flags) = split "/";
	if ($base eq $firstbase) {
		print STDERR "Duplicate base word: $base, flags: $firstflags and $flags\n";
		for (split "",$flags) {
			$firstflags .= $_ unless ($firstflags =~ $_);
		}
	} else { # a really new word is here ...
		$firstflags = "/$firstflags" if ($firstflags);
		print "$firstbase$firstflags\n";
		$firstbase = $base;
		$firstflags = $flags;
	}
}
$firstflags = "/$firstflags" if ($firstflags);
print "$firstbase$firstflags";