Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Spell

 [1/6] from: al::bri::xtra::co::nz at: 22-Jan-2001 15:21


My Spell checker and correcter software (and sample dictionary) is attached. It's used in your Rebol script (this is from my eText - web site creation software) like this: Create: has [NameSpace Extension Name Text][ NameSpace: make block! 3000 foreach File read %. [ if found? Extension: find File %.txt [ Name: to string! copy/part File Extension Text: spell read File repend NameSpace [Name Definitions Text Text] ] ] NameSpace ] In the line: Text: spell read File the string read from 'File is interactively spell-checked and corrected with the user, then returned to 'Text:. The directory/file structure that I use is like this: %/c/Rebol/Units/Spell.r %/c/Rebol/Units/Spell/Dictionary.txt Suggestions for improvements all gratefully accepted. Andrew Martin ICQ: 26227169 http://members.nbci.com/AndrewMartin/ -><- -- Attached file included as plaintext by Listar -- -- File: Spell.r [ Rebol [ Name: 'Spell Title: "Spell Checker and Corrector" File: %Spell.r Home: http://members.nbci.com/AndrewMartin/Rebol/Units/Spell.r Author: "Andrew Martin" eMail: [Al--Bri--xtra--co--nz] Date: 22/Jan/2001 ] Spell!: make object! [ Directory: join wd %Spell/ File: %Dictionary.txt Dictionary: make block! 0 Ignored: make block! 0 Additions: make block! 0 error? try [Dictionary: make hash! sort/case load Directory/:File] Lower: charset [#"a" - #"z"] Upper: charset [#"A" - #"Z"] Alpha: union Upper Lower set 'Spell function [ {Spell checks and corrects (with user interaction) the text supplied.} Text [string!] ][ WordStart WordEnd Original Correction Before After Cancelled ][ parse/case/all Text [ some [ WordStart: [some Alpha opt [[{'} | {-}] some Alpha]] WordEnd: ( Before: copy/part WordStart -29 Original: copy/part WordStart WordEnd After: copy/part WordEnd +29 Correction: copy Original if not Cancelled [ if not found? any [ find/case Ignored Original find/case Additions Original find/case Dictionary Original ][ view layout [ across label "Not in Dictionary:" return text Before field Correction text After return button "Ignore" [ unview/all ] button "Ignore All" [ append Ignored Original unview/all ] return button "Add" [ append Additions Original unview/all ] button "Change" [ WordEnd: change/part WordStart Correction WordEnd unview/all ] button "Change All" [ replace/case/all WordStart Original Correction unview/all ] button "Cancel" [ Cancelled: yes unview/all ] return button "Quit" [ quit ] ] ] ] ) :WordEnd | skip ] ] if not any [ Cancelled empty? Additions ][ append Dictionary Additions clear Additions save Directory/:File make block! sort/case Dictionary ] Text ] ] ] -- Attached file included as plaintext by Listar -- -- File: Dictionary.txt America "American" "Americans" "April" "Benedictine" "Berlin" "British" "Christian" "Christmas" "Colonel" "Count" "Death" "December" "Dodo" "Dr" "English" "French" "Frenchman" "Frenchwoman" "German" "Germans" "Germany" "God" "Greek" "Gutenberg" "Gutenberg's" "Humor" "Hush" "I" "I'd" "I'll" "I'm" "I've" "Illinois" "Indian" "Irish" "Italian" "Italy" "Jupiter" "Latin" "London" "Major" "March" "March's" "Marches" "Marches'" "Mass" "May" "May's" "Miss" "Misses" "Monday" "Mr" "Mrs" "Napoleon" "November" "October" "Oh" "Paris" "Pickwick" "Pilgrim's" "Plato" "President" "Professor" "Professor's" "Rome" "Saturday" "Shakespeare" "St" "Switzerland" "Thursday" "Tuesday" "Washington" "West" "Yankee" "Yankees" "York" "a" "abandon" "abashed" "abject" "able" "abominable" "about" "above" "abroad" "abruptly" "absence" "absent" "absent-minded" "absently" "absorbed" "absurd" "accent" "accept" "accepted" "accepting" "accident" "accidents" "accompanied" "accomplished" "accomplishments" "accordi! ng" "account" "accounts" "accused" "accustomed" "ache" "ached" "aches" "aching" "acquaintance" "acquaintances" "acquainted" "across" "act" "acted" "acting" "active" "actors" "actually" "add" "added" "adding" "addition" "address" "adieu" "administered" "admiration" "admire" "admired" "admiring" "admission" "adore" "adored" "adorned" "advantage" "adventures" "advice" "advise" "advised" "afar" "affair" "affairs" "affect" "affectation" "affected" "affection" "affectionate" "affections" "afflicted" "affliction" "afford" "afforded" "afghan" "afire" "afraid" "after" "afternoon" "afternoons" "afterward" "again" "against" "age" "ages" "aggravated" "agitated" "ago" "agree" "agreeable" "agreed" "aid" "ain't" "air" "airing" "airs" "airy" "alarmed" "alas" "alike" "alive" "all" "allow" "allowed" "alluded" "almost" "alone" "along" "aloud" "already" "also" "altered" "although" "altogether" "always" "am" "amazed" "amazement" "amazingly" "ambition" "ambitious" "amiable" "amiss" "among" "amoun! t" "amuse" "amused" "amusement" "amusing" "an" "ancient" "and! angel" "angelic" "angels" "anger" "angrily" "angry" "anguish" "ankle" "announced" "another" "answer" "answered" "answers" "anticipations" "antique" "anxiety" "anxious" "anxiously" "any" "anybody" "anyone" "anything" "anyway" "anywhere" "apart" "apiece" "apology" "apparently" "appeal" "appealing" "appear" "appearance" "appeared" "appeased" "appetite" "applause" "apple" "apples" "apply" "approached" "approaching" "appropriate" "approval" "approve" "approving" "approvingly" "apron" "apt" "arch" "ardent" "ardor" "are" "aren't" "argument" "aristocratic" "arm" "armed" "arms" "army" "arose" "around" "arrange" "arranged" "arrangement" "array" "arrested" "arrive" "arrived" "art" "artful" "article" "articles" "artist" "artistic" "artistically" "artless" "as" "ashamed" "aside" "ask" "asked" "asking" "asleep" "asparagus" "aspect" "assembled" "assert" "associate" "association" "assumed" "assurances" "assure" "assured" "astonish" "astonished" "astonishing" "at" "ate" "atmosphere" "aton! e" "attack" "attempt" "attempts" "attend" "attention" "attentions" "attitude" "attitudes" "attracted" "attraction" "attractive" "audacity" "audience" "aunt" "aunt's" "aunts" "author" "authoress" "autumn" "aversion" "avoid" "awake" "away" "awful" "awkward" "aye" "babies" "baby" "baby's" "back" "backs" "bad" "bade" "badly" "bag" "bags" "ball" "ballroom" "balm" "band" "bangs" "banisters" "bank" "banks" "bare" "bargain" "barrel" "barricade" "bars" "basely" "bashful" "bashfulness" "basket" "baskets" "bay" "be" "beach" "beads" "beam" "beamed" "beaming" "bear" "beard" "bearing" "bears" "beat" "beautified" "beautiful" "beautifully" "beauty" "became" "because" "beckoned" "become" "becomes" "becoming" "bed" "bedside" "bee" "beef" "been" "beer" "bees" "before" "beforehand" "beg" "began" "begged" "begging" "begin" "beginning" "begins" "begun" "behave" "behaved" "behavior" "beheld" "behind" "behold" "being" "beings" "belief" "beliefs" "believe" "believed" "believing" "bell" "belle" "bell! s" "belong" "belonged" "beloved" "below" "bend" "bending" "be! nefit" "benignant" "benignly" "bent" "bereft" "beside" "besides" "best" "betray" "betrayed" "better" "between" "bewildered" "bewilderment" "beyond" "bib" "bid" "big" "bigger" "bill" "bills" "bind" "bird" "birds" "birthday" "bit" "bits" "bitter" "bitterly" "bitterness" "black" "blame" "blancmange" "blandly" "blank" "blaze" "bless" "blessed" "blessing" "blessings" "blew" "blighted" "blind" "blindly" "bliss" "blissful" "blissfully" "blithe" "blithely" "blonde" "blood" "bloom" "bloomed" "blossom" "blossomed" "blotted" "blow" "blowing" "blown" "blows" "blue" "blunder" "blundered" "blunt" "blush" "blushed" "blushing" "boat" "boating" "boats" "body" "boiled" "bold" "boldly" "bolted" "bonbons" "bonnet" "bonnets" "bonnie" "book" "books" "boot" "boots" "bore" "born" "borne" "borrow" "borrowed" "bosom" "both" "bother" "bottle" "bottles" "bottom" "bought" "bounce" "bounced" "bound" "bouquet" "bouquets" "bow" "bowed" "bower" "box" "boxes" "boy" "boy'" "boy's" "boyish" "boys" "boys'" "bra! celet" "brain" "brave" "bravely" "breach" "bread" "breadth" "break" "breakfast" "breaking" "breaks" "breast" "breath" "breathlessly" "breeding" "bribe" "bridal" "bride" "bridegroom" "bridge" "brief" "bright" "bright-eyed" "brighten" "brightened" "brightening" "brilliancy" "brilliant" "bring" "bringing" "brings" "brisk" "briskly" "broad" "broke" "broken" "brood" "broom" "brooms" "brother" "brotherly" "brothers" "brought" "brow" "brown" "brows" "brush" "brushed" "brute" "bud" "budding" "buds" "built" "bunch" "bundle" "bundled" "bundles" "burden" "burdened" "burdens" "bureau" "buried" "burn" "burned" "burning" "burr" "burst" "bushes" "bushy" "busily" "business" "bustle" "busts" "busy" "but" "butter" "button" "buttonhole" "buttonholes" "buttons" "buy" "buying" "by" "by-and-by" "cage" "cake" "call" "called" "calling" "calls" "calm" "calmly" "came" "camp" "can" "can't" "cane" "cannot" "cap" "capital" "capitally" "caps" "captain" "captivating" "captive" "card" "cards" "care" "cared! careful" "carefully" "careless" "cares" "caressed" "carnel! ian" "carpet" "carriage" "carriages" "carried" "carrol" "carry" "carrying" "carved" "case" "cases" "cast" "castle" "castles" "cat" "catch" "catching" "cats" "caught" "cause" "caused" "cave" "ceased" "celestial" "cellar" "ceremonies" "ceremony" "certain" "certainly" "chains" "chair" "chairs" "chance" "change" "changed" "changes" "changing" "chanting" "chaotic" "chapel" "chapter" "character" "characteristic" "characters" "charge" "charity" "charm" "charmed" "charming" "charms" "chateau" "chatted" "chattered" "chatting" "cheap" "cheat" "check" "checked" "cheek" "cheeks" "cheer" "cheered" "cheerful" "cheerfully" "cheerfulness" "cheering" "cheers" "cheery" "cherished" "cherub" "chest" "chestnut" "chests" "chicken" "chief" "child" "childish" "children" "children'" "children's" "chilly" "chimney" "chin" "china" "chirp" "chirped" "chocolate" "choke" "choose" "chorus" "chose" "chosen" "chubby" "church" "cigar" "circle" "circumstances" "city" "civil" "claim" "clapped" "clashed" "clasp! ed" "class" "clay" "cleaned" "clear" "cleared" "clearer" "clever" "climate" "climb" "climbed" "cling" "clinging" "cloak" "clock" "close" "closed" "closely" "closet" "clothes" "cloud" "clouds" "club" "clumsy" "clung" "coal" "coat" "cocked" "coffee" "cold" "collar" "collars" "collected" "collecting" "college" "cologne" "color" "colored" "colors" "colt" "come" "comes" "comfort" "comfortable" "comfortably" "comforted" "comforting" "comforts" "comical" "coming" "commanded" "commander" "commanding" "comment" "common" "companion" "company" "compared" "complacently" "complain" "complained" "complaining" "complete" "compliment" "compliments" "compose" "composed" "computer" "conceal" "concealed" "concerts" "conclusion" "condition" "cones" "conferred" "confess" "confessed" "confidante" "confided" "confidence" "confidences" "confidential" "confiding" "confidingly" "confinement" "confounded" "confusion" "congratulate" "congratulating" "congratulations" "conquer" "conquered" "conquering" ! conscience "conscious" "consciousness" "consent" "consented! conservatory" "consider" "considered" "consolation" "console" "consoled" "consolingly" "constant" "constantly" "consult" "contained" "content" "contented" "continent" "continually" "continued" "contrary" "contrast" "contrasted" "contribution" "contributions" "control" "conversation" "conversations" "conviction" "convulsed" "cook" "cooking" "cool" "cooled" "copied" "copies" "copy" "copyright" "coquettish" "cordial" "cordially" "corner" "corner'" "corners" "correct" "cost" "costs" "costume" "costumes" "cotton" "could" "couldn't" "countenance" "country" "couple" "couples" "courage" "course" "cover" "covered" "covering" "covers" "coveted" "cozy" "crash" "crazy" "cream" "created" "creation" "creature" "creatures" "credit" "crept" "cricket" "cried" "crimson" "croak" "croaked" "crop" "croquet" "cross" "crossly" "crow" "crowning" "cruel" "crumpled" "crushed" "crutch" "cry" "crying" "cuddled" "cultivated" "cup" "cups" "cure" "curiosity" "curious" "curl" "curls" "curly" "curtain" "! curtained" "curtains" "cushion" "cut" "cutting" "daily" "dainty" "daisies" "daisy" "damage" "damaged" "damages" "damp" "dance" "danced" "dances" "dancing" "danger" "dangerous" "dare" "dared" "daring" "dark" "darkened" "darkly" "darling" "das" "dash" "dashing" "date" "daughter" "daughters" "daunted" "dawdle" "dawdling" "dawn" "day" "day's" "days" "de" "dead" "deaf" "deal" "dear" "dear'" "dearer" "dearest" "dearly" "dears" "deary" "debt" "debts" "deceive" "decide" "decided" "decidedly" "decision" "declare" "declared" "declaring" "declined" "deep" "deepest" "deeply" "deer" "defects" "defend" "defended" "defied" "degree" "delay" "delicate" "delicious" "delight" "delighted" "delightful" "delightfully" "delights" "deliver" "delivered" "delusion" "demand" "demanded" "demanding" "demijohn" "departed" "departing" "departure" "depend" "depended" "depends" "deportment" "describe" "described" "description" "desert" "deserted" "deserve" "deserved" "desirable" "desire" "desired" "desires"! "desk" "despair" "despairing" "despairingly" "desperate" "de! sperately" "despise" "despite" "despondent" "detained" "determined" "deuce" "devices" "devote" "devoted" "devoting" "devotion" "diamonds" "dickens" "did" "didn't" "die" "died" "dies" "difference" "different" "difficult" "difficulties" "difficulty" "dig" "dignified" "dignity" "dilapidated" "diligently" "dim" "dining" "dinner" "directions" "directly" "dirt" "dirty" "disagreeable" "disappeared" "disappoint" "disappointed" "disappointment" "discontented" "discover" "discovered" "discoveries" "discovery" "discretion" "discussing" "discussion" "disgrace" "disgraced" "disgust" "disgusted" "dish" "dishes" "disheveled" "disk" "disliked" "dismal" "dismally" "dismay" "dispatched" "display" "displayed" "displaying" "displeased" "disposed" "distance" "distant" "distracted" "distracting" "distressed" "distribute" "disturb" "disturbed" "ditto" "diverted" "divine" "do" "docile" "doctor" "does" "doesn't" "dog" "dogs" "doing" "doll" "dollar" "dollars" "dolls" "domain" "domestic" "domino" "don! 't" "donations" "done" "doom" "door" "double" "doubt" "doubts" "dovecote" "down" "downcast" "downstairs" "dozen" "drag" "dragged" "dramatic" "drank" "draped" "draw" "drawer" "drawing" "drawn" "dread" "dreaded" "dreadful" "dreadfully" "dream" "dreamed" "dreaming" "dreams" "dreary" "dress" "dressed" "dresses" "dressing" "drew" "dried" "drink" "drive" "driven" "droll" "drop" "dropped" "dropping" "drops" "drove" "drunk" "dry" "drying" "dull" "dumb" "during" "dusk" "dust" "dusty" "duties" "dutiful" "dutifully" "duty" "dying" "each" "eager" "eagerly" "ear" "early" "earn" "earned" "earnest" "earnestly" "earnestness" "earnings" "earrings" "ears" "earth" "earthly" "earthquake" "ease" "easier" "easily" "east" "easy" "eat" "eaten" "eating" "echo" "echoed" "editor" "education" "effect" "effective" "effectually" "effort" "efforts" "eight" "eighteen" "either" "elbows" "elder" "elders" "eldest" "electrified" "electronically" "elegance" "elegant" "element" "eleven" "eloquence" "eloquent" "e! lse" "elsewhere" "elves" "embrace" "emerged" "emotion" "emoti! ons" "employed" "empty" "encourages" "encouraging" "end" "ended" "ends" "enemies" "enemy" "energetic" "energetically" "energy" "engaged" "engagement" "engaging" "enjoy" "enjoyed" "enjoying" "enlightened" "enough" "enter" "entered" "entertain" "enthusiasm" "enthusiastic" "entire" "entirely" "entry" "enveloped" "envy" "equal" "equally" "equivalent" "erect" "errand" "errands" "escape" "escaped" "escort" "escorted" "especial" "especially" "establishment" "etext" "etexts" "eve" "even" "evening" "evenings" "event" "events" "ever" "everlasting" "every" "everybody" "everybody's" "everyone" "everything" "everywhere" "evident" "evidently" "evil" "exact" "exactly" "examine" "examined" "examining" "example" "exasperating" "excel

 [2/6] from: al:bri:xtra at: 22-Jan-2001 16:04


