I’ve heavily documented my code so far so that we can work it out between us. I think I would have a hard time discussing things in person at the moment though, I’m still working it out. Give me some time to get more of it understood.
My code has a little debugging output too, makes it easier to understand, especially with all the recursion that is going on !
I agree with your notion that we cannot create the Graphmaster on the fly. I anticipated this. I haven’t put it into practive yet as I’m still working on the parsing routine, but I have an idea…
The way I decided to do it was by using a big multi dimensional array. Into the array the patterns are injected. So it’s basically an associative array, with words marking the nodes. I traverse the array as per the words in the nodes compared to the words in the input. If the AIML is written properly with no duplicates and shadows you should get only one result.
In fact by it’s nature duplicates would be overwritten anyway. There is a useful side-effect there - and that’s at the time the Graphmaster is created you can check for things like duplicates and throw an error message to a log or something.
As for storing the Graphmaster itself, I thought to serialise the array and then write it to file. So at each volley you wouldn’t need to recreate the Graphmaster - instead you read in the file and unserialise it back into an array form - all ready to use.
It should use a lot less memory than a database or the raw AIML files. Since one node can represent all the patterns that start with one certain word - I mean the word only need be represented once. Since databases use the file system anyway I can’t see this being a bad decision yet.
It’s very interesting to work on.