File: myspellfixprefix.pl

package info (click to toggle)
igerman98 20120607-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 2,496 kB
  • sloc: perl: 940; makefile: 586; sh: 117; sed: 32
file content (34 lines) | stat: -rwxr-xr-x 770 bytes parent folder | download | duplicates (11)
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
#!/usr/bin/perl -w

# 2002-05-05 Bjrn Jacke <bjoern@j3e.de>
#
# script to expand prefixes of capital words to work around a myspell
# bug which would otherwise create words like "unTier" instead of "Untier"
#
# 2005-11-12 Bjoern Jacke <bjoern@j3e.de>
# Comment: hunspell can do decapitalization for this.

while (<STDIN>) {
	chomp;
	if (m/^[A-Z].*\/.*[GUV]/) {
		print STDERR "Capital prefixes will be expanded: $_\n";
		
		($start,$rest) = split("",$_,2);
		$start =~  tr/A-Z/a-z/;
		$rest =~ s/(\/.*)U/$1/;
		$rest =~ s/(\/.*)V/$1/;
		$rest =~ s/(\/.*)G/$1/;
		$rest =~ s/\/$//;
		
		if (m/\/.*U/) {
			s/(\/.*)U/$1/;
			print "Un$start$rest\n";
		}
		if (m/\/.*V/) {
			s/(\/.*)V/$1/;
			print "Ver$start$rest\n";
		}
	}
	chop if (m/\/$/);
	print "$_\n";
}