These files are now on my site at: http://members.nbci.com/AndrewMartin/Rebol/ Andrew Martin ICQ: 26227169 http://members.nbci.com/AndrewMartin/

 [3/6] from: rphilipp:suffolk:lib:ny:us at: 22-Jan-2001 7:20


Andrew, Tried your url, The site says that the page has not yet been created. Robert P.

 [4/6] from: al:bri:xtra at: 23-Jan-2001 8:05


Robert P. wrote:
> > These files are now on my site at: > > http://members.nbci.com/AndrewMartin/Rebol/ > Andrew, > Tried your url, The site says that the page has not yet been created.
Silly NBCi! It's ignoring me! I've checked with my FTP software and it's there. Looks like NBCi have changed their settings to disable directory browsing. I'm going to have to be more subtle... Try this address to get the zip: http://members.nbci.com/_XMCM/andrewmartin/Rebol/Rebol.zip and I'll have to work out a better scheme for distribution. Suggestions gratefully accepted. Thanks Robert, for letting me know. Andrew Martin ICQ: 26227169 http://members.nbci.com/AndrewMartin/

 [5/6] from: d4marcus:dtek:chalmers:se at: 23-Jan-2001 22:43


On Mon, 22 Jan 2001, Andrew Martin wrote:
> My Spell checker and correcter software (and sample dictionary) is attached.
I think it's wonderful! There's a lot of potential there. But there is at least one bug in there which I'm not able to fix. For example, after doing Spell "Python" and replacing Python with Rebol it asks you about "ebol". This only happens when the new word is shorter than the original word, and only for the last word. Someone here should be able to fix it.
> Suggestions for improvements all gratefully accepted.
Well, I took the freedom to make some modifications. I thought it would be nice to make the graphical UI optional, so I seperated it from the 'Spell function. Now someone just need to make an UI for the console. Sorry, didn't have time myself. ;-) Also made some style changes in the GUI. For the better hopefully. The I thought it would be nice to be able to enhance 'Spell with extra rules. So I've added the /extra refinement which takes a block to use as the first parsed rule. Check 'Spell-HTML for an example how it works. This function matches tags, urls and emails. Simply ignoring them ATM, but of course actions can be added to the rule if you need. Anyway, here's the new code: Rebol [ Name: 'Spell Title: "Spell Checker and Corrector" File: %Spell.r ] wd: %./ ;insert your Spell directory path here Spell!: make object! [ Directory: join wd %Spell/ if not exists? Directory [make-dir Directory] File: %Dictionary.txt Dictionary: make block! 0 Ignored: make block! 0 Additions: make block! 0 error? try [Dictionary: make hash! sort/case load Directory/:File] Lower: charset [#"a" - #"z"] Upper: charset [#"A" - #"Z"] Alpha: union Upper Lower WordMatch: [some Alpha opt [[{'} | {-}] some Alpha]] WordStart: WordEnd: Original: Correction: Before: After: Cancelled: None Show-GUI: function [] [ face1 orig cfield b-a b-c b-c* ] [ face1: layout [ across label "Not in Dictionary:" return text Before orig: text Original yellow 'bold text After return text "Change: " cfield: field Correction [ either any [empty? Correction (Correction = Original)] [ orig/font/color: yellow show [orig b-a] hide [b-c b-c*] ] [ orig/font/color: red show [orig b-c b-c*] hide b-a] ] return button "Ignore" #"^i" [ hide-popup ] button "Ignore All" [ append Ignored Original hide-popup ] return b-a: button "Add" #"^a" [ append Additions Original hide-popup ] b-c: button "Change" #"^c" [ WordEnd: change/part WordStart Correction WordEnd hide-popup ] b-c*: button "Change All" [ replace/case/all WordStart Original Correction hide-popup ] return button "Cancel" #"^[" orange [ Cancelled: yes hide-popup ] button "Quit" #"^Q" red [ quit ] ] face1/text: "Spell Checker" show-popup face1 hide [b-c b-c*] do-events/only face1 ] set 'Spell func [ {Spell checks and corrects (with user interaction) the text supplied.} Text [string!] /extra {Extra rule to match before matching words. The rule may of course include actions.} rule [block!] ][ Cancelled: no if not extra [rule: " "] parse/case/all Text [ some [rule | WordStart: WordMatch WordEnd: ( Before: copy/part WordStart -29 Original: copy/part WordStart WordEnd After: copy/part WordEnd +29 Correction: copy Original if not Cancelled [ if not found? any [ find/case Ignored Original find/case Additions Original find/case Dictionary Original ][ Show-GUI ] ] ) :WordEnd | skip ] ] if not any [ Cancelled empty? Additions ][ append Dictionary Additions clear Additions save Directory/:File make block! sort/case Dictionary ] Text ] ] Spell-HTML!: make object! [ alpha: copy Spell!/Alpha non-space: complement charset " ^-^/" to-space: [some non-space | end] tag: ["<" thru ">"] url: [some alpha ":/" to-space] email: [some [alpha | integer! | "."] "@" to-space] rule: [tag | url | email] set 'Spell-HTML func [ {Spell checks and corrects (with user interaction) the HTML supplied.} Text [string!] ][ Spell/extra Text rule ] ] Marcus ------------------------------------ If you find that life spits on you calm down and pretend it's raining

 [6/6] from: d4marcus:dtek:chalmers:se at: 24-Jan-2001 22:39


On Tue, 23 Jan 2001, Marcus Petersson wrote:
> Well, I took the freedom to make some modifications. I thought it would be > nice to make the graphical UI optional, so I seperated it from the 'Spell > function. Now someone just need to make an UI for the console. Sorry,
But now there is one! It is called with the refinement /cons (for console mode). 'Spell/cons works with Rebol/Core. I've even tested it with a 2MB elisp.html file and it seems to work fine. Didn't bother to check all of it though. ;-) Anyway, here's the new code: Rebol [ Name: 'Spell Title: "Spell Checker and Corrector" File: %Spell.r ] wd: %./ ;insert your Spell directory path here Spell!: make object! [ Directory: join wd %Spell/ if not exists? Directory [make-dir Directory] File: %Dictionary.txt Dictionary: make block! 0 Ignored: make block! 0 Additions: make block! 0 error? try [Dictionary: make hash! sort/case load Directory/:File] Lower: charset [#"a" - #"z"] Upper: charset [#"A" - #"Z"] Alpha: union Upper Lower WordMatch: [some Alpha opt [[{'} | {-}] some Alpha]] WordStart: WordEnd: Original: Correction: Before: After: Cancelled: None Change-word: func [/all] [ either all [replace/case/all WordStart Original Correction] [ WordEnd: change/part WordStart Correction WordEnd]] Text-UI: function [] [ same s-a s-c cons edit char buffer ] [ s-c: {^(1B)[KIgnore (Tab) Ignore All (^^x) Change (^^g) Change All (^^h)} same: yes prin "^(1B)[5A^(1B)[K" ; go up 4 lines and clear print [Before " |-> " Original " <-| " After] print s-a: {^(1B)[KIgnore (Tab) Ignore All (^^x) Add (^^a)} print {Edit (Enter) Cancel (^^d) Quit (^^c)^/^/} cons: open/binary [scheme: 'console] while [ wait cons char: to-char first cons ] [ switch char [ #"^-" [break] #"^X" [append Ignored Original break] #"^A" [if same [append Additions Original break]] #"^G" [if not same [Change-word break]] #"^H" [if not same [Change-word/all break]] #"^M" [prin "^(1B)[AChange: ^(1B)[K" Correction: input if not empty? Correction [remove system/console/history] prin "^(1B)[4A" ; go up 4 lines same: any [empty? Correction (Correction = Original)] either same [print s-a] [print s-c] prin "^(1B)[2B" ; go down 2 lines if same [prin "^(1B)[K"] prin "^(1B)[B" ; go down 1 line ] #"^D" [Cancelled: yes break] #"^C" [quit] ] ] close cons ] Show-GUI: function [] [ face1 orig cfield b-a b-c b-c* ] [ face1: layout [ across label "Not in Dictionary:" return text Before orig: text Original yellow 'bold text After return text "Change: " cfield: field Correction [ either any [empty? Correction (Correction = Original)] [ orig/font/color: yellow show [orig b-a] hide [b-c b-c*] ] [ orig/font/color: red show [orig b-c b-c*] hide b-a] ] return button "Ignore" #"^I" [ hide-popup ] button "Ignore All" #"^X" [ append Ignored Original hide-popup ] return b-a: button "Add" #"^A" [ append Additions Original hide-popup ] b-c: button "Change" #"^G" [ Change-word hide-popup ] b-c*: button "Change All" #"^H" [ Change-word/all hide-popup ] return button "Cancel" #"^D" orange [ Cancelled: yes hide-popup ] button "Quit" #"^C" red [ quit ] ] face1/text: "Spell Checker" show-popup face1 hide [b-c b-c*] do-events/only face1 ] strip-newlines: func [strings [block!]] [ foreach s strings [replace/all s "^/" " "]] set 'Spell func [ {Spell checks and corrects (with user interaction) the text supplied.} Text [string!] /cons {Use the console UI instead of View GUI.} /extra {Extra rule to match before matching words. The rule may of course include actions.} rule [block!] ][ Cancelled: no if not extra [rule: " "] if cons [print "^/^/^/^/^/"] parse/case/all Text [ some [rule | WordStart: WordMatch WordEnd: ( Before: copy/part WordStart -25 Original: copy/part WordStart WordEnd After: copy/part WordEnd +25 Correction: copy Original if not Cancelled [ if not found? any [ find/case Ignored Original find/case Additions Original find/case Dictionary Original ][ either cons [strip-newlines reduce [Before After] Text-UI] [Show-GUI] ] ] ) :WordEnd | skip ] ] if not any [ Cancelled empty? Additions ][ append Dictionary Additions clear Additions save Directory/:File make block! sort/case Dictionary ] Text ] ] Spell-HTML!: make object! [ alpha: copy Spell!/Alpha non-space: complement charset " ^-^/" to-space: [some non-space | end] tag: ["<" thru ">"] url: [some alpha ":/" to-space] email: [some [alpha | integer! | "."] "@" to-space] rule: [tag | url | email] set 'Spell-HTML func [ {Spell checks and corrects (with user interaction) the HTML supplied.} Text [string!] /cons {Use the console UI instead of View GUI.} ][ either cons [Spell/cons/extra Text rule] [Spell/extra Text rule] ] ] Marcus ------------------------------------ If you find that life spits on you calm down and pretend it's raining