SpellingCorrector/PatternCompleterEditedbyTeitelmanonNovember3,198211:23amDIRECTORYGeneratorUSING[Handle],RopeUSING[ROPE];Spell:CEDARDEFINITIONS=BEGINGeneralcommentsThisinterfacesupportstwodistinctoperations,spellingcorrectionandpatterncompletion.Spellingcorrectioninvolvesattemptingtotransformanunrecognizedrope,calledtheunknown,intoaknownrope,whichisamemberofsomecomputablesetofropes,accordingtovariousheuristics,e.g.removalofdoubledcharacters,transpositions,caseerrors,etc.Forexample,correctCompilletoCompile(doubledcharacter),UsrExecImpltoUserExecImpl(missingcharacter),ViewerOsptoViewerOps(transposition).Patterncompletioninvolvestransformingtheunknownropeintoaknowncandidateorcandidatesusingspecifiedtransformations.(Currentlytheonlypatternsupportedis*,whichmatchesanysequenceofcharacters.Inthefuture,allpatternsrecognizedbytheTiogaEditToolwillbesupported.)Therearetwowaystocallthispackage.Inthefirstcase,theclienthasinhandanunknownropeandwantstofindthesinglecorrectropethatitspecifies.Theunknownropemaybeamisspellingofsomecandidateinthesourceofcandidates(seediscussionofsourcesbelow),oritmaybeapatternwhichuniquelyspecifiesthedesiredcandidate,e.g.theusermighttypeR*.profileinacontextwhereafilenamewasrequired,knowingthatthisissufficienttobeunambiguous.Inordertopermittheclientnottohavetodistinguishthesetwocases,asingleprocedure,GetTheOne,isprovided.Inthecasethattheunknownisapattern,GetTheOnecallsthepatternmatcher,andiftheresultinglistconsistsofasinglecandidate,returnsthatcandidate,otherwiseGetTheOnereturnsNIL(i.e.iftherearezeroormorethanonesuccessfulmatches).Iftheunknownisnotapattern,thenactualspellingcorrectionwillbeperformed.Ineithercase,iftheuser'sprofilehassoindicatedasdescribedbelow,theuserwillbeinformedoftheaction,orconfirmationwillberequestedbeforetheactionistaken.Theseconduseofthispackageoccurswhentheclienthasinhandanunknownandwantsallcandidatesthatmatchit,i.e.,alistofropes.Again,theunknownmaybeapattern,orsimplyamisspelling.Forexample,theusermighttypetotheuserexecDelete*.mesa$,orDeleteFooo.mesa.Inordertopermittheclientnottohavetodistinguishthesetwocases,thereisasingleprocedure,GetMatchingList,whichhandlesbothcases.Iftheunknownisapattern,GetMatchingListreturnsalistofallcandidatesthatmatchthepattern,ifamisspelling,GetMatchingListreturnsalistconsistingofthesinglecorrectspelling(ifoneisfound,otherwisereturnNIL).sourcesofcandidatesforcorrection/completionForbothGetTheOneandGetMatchingList,thesourceofcandidatescaneitherbeaLISTOFROPE,orageneratorwhichproducesROPEs.GeneratorscanbeeasilycreatedusingCreateGeneratorasdescribedbelow.Forbothcases,anoptionalfilterpredicatecanbespecifiedwhichcanbeusedtoselectoutasubsetofthecandidatesforconsideration.ConfirmationandmessagesforspellingcorrectionSpellingcorrectionisdividedintothreeclassesinorderofdecreasingcertainty:(1)correctionsinvolvingcaseerrorsonly,(2)correctionsinwhichallmistakesareaccountedfor,i.e.,theonlymistakesaredoubledcharactersortranspositions,e.g.,typingcompilleorcompielforcompile(butnotcompil),(3)correctionsinwhichtherearesome(albeitveryfew)actualerrors,i.e.,extraneouscharactersoromittedcharacters.p b&0L!V%'w-/6*7:>q ^r ]q]z]r]'] [jq[j[jr[jqD[jrU[j Ys V\r }V\qzV\EV\ rdV\q Rrs N,t Ky K5 ! (^- 4t7p0C D   #)a 0(7F9@ C4 ! #?%+.127D=t?1 E A #l&+2&35e9?AG ? [K 's)o+/258: =c Wt.o#$'X*;-/36A7;=~CF ; }n #z$ *-369;= D<E :> !$ +",168:4=T?`@E 8m` #t&(+/2 9;h<AEG% 6 \F!U" (*t,g 5J7:<@CWG 5  u!l"&| -T 5?6=P?AxDdG/ 3wuY"m$)/@13b5;p=BDuE 1 {/ $,N1468-;> ABFi 0( +%'=)+n04>8= DG . -!2HR#M'*|,e2~4Q:?+ADG ,r6 "[%&-81379k *V >S!X%'T+-q/24i:q=@B (  {#}%,/81?279>?O F '6=A^ &"*0/26s =?CcE %` DjP #c&)-L./3 :E # `s!"#)389<=? F "V` B)./1 89<?Dy j rCmu  :lt F `%n',<. 47j;f=f>BND  c:# +-04'95=$G  f:%9(.u028<?@D*E P a s  u  F " t += "Q&(K+- 4[ :s< C   o"b$6)+2J47=9<AD+ L"')H.s058;#@yB 5 ;)q #'+. 5y ;=B  TVm$(Thecaseofpatterncompletionisconsideredtofallbetweencase(1)and(2).)Theusercanindependentlycontrolwhichclassesofcorrectionsconfirmationisrequiredfor,forwhichclassesheistobeinformed,orevenforwhichclassesofcorrectionsthespellingcorrectorisenabledatall,byappropriatesettingsfortheparametersconfirm,inform,anddisabled(whicharepackagedintoasinglerecordoftypeModes,describedbelow).Thevalueofdisabledisanenumeratedtype{never,someMistakes,allAccountedFor,patternMatch,caseError,always},whichspecifiesthatcorrectionsaredisabledforthatclassandallclassesthatprecedeitintheenumeratedtype.Forexample,ifdisabledissomeMistakes,thencompillewillbecorrectedtocompile,butcompilwon't,becauseithasamissingcharacterandhencefallsintotheclasssomeMistakes.Ifdisabledisalways,thenthecorrectoristurnedoffcompletely.Similarly,thevalueofinformandconfirmspecifythatinforming/confirmingisrequestedforthatclassandallthatprecedeitintheenumeratedtype.Forexample,ifinformisallAccountedFor,thentheuserwillbeinformedforcorrectionsofclassallAccountedForaswellasthosewithsomeMistakes.Ifinformingisrequested,butnoinformprocedurewassuppliedinthecorrespondingcall,thensimplydonotinformtheuser.TheseparameterscanbespecifiedbyentriesintheuserprofileforSpell.Confirm,Spell.Inform,andSpell.Disabled,orexplicitlypassedinasargumentstoGetTheOneandGetMatchingList.Thedefaultsettingsaredisabled=never,confirm=allAccountedFor,inform=patternMatch.Forthosecasesforwhichconfirmationisrequested,atimeoutandadefaultvalueforconfirmationcanbespecifiedviauserprofileentriesSpell.TimeoutandSpell.DefaultConfirmrespectively.Thedefaultsettingfortimeout=-1,meaningnevertimeout.Ifconfirmationisrequested,butnoconfirmingprocedurehasbeensuppliedinthecorrespondingcall,thenthebehaviouristhesameasthoughtheuserrejectedthecorrection,i.e.didnotconfirm.Types,globalparametersROPE:TYPE=Rope.ROPE;SpellingList:TYPE=LISTOFROPE;SpellingGenerator:TYPE=REFSpellingGeneratorRecord;SpellingGeneratorRecord:TYPE=RECORD[clientData:REFANY,private:REFSpellingGeneratorPrivateRecord];SpellingGeneratorPrivateRecord:TYPE;Filter:TYPE=PROCEDURE[candidateRope:ROPE,unknown:ROPE]RETURNS[accept:BOOLEAN];--truemeansconsiderthecandidateAbortProc:TYPE=PROC;responsibleforcheckingforanabortcondition,andalsodoingtheabort.Forexample,whencalledfromUserExecUtilities.GetTheOne,thisprocedurewouldbeIFUserExec.UserAbort[exec]THENERRORUserAborted;ConfirmProc:TYPE=PROC[msg:ROPE,timeout:INT,defaultConfirm:BOOL]RETURNS[yes:BOOL];outputropetoyourfavoritestream,displayinviewer,whatever,thenrequestconfirmation.timeoutishowlongtowait,inmilliseconds,beforereturningdefault.Iftimeout=-1,thenwaitforever,i.e.usermustconfirm.InformProc:TYPE=PROC[msg:ROPE];outputtoyourfavoritestream,displayinviewer,whateverCorrectionClass:TYPE={never,someMistakes,allAccountedFor,patternMatch,caseError,always};2t b!  $n %2&).T1!3'58;J>"@ `y  ')].137<4>'?AFC9 ^ n "%M*v0[178;"=2 D ]+ ] N"1'+.:4-68;@AD [E"$'& -05 > Y  c"V'*h 1I38:=@C_E5 X5 9L "C$*,(13 <+?TDG V2K"r'(+i,17y:4>/A CF^ T # d#&+-X14 ;t AD G S??p+,3?58V;>H@>CH9 Q  !#')!37-9<?OAJGR O  U"$&*I-f 78?@r G NI B #O ,F/)2O68;;?B+ K <"&(f*.24 >X F Je o!#*i,:36AD Hq)}!#.34 E 8 "# *&+Q0h3!4K8<> G D@ - = )5,9w AD B~ $*,o 46 =q@;B @E ),/2`8:}<@B_G/ ?J q A}"gs ;& v 7r!7q77ru7[7q77r7u 4G r4Gq4G4Grl4Gq4G4Gr!4Gu 0r0q00r 0q00r0 |0u /&r/&q/&/&rY/&q!>/&"/&r&,/&&/& q-/&.u/&0Qr2/&3/&q8/&9/&r -~u +r<+q :+ +r#'+u (]rC(]qA(](]r(]q}(]%(]r(](] q&(]'(]r*(]*(]q1o(]2C(]r4(]q5g(]6;(]r;X(];(]q@p(]A)(]rF(]Fs(]p &G@u #Jr&#Jq$#J#Jr{#Jq`#J#Jr#Jp!  $b *-B0369<B<(0*0468F} u  rqSrq~rcq!"!r$3%q*+ r,. q878r;cqneverabort.confirm:ConfirmProc_NIL,--NIL=>Ifconfirmationisrequired,actasthoughusersaidNo.inform:InformProc_NIL,--NIL=>nooutput.filter:Filter_NIL,modes:Modes_NIL--NILmeansusevaluesinuserprofile]RETURNS[ROPE];GetMatchingList:PROCEDURE[pattern:ROPE,spellingList:SpellingList_NIL,--argumentssameinterpretationasforGetTheOnegenerator:SpellingGenerator_NIL,abort:AbortProc_NIL,confirm:ConfirmProc_NIL,inform:InformProc_NIL,filter:Filter_NIL,modes:Modes_NIL]RETURNS[LISTOFROPE];Note...theinterfaceUserExecUtilitiesprovidesaconvenientwayofcallingGetTheOneandGetMatchingListbyspecifyingeitheranExecHandleoraViewer.Theseprocedureswillspecifyappropriatevaluesforabort,confirm,andinformwhencallingthecorrespondingproceduresinSpell,e.g.ifgivenanExecHandle,aYesNomenuwillbepostedandtheusercanconfirmeitherviamenuorbytypingYorN.SpellingGeneratorsGeneratorFromProcs:PROC[initialize:PROCEDURE[self:SpellingGenerator]_NIL,generate:PROCEDURE[self:SpellingGenerator]RETURNS[candidate:REFANY],--mustnarrowtoROPEorREFTEXT.3u b&rb&qb&b&rSb&q8b& b&rb&!@b& u `{ r7`{q5`{`{r`{qq`{E`{r_`{^{c]&q]&]&r]&p ]&]&_ >$f'+r[{q:[{[{p[{[{ f$(o*+.034 <@7BYQy ! (-@1h24,rX)u T r TTpS)Zu%q s O du KrKqK.KrKJqJoJrJHZ _ qHZ jHZr!HZF  q!F"Fr#Fp$F%F%'T*f 14@:B<B EvF I K#$'*->0I3 ;=@/ C`Y d" )+- rA'qbAJArmApA<!b#'r@  q{@ c@ r@ p c@ @ !$')# 12{8:V<@CFLr >`* q>`>`r >`p x>`!%')r <qM<5<rX<; hq; ; pj; ;  $/&*,D/(r9`q7r7qc7rt77u 4`r<4`q:4`4`rn4`2qF22rW21 _ q1 j1 r!1 p"1 #g1 $e*.Y 68y:r/`  q!/`"/`r#/`-'qb-J-rm-,  q{, c, r, *` vq*`*`r*`(q;($(rG(' hq' ' r%_q#r#qc#HGrX##t    f&"$ +!./4g<> f   "_#(, 4 6; CGR E*C5 L%' 1, 8:>ACG   Bwf!%(W*-0f59;?ACH p s IF u rq5r K q K KrJ K K*q, K, Kr. K q  r  q* + r0 14 q7 8 :r=# = p>b > ?C% w)TVm$(terminate:PROCEDURE[self:SpellingGenerator]_NIL,--tobecalledwhenfinished.clientData:REFANY_NIL]RETURNS[SpellingGenerator];Note...thevalueofgeneratemustnarrowtoROPEorREFTEXT.IfthevaluenarrowstoaREFTEXT,aROPEwillbecreatedonlyforthosecandidatesthatthespellingcorrectorisgoingtoretainacrosscallstogenerate.Thisenablesgeneratetoreturnascratchreftextforinspection,andnothavetoallocateanewropeforeachcandidateitgenerates.GeneratorFromEnumerator:PROC[enumerator:PROC[self:Generator.Handle],clientData:REFANY]RETURNS[SpellingGenerator];Thisprocedureisusefulwhenyouhaveaprocedurethatenumerates,e.g.EnumerateGlobalFrames,andwishtouseittoprovidecandidatesforspellingcorrector.SimplywriteanenumeratorprocedurewhichusesGenerator.Produce(seeGeneratorinterfaceforanexample)toproducecandidatesfrominsideoftheenumerator,andpassthisprocedureinastheenumeratorargument.Filecorrection/completion.GetTheFile:PROC[unknown:Rope.ROPE,defaultExt:Rope.ROPE_NIL,abort:AbortProc_NIL,confirm:ConfirmProc_NIL,inform:InformProc_NIL,modes:Modes_NIL]RETURNS[correct:Rope.ROPE];Ifunknowndoesnothaveanextension,defaultExtwillbeused.IftheunknowndoesnothaveanextensionanddefaultExtisNIL,thenunknownwillonlybecomparedagainstfileswithnoextension.Ifunknownhasanextension,andtheextension(minustrailing$ifany)isnotoneofthoseonextensionList(definedbelow),firstattemptspellingcorrectiononextensionList.Ifthissucceeds,seeifthefilenameisnowcorrect,andifso,returnwithoutdoinganydirectoryenumeration.Otherwise,attemptcorrectionconsideringonlyfileswiththeindicatedextension.IftheunknownextensiondoesnotcorrespondtooneofthoseonextensionList,attemptcorrectionconsideringfileswithanyextension,i.e.boththerootandtheextensionmayormaynotbemisspelled.(Notethatthisdiffersfromtheprocedurefollowedifunknowndoesnotcontainanextension,anddefaultExtisspecified,inthatinthiscaseitisassumedthatdefaultExtiscorrect,andonlyfileswiththeindicatedextensionareexamined.)Intheeventofasuccessfulcorrection,theinformingmessagewillcontainanextensiononlyiftheunknowncontainedanextension.However,thevaluereturned,ifnon-NIL,willalwaysbethefullnameofthefile.Herearesomeexamples:GetTheFile["Mumble.mesa"]=>lookatfileswithextensionmesaforamisspellingofmumble(becauuse"mesa"isonextensionList)GetTheFile["Mumble","mesa"]=>sameasabove,exceptcorrectionmessagewillsayMumble->4rb& qb&Yb&rb&Ib&M+q,b&-b&r.b&p/b&0 b&124|8];r`u q!`u`ur`uqW`u?`ur^q^^r^J^t Z XVL"#()-=13d59v>@dAD V` '- @# *-i/4:<?AE T%$&|*,0258$ ?#ADG S'E#%@ u Or8Oq6OOr OM xMMr MlMpLL x!LLLLrJxJJrJJJt H3!$&$,/ 7%9 FnV $/&X+Y 16|9; C  D!(c.0X2Q8L:?e F( C  !$ *,Q-0_ 7s > Hu ; r;q;r;rW;9x#99r4981 7x8181r:81x8181r816'xb6J6rm64 x{4c4r43 vx33r31lhx1l1lr/x//r/J/Vx//r /!R/t + s %L , .04f58d>ADIG ) C#(+.0v6;I>"A(C 'W  A"#$*/467:ABG; $  S!"% )/.024:d B "a  !$'*V0I  K" )9*-/w3%5: =C 5 1z !#' )I,.069;u>Y@B~ ]&],-369e>S@R F    :"%'(y.0 7w8=@vCFt ?]Po  N  $a&-M25r:bBDG kv qW a" %]'*+-i37L9: BDD! _= 5 #&&(k,1/ 7=?B:Gw)TVm$]ratherthanMumble.mesa->GetTheFile["Mumble.msa"]=>correctmsatomesa,seeifmumble.mesaexists,andifnot,proceedasincase1GetTheFile["Mumble","msa"]=>onlylookatfileswithextensionmsaGetTheFile["Mumble.frob"]=>examineallfileswithnon-Nullextensions,because"frob"isnotonextensionlist.GetTheFile["Mumblefrob"]=>onlylookatfileswithnoextensionsGetMatchingFileList:PROC[unknown:Rope.ROPE,defaultExt:Rope.ROPE_NIL,abort:AbortProc_NIL,confirm:ConfirmProc_NIL,inform:InformProc_NIL,modes:Modes_NIL]RETURNS[files:LISTOFROPE];fileextensionsextensionList:SpellingList;usedinspellingcorrectionoffilenamesasdescribedbelow.initializedto(mesa,bcd,cm,config,commands,profile,df,doc,press,style,abbreviations).Theuserisfreetoaddentriestothislist.AddExtension:PROC[ext:ROPE];--addsexttoextensionList.MiscellaneousIsAPattern:PROC[unknown:ROPE]RETURNS[BOOLEAN];currentlytrueifunknowncontains*notprecededbya'END.5t b) 1  _ S$')V-$/p0 9=@8ADW ^ YH ["N%h(*-0"6A Y2 &s(|+.4 ;AEG Wi T =#W&p( *.0 u QrQqQ*QrQOx#OOr4ONQ 7xNQNQr:NQxNQNQrNQL'xbLJLrmLK x{KcKrKI[ vxI[I[rI[GhxGGrF xF F rF JF xF jF r F ! F s A u > r>u> p< !&!'-1 89=@CM;Mjf>"&g/b2%5 6u9":=]ACVEu 7 r67q377r7#7q77r7Z7p 7!U7"S%m')h s 3 u 0 rs0qq00r0a0q00r 0q!0"0r'm0q'0r-p0-0p.#$'8,/0Pq +r s+w)qTVm$"LAUREL HELVETICA TIMESROMAN TIMESROMAN TIMESROMAN TIMESROMANYLAUREL TIMESROMAN TIMESROMAN ? )($,j//- spell.mesa 9-Mar-83 23:00:59