comparison doc/interpreter/doccheck/add_to_aspell_dict @ 10791:3140cb7a05a1

Add spellchecker scripts for Octave and run spellcheck of documentation interpreter/doccheck: New directory for spelling/grammar scripts. interpreter/doccheck/README: Instructions for using scripts. interpreter/doccheck/spellcheck: Script to spellcheck a Texinfo file. interpreter/doccheck/aspell.conf: GNU Aspell configuration file for Octave documentation. interpreter/doccheck/aspell-octave.en.pws: Private Aspell dictionary. interpreter/doccheck/add_to_aspell_dict: Script to add new Octave-specific words to private Aspell dictionary. interpreter/octave.texi: New @nospell macro which forces Aspell to ignore the word marked by the macro. interpreter/mk_doc_cache.m: Skip new @nospell macro when building doc_cache.
author Rik <octave@nomad.inbox5.com>
date Sat, 17 Jul 2010 19:53:01 -0700
parents
children 0306e572c686
comparison
equal deleted inserted replaced
10790:01f1643dfbb1 10791:3140cb7a05a1
1 #!/usr/bin/perl -w
2
3 ################################################################################
4 # File : add_to_aspell_dict
5 # Purpose: Merges a file of new words into an existing dictionary file.
6 # The resulting file is uniquified and sorted before being written out.
7 # Usage : add_to_aspell_dict <filename_of_new_words>
8 ################################################################################
9 # Initialize variables
10 # Private Octave dictionary for Aspell
11 $octdict_fname = './doccheck/aspell-octave.en.pws';
12
13 ################################################################################
14 # Parse command line arguments
15 if (@ARGV != 1)
16 {
17 die "USAGE: add_to_aspell_dict <filename_of_new_words>\n";
18 }
19
20 $new_words_fname = shift(@ARGV);
21 if (!-r $new_words_fname)
22 {
23 die "Unable to read input file: $new_words_fname\n";
24 }
25
26 ################################################################################
27 # Add new words to a dictionary database
28 open (FH, "<$new_words_fname") or die "Unable to open file: $new_words_fname\n";
29 while (<FH>) { $dict_db{$_} = 1; }
30 close (FH);
31
32 # Add words from existing dictionary to dictionary database
33 open (FH, "<$octdict_fname") or die "Unable to open Octave dictionary: $octdict_fname\n";
34 $header = <FH>;
35 while (<FH>) { $dict_db{$_} = 1; }
36 close (FH);
37
38 # Remove old dictionary file and write out new one
39 unlink ($octdict_fname) or die "Unable to delete Octave dictionary: $octdict_fname\n";
40 open (FH, ">$octdict_fname") or die "Unable to open file for writing: $octdict_fname\n";
41 print FH $header;
42 print FH sort keys(%dict_db);
43 close (FH);
44