Difference between revisions of "Tutorial for NLP"
(3 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
Natural Language Processing | Natural Language Processing | ||
+ | [https://www.dropbox.com/s/396eag04xh3c0ni/NLP.pdf?dl=0 PDF VERSION]PDF versions do not get updated as regularly | ||
(anywhere i say npl i mean nlp) | (anywhere i say npl i mean nlp) | ||
Line 241: | Line 242: | ||
− | open | + | open syntax.txt and add |
<syntaxhighlight lang="cpp"> | <syntaxhighlight lang="cpp"> | ||
#include "ai/nlp/nlp_custom.txt" | #include "ai/nlp/nlp_custom.txt" | ||
Line 279: | Line 280: | ||
cat=animation// the animation in #custom | cat=animation// the animation in #custom | ||
+ | |||
I think that's enough on the nlp | I think that's enough on the nlp | ||
+ | |||
+ | If i missed something or something is incorrect then let me know | ||
+ | |||
+ | Good luck |
Latest revision as of 03:16, 13 January 2016
Eskarn's tutorial for NLP
Adding Words and Sentences to the NLP
Natural Language Processing
PDF VERSIONPDF versions do not get updated as regularly
(anywhere i say npl i mean nlp)
This is an advanced tutorial and probably wont have pictures
How im going to do this tutorial is explain the theory on how the NPL works then cheat
after you know how the NLP works you will understand why im gonna cheat
i will be using an unpacked dungeon
How to unpack
you will need to have the brain enabled to see the responses and debug mode is always good
settings ini in main folder
runtime { start_mode = FAST; debug_sys = BASIC; debug_render = NONE; debug_phys = NONE; debug_brain = ENABLED; save_key = ""; }
pack_dungeon\ai\nlp
you will see 59 text files each text file handles different parts of the NLP
lets start with something easy
open up
nlp_actor.txt
lets take the top set
#actor = <you> : you
#actor is the variable
<you> is the word said by the player
: you is the result
this one is a little bit different
#actor = <#name> : &0
#actor is the variable
<#name> is another variable set below so we are seeing if any of those names have been said
: &0 this is saying the first #variable so #name
if the player said tiffany it would return tiffany
if they said aiko it would return aiko
lets move on to nlp_answer.txt
#answerverb = <#actor can> : yes,&0,can,present
@answerverb is the variable
<#actor can> remember the #actor from before so if the player says any of the #actor words aswell as can so "you can" "we can" "Samantha can" etc
: yes,&0,can,present this will result as
present.can.#actor.yes with #actor being what was said
well this seems easy
nlp_actor.txt
nlp_answer.txt
nlp_attr.txt
nlp_greet.txt
nlp_object.txt
nlp_question.txt
nlp_verb.txt
are the ones that have mostly single words and then a single responses
lets move on to a harder one
and we will see how this all comes together
open nlp_ac_feel.txt
now you will instantly see it becomes a lot harder
so lets take the first response
#nquestion1 = <how * #qis * #actor> : ^qn_how_ac_feel(&1,present)
#nquestion1 is the variable
<how * #qis * #actor> #qis is set in npl_question.txt and #actor we know
so #qis can be "is" "are" "am"
"how is he" "how are you" "how am Samantha"
the * mean anything so the sentence could also be "how is [that] Samantha"
"how [nice] is [this] Samantha" "how [goobly] are [pixydustinface] Samantha"
some of these don't make sense but that's why there is many responses
: ^qn_how_ac_feel(&1,present)
^qn_how_ac_feel the ^ means the variable is not set but do it anyway otherwise there would be an error saying that its not set
the qn_how_ac_feel is used later and it would be
#actor.present
now open
nlp_result.txt
and find
// Actor feel
here is where the qn_how_ac_feel is used
qn_how_ac_feel(*,*) : get (form),&0(actor),feel(attr),&1(tense)
qn_how_ac_feel(anything,anything) so basicly #actor.present
: get (form),&0(actor),feel(attr),&1(tense)
e=[get.form,#actor.actor,feel.attr,present.tense])"
#nquestion1 = <how * #qwas * #actor> : ^qn_how_ac_feel(&1,past) #question = <#nquestion1> : question(&0) #sentence = <#question> : &0
then it all comes down to #final in npl_sentence.txt
#final = <#answer #name * #sentence *> : &1(&0,&2)
Every result has to start with the actor who the sentence is addressed to.
So #final = <#name #greet *> : &0(&1)
Can parse "Saiko Hello" -> Saiko(Hello)
if it does not have #name it must be "you(&0)"
if you understand all of this and want to try to add words and sentences in go for it otherwise im gonna show you how to cheat
only cheat if you are adding an animation command
copy the nlp_actor.txt and rename it nlp_custom
////////////////////////////////////////// // Custom ////////////////////////////////////////// #custom = <#custom0> : animation(&0) in_custom(*) : &0(animation),animation(type) #custom0 = <#customval> : ^in_custom(&0) #customval = <* handstand *> : handstand #customval = <* bend over bench *> : benchanal #customval = <* ride me *> : rideme #customval = <* cartwheel *> : cartwheel
open syntax.txt and add
#include "ai/nlp/nlp_custom.txt"
under #include "ai/nlp/nlp_sentence.txt"
open nlp_sentence.txt
and add
#final = <#custom *> : you(&0)
under nres final 0
this will make our animation response trigger first so don't use already existing words otherwise they will override them
inside the trace.txt after running the dungeon and saying the words
09:39:31 Me: CTALK: "ride me"
09:39:31 BRAIN: "Saiko[TALK]:talk=(closest:2,from:PLAYER,to:you,slen=7,cat=animation,e=[rideme.animation,animation.type])"
09:39:33 BRAIN: "state.code.ref.state.RUN0.animation.rideme"
09:39:31 Me: CTALK: "ride me"// what the player said
to:you// which is the you in #final
slen=7// how many character are in the word "ride me" includes the space
cat=animation// the animation in #custom
I think that's enough on the nlp
If i missed something or something is incorrect then let me know
Good luck