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

[REBOL] Spell

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 -><- -- Attached file included as plaintext by Listar -- -- File: Spell.r [ Rebol [ Name: 'Spell Title: "Spell Checker and Corrector" File: %Spell.r Home: 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