annotate doc/interpreter/doccheck/add_to_aspell_dict @ 10795:0306e572c686

Use case insensitive sort in spellcheck scripts.
author Rik <octave@nomad.inbox5.com>
date Sun, 18 Jul 2010 22:10:13 -0700
parents 3140cb7a05a1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10791
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
1 #!/usr/bin/perl -w
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
2
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
3 ################################################################################
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
4 # File : add_to_aspell_dict
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
5 # Purpose: Merges a file of new words into an existing dictionary file.
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
6 # The resulting file is uniquified and sorted before being written out.
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
7 # Usage : add_to_aspell_dict <filename_of_new_words>
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
8 ################################################################################
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
9 # Initialize variables
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
10 # Private Octave dictionary for Aspell
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
11 $octdict_fname = './doccheck/aspell-octave.en.pws';
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
12
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
13 ################################################################################
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
14 # Parse command line arguments
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
15 if (@ARGV != 1)
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
16 {
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
17 die "USAGE: add_to_aspell_dict <filename_of_new_words>\n";
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
18 }
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
19
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
20 $new_words_fname = shift(@ARGV);
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
21 if (!-r $new_words_fname)
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
22 {
10795
0306e572c686 Use case insensitive sort in spellcheck scripts.
Rik <octave@nomad.inbox5.com>
parents: 10791
diff changeset
23 die "Unable to read input file: $new_words_fname\n";
10791
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
24 }
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
25
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
26 ################################################################################
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
27 # Add new words to a dictionary database
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
28 open (FH, "<$new_words_fname") or die "Unable to open file: $new_words_fname\n";
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
29 while (<FH>) { $dict_db{$_} = 1; }
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
30 close (FH);
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
31
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
32 # Add words from existing dictionary to dictionary database
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
33 open (FH, "<$octdict_fname") or die "Unable to open Octave dictionary: $octdict_fname\n";
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
34 $header = <FH>;
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
35 while (<FH>) { $dict_db{$_} = 1; }
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
36 close (FH);
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
37
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
38 # Remove old dictionary file and write out new one
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
39 unlink ($octdict_fname) or die "Unable to delete Octave dictionary: $octdict_fname\n";
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
40 open (FH, ">$octdict_fname") or die "Unable to open file for writing: $octdict_fname\n";
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
41 print FH $header;
10795
0306e572c686 Use case insensitive sort in spellcheck scripts.
Rik <octave@nomad.inbox5.com>
parents: 10791
diff changeset
42 print FH sort { uc($a) cmp uc ($b) } keys(%dict_db);
10791
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
43 close (FH);
3140cb7a05a1 Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
diff changeset
44