minor changes
[worddb.git] / wiktionary / parsewords.pl
bloba6588c976ccf88bb034a9c316cf40b61126b2964
1 #!/usr/bin/perl
3 if ($#ARGV != 0)
5 print "Usage: $0 <filename> \n";
6 exit;
9 $filename = $ARGV[0];
10 print "File: $filename\n";
11 open(FILE, $filename) or die("Could not open file $filename");
12 @alllines = <FILE>;
13 $collect = 'NONE';
15 foreach $line (@alllines)
17 if ($line =~ m/<title>(\w+)<\/title>/) {
18 print "\n";
19 print "Word: $1\n";
20 $collect = 'NONE';
22 } elsif ($collect eq 'ETYMOLOGY') {
23 print "Etymology: $line \n";
24 $collect = 'NONE';
25 } elsif ($line =~ m/===Etymology/) {
26 $collect = 'ETYMOLOGY';
28 } elsif ($collect eq 'NOUN') {
29 if ($line =~ m/^#:/) {
30 print "Noun Usage: $line";
31 } elsif ($line =~ m/^#/) {
32 print "Noun Meaning: $line";
33 } elsif ($line =~ m/^==/) {
34 $collect = 'NONE';
36 } elsif ($line =~ m/==Noun/) {
37 $collect = 'NOUN';
39 } elsif ($collect eq 'VERB') {
40 if ($line =~ m/^#:/) {
41 print "Verb Usage: $line";
42 } elsif ($line =~ m/^#/) {
43 print "Verb Meaning: $line";
44 } elsif ($line =~ m/^==/) {
45 $collect = 'NONE';
47 } elsif ($line =~ m/==Verb/) {
48 $collect = 'VERB';
50 } elsif ($collect eq 'ADJECTIVE') {
51 if ($line =~ m/^#:/) {
52 print "Adjective Usage: $line";
53 } elsif ($line =~ m/^#/) {
54 print "Adjective Meaning: $line";
55 } elsif ($line =~ m/^==/) {
56 $collect = 'NONE';
58 } elsif ($line =~ m/==Adjective/) {
59 $collect = 'ADJECTIVE';
62 close (FILE);