Subject: LambdaMoo server programming

From: [email-masked] (Donald Bora)
Date: Fri, 24 Sep 1993 07:18:47 -0700

Has anyone out there messed around with the Lambda server code.  I am 
thinking about making some modifications to the code and was wondering
if anyone has made changes and knows the code.

				Just curious.

-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Donald F. Bora                            |                    |     | 
The Institute for the Learning Sciences   |                    |  O  |
Northwestern University                   |                    (--|--)
Evanston, Ill                             |                       | 
e-mail: [email-masked]                 |                      / \
work:   (708) 467-1972                    |  
             --------Be excellent to each other--------

---

From: [email-masked]
Date: Fri, 24 Sep 1993 08:27:02 -0700

Can someone please tell me how to use Mr. Spell?  It's sitting in the
LambdaCore distribution, but for the life of me I can't figure out
it's verb interface.  :-)

---

From: Judy Anderson <[email-masked]>
Date: Fri, 24 Sep 1993 09:24:29 -0700

Well, we managed to get Mr. Spell without the supporting user verbs.
Here are the supporting verbs that need to go on a player class.
(There may be more; others should feel free to post additional bits of
script that need to be executed.)

@verb $player:"@addword @adddict"   any any any
@program $player:@addword
set_task_perms(player);
if (verb == "@adddict" && !(player in $spell.trusted || player.wizard))
  player:tell("You may not add to the master dictionary. The following words
will instead by put in a list of words to be approved for later addition to the
dictionary. Thanks for your contribution.");
endif
if (!argstr)
  player:notify(tostr("Usage: ", verb, " one or more words"));
  player:notify(tostr("       ", verb, " object:verb"));
  player:notify(tostr("       ", verb, " object.prop"));
elseif (data = $spell:get_input(argstr))
  num_learned = 0;
  for i in [1..length(data)]
    line = $string_utils:words(data[i]);
    for ii in [1..length(line)]
      if (seconds_left() < 2)
        suspend(0);
      endif
      if (verb == "@adddict")
        result = $spell:add_word(line[ii]);
        if (result == E_PERM)
          if ($spell:find_exact(line[ii]) == $failed_match)
            player:notify(tostr("Submitted for approval:  ", line[ii]));
            $spell:submit(line[ii]);
          else
            player:notify(tostr("Already in dictionary:  " + line[ii]));
          endif
        elseif (typeof(result) == ERR)
          player:notify(tostr(result));
        elseif (result)
          player:notify(tostr("Word added:  ", line[ii]));
          num_learned = num_learned + 1;
        else
          player:notify(tostr("Already in dictionary:  " + line[ii]));
        endif
      elseif (!$spell:valid(line[ii]))
        player.dict = listappend(player.dict, line[ii]);
        player:notify(tostr("Word added:  ", line[ii]));
        num_learned = num_learned + 1;
      endif
    endfor
  endfor
  player:notify(tostr(num_learned ? num_learned | "No", " word", num_learned !=
1 ? "s " | " ", "added to ", verb == "@adddict" ? "main " | "personal ",
"dictionary."));
endif
.
@verb $player:"@spell @cspell @complete"   any any any
@program $player:@spell
"@spell a word or phrase  -- Spell check a word or phrase.";
"@spell thing.prop  -- Spell check a property. The value must be a string or a
list of strings.";
"@spell thing:verb  -- Spell check a verb. Only the quoted strings in the verb
are checked.";
"@cspell word  -- Spell check a word, and if it is not in the dictionary,
offset suggestions about what the right spelling might be. This actually works
with thing.prop and thing:verb too, but it is too slow to be useful--it takes
maybe 30 seconds per unknown word.";
"@complete prefix  -- List all the word in the dictionary which begin with the
given prefix. For example, `@complete zoo' lists zoo, zoologist, zoology, and
zoom.";
"";
"Mr. Spell was written by waffle ([email-masked]), for use by";
"MOOers all over this big green earth. (....and other places....)";
"This monstrosity programmed Sept-Oct 1991, when I should have been studying.";
set_task_perms(player);
if (!argstr)
  if (verb == "@complete")
    player:notify(tostr("Usage: ", verb, " word-prefix"));
  else
    player:notify(tostr("Usage: ", verb, " object.property"));
    player:notify(tostr("       ", verb, " object:verb"));
    player:notify(tostr("       ", verb, " one or more words"));
  endif
elseif (verb == "@complete")
  if ((foo = $string_utils:from_list($spell:sort($spell:find_all(argstr)), "
")) == "")
    player:notify(tostr("No words found that begin with `", argstr, "'"));
  else
    player:notify(tostr(foo));
  endif
else
  "@spell or @cspell.";
  corrected_words = {};
  data = $spell:get_input(argstr);
  if (data)
    misspelling = 0;
    for i in [1..length(data)]
      line = $spell:words(data[i]);
      for ii in [1..length(line)]
        if (ticks_left() < 1000 || seconds_left() < 2)
          suspend(0);
        endif
        if (!$spell:valid(line[ii]))
          if (rindex(line[ii], "s") == length(line[ii]) &&
$spell:valid(line[ii][1..length(line[ii]) - 1]))
            msg = "Possible match: " + line[ii];
            msg = msg + " " + (length(data) != 1 ? "(line " + tostr(i) + ")  "
| "  ");
          elseif (rindex(line[ii], "'s") == length(line[ii]) - 1 &&
$spell:valid(line[ii][1..length(line[ii]) - 2]))
            msg = "Possible match: " + line[ii];
            msg = msg + " " + (length(data) != 1 ? "(line " + tostr(i) + ")  "
| "  ");
          else
            misspelling = misspelling + 1;
            msg = "Unknown word: " + line[ii] + (length(data) != 1 ? " (line "
+ tostr(i) + ")  " | "  ");
            if (verb == "@cspell" && !(line[ii] in corrected_words))
              corrected_words = listappend(corrected_words, line[ii]);
              guesses = $string_utils:from_list($spell:guess_words(line[ii]), "
");
              if (guesses == "")
                msg = msg + "-No guesses";
              else
                msg = msg + "-Possible correct spelling";
                msg = msg + (index(guesses, " ") ? "s: " | ": ");
                msg = msg + guesses;
              endif
            endif
          endif
          player:notify(tostr(msg));
        endif
      endfor
    endfor
    player:notify(tostr("Found ", misspelling ? misspelling | "no", "
misspelled word", misspelling == 1 ? "." | "s."));
  elseif (data != $failed_match)
    player:notify(tostr("Nothing found to spellcheck!"));
  endif
endif
.
@verb $player:"@rmword"   any any any
@program $player:@rmword
set_task_perms(player);
if (argstr in player.dict)
  player.dict = setremove(player.dict, argstr);
  player:notify(tostr("`", argstr, "' removed from personal dictionary."));
else
  player:notify(tostr("`", argstr, "' not found in personal dictionary."));
endif
@verb $player:"@rmdict"   any any any
@program $player:@rmdict
set_task_perms(player);
result = $spell:remove_word(argstr);
if (result == E_PERM)
  player:notify("You may not remove words from the main dictionary. Use
`@rmword' to remove words from your personal dictionary.");
elseif (typeof(result) == ERR)
  player:notify(tostr(result));
elseif (result)
  player:notify(tostr("`", argstr, "' removed."));
else
  player:notify(tostr("`", argstr, "' not found in dictionary."));
endif
.