⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch29_05.htm

📁 the unix power tools
💻 HTM
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 29] 29.5 Adding Words to ispell's Dictionary </TITLE><METANAME="DC.title"CONTENT="UNIX Power Tools"><METANAME="DC.creator"CONTENT="Jerry Peek, Tim O'Reilly &amp; Mike Loukides"><METANAME="DC.publisher"CONTENT="O'Reilly &amp; Associates, Inc."><METANAME="DC.date"CONTENT="1998-08-04T21:45:05Z"><METANAME="DC.type"CONTENT="Text.Monograph"><METANAME="DC.format"CONTENT="text/html"SCHEME="MIME"><METANAME="DC.source"CONTENT="1-56592-260-3"SCHEME="ISBN"><METANAME="DC.language"CONTENT="en-US"><METANAME="generator"CONTENT="Jade 1.1/O'Reilly DocBook 3.0 to HTML 4.0"><LINKREV="made"HREF="mailto:online-books@oreilly.com"TITLE="Online Books Comments"><LINKREL="up"HREF="ch29_01.htm"TITLE="29. Spell Checking, Word Counting, and Textual Analysis"><LINKREL="prev"HREF="ch29_04.htm"TITLE="29.4 Inside spell "><LINKREL="next"HREF="ch29_06.htm"TITLE="29.6 Counting Lines, Words, and Characters: wc "></HEAD><BODYBGCOLOR="#FFFFFF"TEXT="#000000"><DIVCLASS="htmlnav"><H1><IMGSRC="gifs/smbanner.gif"ALT="UNIX Power Tools"USEMAP="#srchmap"BORDER="0"></H1><MAPNAME="srchmap"><AREASHAPE="RECT"COORDS="0,0,466,58"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="467,0,514,18"HREF="jobjects/fsearch.htm"ALT="Search this book"></MAP><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch29_04.htm"TITLE="29.4 Inside spell "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 29.4 Inside spell "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><B><FONTFACE="ARIEL,HELVETICA,HELV,SANSERIF"SIZE="-1">Chapter 29<BR>Spell Checking, Word Counting, and Textual Analysis</FONT></B></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch29_06.htm"TITLE="29.6 Counting Lines, Words, and Characters: wc "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 29.6 Counting Lines, Words, and Characters: wc "BORDER="0"></A></TD></TR></TABLE>&nbsp;<HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="SECT1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-4092">29.5 Adding Words to ispell's Dictionary </A></H2><PCLASS="para"><SPANCLASS="link"><EMCLASS="emphasis">ispell</EM> (<ACLASS="linkend"HREF="ch29_02.htm"TITLE="Check Spelling Interactively with ispell ">29.2</A>)</SPAN>uses two lists for spelling verification:a master wordlistand a supplemental personal wordlist.<ACLASS="indexterm"NAME="AUTOID-32088"></A><ACLASS="indexterm"NAME="AUTOID-32090"></A><ACLASS="indexterm"NAME="AUTOID-32093"></A><ACLASS="indexterm"NAME="AUTOID-32095"></A><ACLASS="indexterm"NAME="AUTOID-32098"></A><ACLASS="indexterm"NAME="AUTOID-32100"></A></P><PCLASS="para">The master wordlist for <EMCLASS="emphasis">ispell</EM> is normally the file<EMCLASS="emphasis">/usr/local/lib/ispell/ispell.hash</EM>.This is a &quot;hashed&quot;dictionary file.That is, it has beenconverted to a condensed, program-readable form usingthe <EMCLASS="emphasis">buildhash</EM> program (which comes with <EMCLASS="emphasis">ispell</EM>), to speed the spell-checking process.</P><PCLASS="para">The personal wordlist is normally a file called <EMCLASS="emphasis">.ispell_words</EM> in yourhome directory.(You can override this default with either the <EMCLASS="emphasis">-p</EM>command-line option or the <EMCLASS="emphasis">WORDLIST</EM> <SPANCLASS="link">environment variable (<ACLASS="linkend"HREF="ch06_01.htm#UPT-ART-1170"TITLE="What Environment Variables Are Good For ">6.1</A>)</SPAN>.)This file is simply a list of words, one per line, so you canreadily edit it to add, alter, or remove entries.The personal wordlist is normally used in addition to themaster wordlist, so if a word usage is permitted by either list it isnot flagged by <EMCLASS="emphasis">ispell</EM>.</P><PCLASS="para">Custom personal wordlists are particularly useful for checking documents thatuse jargon, or special technical words that are not in the masterwordlist, and for personal needs such as holding the names of yourcorrespondents. You may choose to keep more than one custom wordlist,to meet various special requirements.</P><PCLASS="para">You can add to your personal wordlist any time you use<EMCLASS="emphasis">ispell</EM>: simply use the I command to tell <EMCLASS="emphasis">ispell</EM> that theword it offered as a misspelling is actually correct, and should beadded to the dictionary.You can also add a list of words from afile using the <EMCLASS="emphasis">ispell&nbsp;-a</EM> option.The words must be one to aline, but need not be sorted.Each word to be added must be precededwith an asterisk.(Why?Because <EMCLASS="emphasis">ispell&nbsp;-a</EM> has other functionsas well.)So, for example, we could have added a list of UNIX utilitynames to our personal dictionaries all at once, rather than one byone as they were encountered during spell-checking.</P><PCLASS="para">Obviously, though, in an environment where many people are workingwith the same set of technical terms, it doesn't make sense for eachindividual to add the same word list to his or her own private<EMCLASS="emphasis">.ispell_words</EM> file.It would make far more sense for a groupto agree on a common dictionary for specialized terms and always toset <EMCLASS="emphasis">WORDLIST</EM> to point to that common dictionary.</P><PCLASS="para">If the private wordlist gets too long, you can create a &quot;munched&quot; wordlist.The<ACLASS="indexterm"NAME="AUTOID-32124"></A><EMCLASS="emphasis">munchlist</EM> script that comes with <EMCLASS="emphasis">ispell</EM>reduces the names in a wordlist to a set ofword roots and permitted suffixes according to rules described in the<EMCLASS="emphasis">ispell</EM>(4) reference page that will be installed with<EMCLASS="emphasis">ispell</EM> from the CD-ROM.This creates amore compact but still editable wordlist.</P><PCLASS="para">Another option is to provide an alternative master spelling list usingthe <EMCLASS="emphasis">-d</EM> option.This has two problems, though:</P><OLCLASS="orderedlist"><LICLASS="listitem"><PCLASS="para">The master spelling list should include spellings that are alwaysvalid, regardless of context. You do not want to overload your masterwordlist with terms that might be misspellings in a differentcontext. For example, <EMCLASS="emphasis">perl</EM> is a powerful programming language,but in other contexts, <EMCLASS="emphasis">perl</EM> might be a misspelling of<EMCLASS="emphasis">pearl</EM>.You may want to place <EMCLASS="emphasis">perl</EM> in a supplementalwordlist when documenting UNIX utilities, but probably wouldn't want itin the master wordlist unless you are documenting UNIX utilities mostof the time that you use <EMCLASS="emphasis">ispell</EM>.</P></LI><LICLASS="listitem"><PCLASS="para">The <EMCLASS="emphasis">-d</EM> option must point to a hashed dictionary file.This is alarge file and time-consuming to build.What's more, you cannot edit ahashed dictionary; you will have to edit a master word list and use (or<ACLASS="indexterm"NAME="AUTOID-32143"></A>have the system administrator use) <EMCLASS="emphasis">buildhash</EM> to hash the newdictionary to optimize spelling checker performance.</P></LI></OL><PCLASS="para">To build a new hashed wordlist, provide <EMCLASS="emphasis">buildhash</EM> with acomplete list of the words you want included, one per line.(The <EMCLASS="emphasis">buildhash</EM> utility can onlyprocess a raw wordlist, not a munched wordlist.)The standard system wordlist, <EMCLASS="emphasis">/usr/dict/words</EM> on many systems, canprovide a good starting point.This file is writeable onlyby the system administrator, and probably shouldn't be changed in anycase.So make a copy of this file, and edit or add to the copy.After processingthe file with <EMCLASS="emphasis">buildhash</EM>, you can either replace the default <EMCLASS="emphasis">ispell.hash</EM> file, or point to your new hashed file with the <EMCLASS="emphasis">-d</EM>option.<ACLASS="indexterm"NAME="AUTOID-32153"></A></P><DIVCLASS="sect1info"><PCLASS="SECT1INFO">- <SPANCLASS="authorinitials">TOR</SPAN>, <SPANCLASS="authorinitials">LK</SPAN></P></DIV></DIV><DIVCLASS="htmlnav"><P></P><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch29_04.htm"TITLE="29.4 Inside spell "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 29.4 Inside spell "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="book"HREF="index.htm"TITLE="UNIX Power Tools"><IMGSRC="gifs/txthome.gif"SRC="gifs/txthome.gif"ALT="UNIX Power Tools"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch29_06.htm"TITLE="29.6 Counting Lines, Words, and Characters: wc "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 29.6 Counting Lines, Words, and Characters: wc "BORDER="0"></A></TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172">29.4 Inside spell </TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="index"HREF="index/idx_0.htm"TITLE="Book Index"><IMGSRC="gifs/index.gif"SRC="gifs/index.gif"ALT="Book Index"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172">29.6 Counting Lines, Words, and Characters: wc </TD></TR></TABLE><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><IMGSRC="gifs/smnavbar.gif"SRC="gifs/smnavbar.gif"USEMAP="#map"BORDER="0"ALT="The UNIX CD Bookshelf Navigation"><MAPNAME="map"><AREASHAPE="RECT"COORDS="0,0,73,21"HREF="../index.htm"ALT="The UNIX CD Bookshelf"><AREASHAPE="RECT"COORDS="74,0,163,21"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="164,0,257,21"HREF="../unixnut/index.htm"ALT="UNIX in a Nutshell"><AREASHAPE="RECT"COORDS="258,0,321,21"HREF="../vi/index.htm"ALT="Learning the vi Editor"><AREASHAPE="RECT"COORDS="322,0,378,21"HREF="../sedawk/index.htm"ALT="sed &amp; awk"><AREASHAPE="RECT"COORDS="379,0,438,21"HREF="../ksh/index.htm"ALT="Learning the Korn Shell"><AREASHAPE="RECT"COORDS="439,0,514,21"HREF="../lrnunix/index.htm"ALT="Learning the UNIX Operating System"></MAP></DIV></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -