|
gim Newbie
Joined: 10 Aug 2005 Posts: 6
|
Posted: Wed Aug 10, 2005 8:03 pm
Parsing a Line and map the Nouns in it |
Hi there!
Im wondering how i can parse a whole line and add all the nouns(always with a capital letter in germany) into an array/string list. Yes, I am trying to build a quest script.
my dirty solution is:
#REGEX {([A-Z]+[a-z]+)} {#additem wordlist %1} "" {case}
for lines that contain ONE noun
and
#REGEX {([A-Z]+[a-z]+).*([A-Z]+[a-z]+)} {
#additem wordlist %1;
#additem wordlist %2} "" {case}
for lines that contain TWO nouns
and so on...
i know i can trigger all nouns with:
#TRIGGER {[A-Z][a-z]} {} "" {case}
but that doesn't help since zmud cannot map the triggered items afaik
waiting impatiently for help .. thanks in advance :)
gim |
|
|
|
Vitae Enchanter
Joined: 17 Jun 2005 Posts: 673 Location: New York
|
Posted: Thu Aug 11, 2005 12:10 am |
might help to have a few examples of the mud output for quests.
I can't help ya, but someone might be able to if they see examples |
|
|
|
gim Newbie
Joined: 10 Aug 2005 Posts: 6
|
Posted: Thu Aug 11, 2005 6:33 am |
alright, here we go with an example:
mud output:
Du stehst in einem grossen, schwarzen Wuerfel. Allerdings kannst du nichts
Besonderes hier entdecken, ausser einem kleinen, weissen Zettel auf dem Boden.
what i like to do is: save all words with capital letters into a string-list ->
Du|Wuerfel|Allerdings|Besonderes|......
how do i parse each line of the mud output for saving the capitalized words?
gim |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Thu Aug 11, 2005 8:58 am |
You will have to produce another #TRIGGER or #ALIAS that turns on the class with #T+ and clears the variable. As well as something that turns it off again with #T-
#CLASS QuestCapture {disable}
#VAR Capitalized {} {}
#TRIGGER {*} {Capitalized=%concat(@Capitalized,"|",%replace(%line," ","|"))}
#TRIGGER {^$} {#FORALL @Capitalized {#IF (%ascii("%i")>90) {#DELITEM Capitalized {%i}}}}
#CLASS 0 |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
gim Newbie
Joined: 10 Aug 2005 Posts: 6
|
Posted: Thu Aug 11, 2005 3:17 pm |
didn't work for me, but thanks for help
based on your idea i tried this:
#TRIGGER {*} {
#var zeile %replace( %replace( %replace( %replace( %replace( %replace( %line, " ", "|"), "."), ","), "?"), "!"), ":") {} {forschen}; //removes . and , and that stuff from the line
#FORALL @zeile {#IF (%ascii( %i)>90) {#DELITEM zeile {%i}}};
//removes items that start with ascii>90
#FORALL @zeile {#ADDITEM WortListe {%i}}
//adds items from zeile to WortListe without duplicates!
}
it's much better than my first try but if i type in "look" and get some lines from the mud it ONLY saves the nouns from the last line.. why is that??
gim |
|
|
|
TonDiening GURU
Joined: 26 Jul 2001 Posts: 1958 Location: Canada
|
Posted: Thu Aug 11, 2005 7:18 pm |
Untested ideas
How about changing the trigger pattern to #TRIGGER {*$} and try and ensure you are triggering on a line.
With the overhead of the 2 #FORALL, maybe try a #additem zeile %replace(... as you might be overwriting zeile with the speed of the input.
That or capture the entire paragraph first then send it for processing. |
|
|
|
gim Newbie
Joined: 10 Aug 2005 Posts: 6
|
Posted: Thu Aug 11, 2005 7:49 pm |
how do i capture a whole paragraph?
|
|
|
|
TonDiening GURU
Joined: 26 Jul 2001 Posts: 1958 Location: Canada
|
Posted: Fri Aug 12, 2005 1:16 am |
What does your mudoutput look like some lines before and after a paragraph?
ie:
L33T>
You are located in a large, black cube. However you cannot discover anything special here, except a small, white note on the soil.
No obvious exits:
L33T> |
|
|
|
gim Newbie
Joined: 10 Aug 2005 Posts: 6
|
Posted: Fri Aug 12, 2005 8:10 am |
something like this.. sorry for the german language.
Der grosse Raum mit seiner niedrigen Decke und den grob geschnittenen
Querbalken hat Platz fuer sehr viele Personen. Knarrende Dielen erzaehlen
ueber Heldentaten laengst vergessener Abenteurer, beruehmter als mancher
Weise unserer Zeit.
Abenteurer, aber auch andere Bewohner dieser Welt kommen hierher, um
sich zu informieren, ihre Erfahrungen auszutauschen oder sich in den
verschiedensten Wissenschaften zu verbessern.
Durch die immer offene Tuer scheint die aufgehende Sonne herein und fuellt
den Raum mit ihrem goldenen Licht. Sonst gibt es hier nur noch den Ausgang
im Westen, welcher hinaus in die Welt fuehrt und Bilder an den Waenden,
mit Zeichnungen und Gemaelden vom TestSilber@micha. Eins der Bilder erlaeutert
die Funktion der Gilde und eine grosse Uhr an der Wand zeigt, was die
Stunde schlaegt.
Es gibt einen sichtbaren Ausgang: westen. //exits
Merlin, der Urvater aller Magier. //stuff in the room
Ein Zettel mit Hinweisen.
Eine Zeitung.
> |
|
|
|
TonDiening GURU
Joined: 26 Jul 2001 Posts: 1958 Location: Canada
|
Posted: Fri Aug 12, 2005 12:42 pm |
You didn`t provide something that could be used determine where a paragraph/room description starts so I`ll default with your prompt.
We can search continuously from your prompt till we see the line about the visible exits then we send off what was captured to a processing alias:
#TRIGGER "ParagraphGrabber" {^~>} {#temp ParagraphGrabberEnd {^Es gibt einen sichtbaren Ausgang} {#co 31;#state ParagraphGrabber 0;ProcessParagraphGrabber}}
#COND {} {#additem V_ParagraphGrabber %line} {looppat}
All the captured lines get added into V_ParagraphGrabber and are processed by ProcessParagraphGrabber.
Changed it a little to remove %null entries and to remove your prompt if we capture it. Its goal is to stack the possibles into zeile then stacks WortListe with the capitalized words. You probably can simpify things.
#ALIAS ProcessParagraphGrabber {#var zeile %replace( %replace( %replace( %replace( %replace( %replace( %replace( %replace( {@V_ParagraphGrabber}, " ", "|"), "."), ","), "?"), "!"), ":"), ">"), "||") _nodef {forschen};#var V_ProcessParagraphGrabber %null;#FORALL @zeile {#IF (%ascii( %i)>90) {#DELITEM zeile {%i}}};#FORALL @zeile {#ADDITEM WortListe {%i}}}
Something like that should work. |
|
|
|
|
|