How to test NPC Parser: Difference between revisions

Jump to navigation Jump to search
Content deleted Content added
imported>MartinFuchs
describe matching types
imported>Pinch
m Changed words.xml location
 
(42 intermediate revisions by 4 users not shown)
Line 6: Line 6:
__TOC__
__TOC__


After you designed a new NPC conversation, you have to implement it in the server code and test if the NPC understands all user input like you planed. To support you in this process there is the NPC Conversation Parser Test Environment (PTE):
After you designed a new NPC conversation, you have to implement it in the server code and test if the NPC understands all the user input like you planned. If you have not already looked at the guides for [[Stendhal NPC Coding]] and [[Stendhal Quest Coding]], these could be helpful.

If during testing you find that the NPC is not responding as you expect, you should first check that the flow of conversation states is correct. If you are using standard Producer, Buyer or Seller code, this is already likely correct. Otherwise, the [[Stendhal_Quest_Coding_-_Part_2#Ask_the_players_whether_they_will_do_the_quest|quest tutorial]] covers the theory and how to test it.

After the conversation states are confirmed correct, you can check is that the NPC is correctly interpreting ''(parsing)'' what the player says. To support you in this process there is the NPC Conversation Parser Test Environment (PTE):


[[Image:npc parser testenv.png]]
[[Image:npc parser testenv.png]]




You can launch the dialog with the script "runpte.sh" on Unix/Mac and with "runbte.bat" on windows. This will compile the server and tools part, then launch the Java dialog. It may be even easier or you to run it directly from Eclipse by launching the class games.stendhal.tools.npcparsertestenv.TestEnvDlg .
You can launch the dialog with the script "runpte.sh" on Unix/MacOS and with "runbte.bat" on windows. This will compile the server and tools part, then launch the Java dialog. It may be even easier or you to run it directly from Eclipse by launching the class games.stendhal.tools.npcparsertestenv.TestEnvDlg .


The dialog displays how the conversation parser interprets user input and gives a hint about not yet known words. You can choose one of the predefined example sentences or write your own text into the input field. This way you can design the NPC conversations and test how the parser reacts on user input. You can see how the parser interprets the text, recognizes the words and merges them to longer expressions. Each expression is assigned an expression type like OBJect, SUBject, VERb or ADJective. If the parser discovers any unknown words, the surrounding expression is displayed in red color. You should add these new words to the word list "words.txt", located in the package "games.stendhal.server.entity.npc.parser" .
The dialog displays how the conversation parser interprets user input and gives a hint about not yet known words. You can choose one of the predefined example sentences or write your own text into the input field. This way you can design the NPC conversations and test how the parser reacts on user input. You can see how the parser interprets the text, recognizes the words and merges them to longer expressions. Each expression is assigned an expression type like OBJect, SUBject, VERb or ADJective. If the parser discovers any unknown words, the surrounding expression is displayed in red color. You should add these new words to the word list "words.txt", located in the package "games.stendhal.common.parser" .


In the right window section there are visible the fields Subject, Object, Verb, ... . If the expression type is unique in the sentence, you can immediately see the respective expressions. Otherwise you see the number of expression types.
In the right window section there are visible the fields Subject, Object, Verb, ... . If the expression type is unique in the sentence, you can immediately see the respective expressions. Otherwise you see the number of expression types.
Line 26: Line 30:
if you use exact matching, it does not match:
if you use exact matching, it does not match:


* Standard matching compares the normalized expressions (not looking at concrete item numbers for example).
* Joker matching allows to use "*" wildcards as placeholder for arbitrary expressions.
* Joker matching allows to use "*" wildcards as placeholder for arbitrary expressions.
* Exact matching only matches sentences if all of the expressions in the sentence exactly match them in the match string.
* Exact matching only matches sentences if all of the expressions in the sentence exactly match them in the match string.
* Case insensitive matching behaves like exact matching, but does not look on upper/lower case.
* Case insensitive matching behaves like exact matching, but does not look on upper/lower case.
* Similarity matching allows the user some spelling errors. It matches if there are not too many character differences in each of the constituting words of the user input string.
* Similarity matching allows the user some spelling errors. It matches if there are not too many character differences in each of the constituting words of the user input string.
* Controlled matching allows to specify the matching type by leading type flags like "|JOKER|", "|SIMILAR|" or "|EXACT|ICASE|".
* Type expression matching only compares expression types. (TODO: find a good example)
* Merged expression matching compares the normalized expressions, not looking at e.g. concrete item numbers.


If you use any of this extended matching types in your code, it may be helpful to use the matching string, e.g. "|JOKER|buy * bananas" in the display field.
If you use any of this extended matching types in your code, it may be helpful to use the matching string, e.g. "|JOKER|buy * bananas" in the display field.