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

📄 ch29_01.htm

📁 the unix power tools
💻 HTM
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 29] Spell Checking, Word Counting, and Textual Analysis</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:44:59Z"><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="part04.htm"TITLE="IV. Looking Inside Files "><LINKREL="prev"HREF="ch28_15.htm"TITLE="28.15 Show Changes in a troff File with diffmk "><LINKREL="next"HREF="ch29_02.htm"TITLE="29.2 Check Spelling Interactively with ispell "></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="ch28_15.htm"TITLE="28.15 Show Changes in a troff File with diffmk "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 28.15 Show Changes in a troff File with diffmk "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><B><FONTFACE="ARIEL,HELVETICA,HELV,SANSERIF"SIZE="-1">Chapter 29</FONT></B></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch29_02.htm"TITLE="29.2 Check Spelling Interactively with ispell "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 29.2 Check Spelling Interactively with ispell "BORDER="0"></A></TD></TR></TABLE>&nbsp;<HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="CHAPTER"><H1CLASS="chapter"><ACLASS="title"NAME="UPT-CHP-29">29. Spell Checking, Word Counting, and Textual Analysis</A></H1><DIVCLASS="htmltoc"><P><B>Contents:</B><BR><ACLASS="sect1"HREF="#UPT-ART-4080"TITLE="29.1 The UNIX spell Command ">The UNIX spell Command </A><BR><ACLASS="sect1"HREF="ch29_02.htm"TITLE="29.2 Check Spelling Interactively with ispell ">Check Spelling Interactively with ispell </A><BR><ACLASS="sect1"HREF="ch29_03.htm"TITLE="29.3 How Do I Spell That Word? ">How Do I Spell That Word? </A><BR><ACLASS="sect1"HREF="ch29_04.htm"TITLE="29.4 Inside spell ">Inside spell </A><BR><ACLASS="sect1"HREF="ch29_05.htm"TITLE="29.5 Adding Words to ispell's Dictionary ">Adding Words to ispell's Dictionary </A><BR><ACLASS="sect1"HREF="ch29_06.htm"TITLE="29.6 Counting Lines, Words, and Characters: wc ">Counting Lines, Words, and Characters: wc </A><BR><ACLASS="sect1"HREF="ch29_07.htm"TITLE="29.7 Count How Many Times Each Word Is Used ">Count How Many Times Each Word Is Used </A><BR><ACLASS="sect1"HREF="ch29_08.htm"TITLE="29.8 Find a a Doubled Word ">Find a a Doubled Word </A><BR><ACLASS="sect1"HREF="ch29_09.htm"TITLE="29.9 Looking for Closure ">Looking for Closure </A><BR><ACLASS="sect1"HREF="ch29_10.htm"TITLE="29.10 Just the Words, Please ">Just the Words, Please </A></P><P></P></DIV><DIVCLASS="sect1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-4080">29.1 The UNIX spell Command </A></H2><PCLASS="para">The <EMCLASS="emphasis">spell</EM> command reads one or more files and prints a list of wordsthat may be misspelled.<ACLASS="indexterm"NAME="UPT-ART-4080-IX-SPELL-CHECKING"></A><ACLASS="indexterm"NAME="AUTOID-31777"></A><ACLASS="indexterm"NAME="AUTOID-31781"></A><ACLASS="indexterm"NAME="AUTOID-31785"></A>You can redirect the output to a file, use<SPANCLASS="link"><EMCLASS="emphasis">grep</EM> (<ACLASS="linkend"HREF="ch27_01.htm#UPT-ART-7420"TITLE="Different Versions of grep ">27.1</A>)</SPAN>to locate each of the words, and then use <EMCLASS="emphasis">vi</EM> or <EMCLASS="emphasis">ex</EM> to make the edits.It's also possible to hack up a shell and <EMCLASS="emphasis">sed</EM> script thatinteractively displays the misspellings and fixes them on command,but realistically, this is too tedious for most users.(The<SPANCLASS="link"><EMCLASS="emphasis">ispell</EM> (<ACLASS="linkend"HREF="ch29_02.htm"TITLE="Check Spelling Interactively with ispell ">29.2</A>)</SPAN>program solves many&nbsp;- though not all&nbsp;- of these problems.)</P><PCLASS="para">When you run <EMCLASS="emphasis">spell</EM> on a file, the list of words it produces usuallyincludes a number of legitimate words or terms that the program doesnot recognize.<EMCLASS="emphasis">spell</EM> is case-sensitive; it's happy with <EMCLASS="emphasis">Aaron</EM> butcomplains about <EMCLASS="emphasis">aaron</EM>.You must cull out the proper nouns and other words <EMCLASS="emphasis">spell</EM> doesn'tknow about to arrive at a list of true misspellings.For instance, look at the results on this sample sentence:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">Alcuin uses TranScript to convert ditroff intoPostScript output for the LaserWriter printerr.$ <CODECLASS="userinput"><B>spell sample</B></CODE>AlcuinditroffprinterrLaserWriterPostScriptTranScript</PRE></BLOCKQUOTE></P><PCLASS="para">Only one word in this list is actually misspelled.</P><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-31805"></A><ACLASS="indexterm"NAME="AUTOID-31807"></A><ACLASS="indexterm"NAME="AUTOID-31810"></A>On many UNIX systems, you can supply a local dictionary file so that <EMCLASS="emphasis">spell</EM>recognizes special words and terms specific to your site or application.After you have run <EMCLASS="emphasis">spell</EM> and looked through the word list, you cancreate a file containing the words that were not actual misspellings.The <EMCLASS="emphasis">spell</EM> command will check this listafter it has gone through its own dictionary.[On systems where I've used it, your word list file had to be<SPANCLASS="link">sorted (<ACLASS="linkend"HREF="ch36_01.htm#UPT-ART-7640"TITLE="Putting Things in Order ">36.1</A>)</SPAN>.-<EMCLASS="emphasis">JP</EM>&nbsp;]</P><PCLASS="para">If you added the special terms in a file named <EMCLASS="emphasis">dict</EM>, you couldspecify that file on the command line using the <CODECLASS="literal">+</CODE> option:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">$ <CODECLASS="userinput"><B>spell +dict sample</B></CODE>printerr</PRE></BLOCKQUOTE></P><PCLASS="para">The output is reduced to the single misspelling.</P><PCLASS="para">The <EMCLASS="emphasis">spell</EM> command will also miss words specified as arguments to<SPANCLASS="link"><EMCLASS="emphasis">nroff</EM> or <EMCLASS="emphasis">troff</EM> macros (<ACLASS="linkend"HREF="ch43_13.htm"TITLE="The Text Formatters nroff, troff, ditroff, ... ">43.13</A>)</SPAN>,and like any spelling checker, will make some errors based on incorrectderivation of spellings from the root words contained in its dictionary.If you understand <SPANCLASS="link">how <EMCLASS="emphasis">spell</EM> works (<ACLASS="linkend"HREF="ch29_04.htm"TITLE="Inside spell ">29.4</A>)</SPAN>,you may be less surprised by someof these errors.</P><DIVCLASS="sect1info"><PCLASS="SECT1INFO">- <SPANCLASS="authorinitials">DD</SPAN> <SPANCLASS="bibliomisc">from <CITECLASS="citetitle">UNIX Text Processing</CITE>, Hayden Books, 1987</SPAN></P></DIV></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="ch28_15.htm"TITLE="28.15 Show Changes in a troff File with diffmk "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 28.15 Show Changes in a troff File with diffmk "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_02.htm"TITLE="29.2 Check Spelling Interactively with ispell "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 29.2 Check Spelling Interactively with ispell "BORDER="0"></A></TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172">28.15 Show Changes in a troff File with diffmk </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.2 Check Spelling Interactively with ispell </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 + -