I'm trying to make a script that will take out the majority of the articles and prepositions in a room description leaving only nouns and verbs in order to create a list of things that can be looked at in a room. It works fine, I was just wondering if anyone knew a better way to do it. The script i have is rather lengthy.
first I copy the room description into the variable 'room'
first I copy the room description into the variable 'room'
<aliases>
<alias
script="examine_array"
match="examine"
enabled="y"
sequence="100"
>
</alias>
</aliases>
sub examine_array(name, output, wilds)
dim items, i, rest
rest = ""
items = split(world.GetVariable("room"))
for i = 1 to Ubound(items)
select case items(i)
case "a"
case "the"
case "an"
case "you"
case "is"
case "if"
case "was"
case "be"
case "To"
case "see"
case "and"
case "there"
case "There"
case "You"
case "A"
case "The"
case "are"
case "with"
case "within"
case "without"
case "where"
case "come"
case "that"
case "read"
case "learn"
case else rest = rest + " " + items(i)
end select
next
world.note rest
end sub
my actual script has almost 100 words it looks for
Australia Forum Administrator
#1
This might be quicker and easier to maintain.
I used a regular expression to replace the words in your room description by a space, and then used the MUSHclient "replace all" to replace multiple spaces with one space (in case two came in a row).
For ease of maintenance you could keep the target words in a variable themselves.
eg.
regEx.Pattern = "\\b(" & GetVariable ("words") & ")\\b"
The "\\b" is used to mark a "word boundary" (like space, comma, period etc.) so it doesn't strip the "a" out of the middle of words.
Here is the alias:
<aliases>
<alias
match="examine"
enabled="y"
send_to="12"
sequence="100"
>
<send>Set regEx = New RegExp
regEx.Pattern = "\\b(a|the|an|you|is|if|was|be|to|see|and|the)\\b"
regEx.IgnoreCase = True
regEx.Global = True
result = regEx.Replace(GetVariable ("room"), " ")
Set regEx = nothing
world.note world.Replace (result, " ", " ", vbTrue)</send>
</alias>
</aliases>
Example of use:
Original description
You stand inside the Darkhaven Academy, an establishment designed to teach the basics of play inside this game. Each room has a specific purpose and contains information on the various commands to maneuver around and interact with the players. We recommend you explore the Academy in full, taking the time to read the instructions in each room.
After applying "examine"
stand inside Darkhaven Academy, establishment designed teach basics of play inside this game. Each room has specific purpose contains information on various commands maneuver around interact with players. We recommend explore Academy in full, taking time read instructions in each room.
USA
#2
Thank you very much! I put my word list into a variable as you suggested and it works great, thanks again.