First of all, this is a very interesting question. I definitely wish I
had more time to think about it and maybe put together some code -
unfortunately I don't.

Clojure does sound like it would be good for this kind of processing.
This is an ideal example of where it would be incredibly powerful to
built up a domain specific language from Clojure using macros,
allowing both the full expressivity of AIML and the full power of
Clojure when necessary.

That said, just from reading your post - Clojure is a much less
specialized language than AIML appears to be, particularly in the area
of pattern matching in the strings. You will either have to find a
Java (or Clojure) library that does this, or write the Clojure
yourself. It's definitely possible, but I'm afraid there's no way to
avoid actually getting dirty and writing the pattern-finding code
(unless you can find a library that does exactly what you want, and
wrap it).

My intuition is that it would be fairly easy to get something that
just works - a lot can probably be done with Clojure's regular
expression capability. But I have a feeling that in order to get high-
performance code, you'll have to do a lot of indexing and caching
which could potentially get complex.

All in all, I think Clojure's a great language for this, but in order
to replicate some of the advanced features of a made-for-ai
specialized language you're going to have to do some non-trivial
coding to basically recreate those features of AIML that are unique.
This is true of Clojure or any other general-purpose programming
language. Whether it's worth the effort is up to you, but if you can
do a good job I bet there'd be a lot of interested people.

It actually sounds very like the classic exercise of building a logic-
based language similar to Prolog in Scheme or Lisp, only with an AI/
pattern matching functionality instead of a logic resolution engine.

I'll look over your questions in more detail later, if I have time,
and see if I can provide any more specific input.

Thanks!

-Luke


On May 5, 12:16 pm, dhs827 <scheur...@gmail.com> wrote:
> Hi,
>
> my name is Dirk Scheuring, I'm a writer based in Cologne, Germany, and
> I want to write something about AI that can only be expressed by using
> AI technology and technique. You could say that what I aim for is a
> chatbot, but it's a bot that works quiet different from the norm; at
> it's core, there is a functional program, and on the fringe, there's
> lots of state information.
>
> I have a working prototype, written in AIML, the language in which the
> famous Alicebot was written. Most bots written in AIML use a simple
> stimulus-response conception of dialogue, without using (sequences of)
> state, self-reflection, or other advanced concepts. So some people who
> have only cursory knowledge of this language think that it's too
> simple to be doing anything with that might be computationally
> interesting. I know this to be false.
>
> AIML is sort of a micro-version of a Lisp, with String being the only
> type, and recursion over everything (powerful and dangerous). You can
> write serious functions with it [1], but you have to abuse it. And I
> heavily abused the language to make it do what I want. I managed to
> build a prototype that does something interesting, but only does it
> for like ten conversational strokes, because then the interpreter's
> stack overflows, causing an infinite loop.
>
> I need to implement my ideas in a different language - one that I
> don't have to abuse to do complex stuff. I've looked at various
> functional languages, and have now installed two, Scala and Clojure,
> doing a couple tutorials at the respective REPLs. I have a hunch that
> Clojure might turn out to be closer to what I already have in AIML,
> but I'm not sure yet. Maybe you can help me decide.
>
> AIML is an XML dialect; its most important construct is the <category/>, 
> which has a <pattern/> and a <template/>. This is a default
>
> <category/>, which matches any string:
>
> <category>
>   <pattern>*</pattern>
>   <template>
>     <srai>SOMEFUNCTION</srai>
>   </template>
> </category>
>
> The <srai/> element in the <template/> means that I invoke the pattern
> matcher recursivly to match SOMEFUNCTION. How can I express this in
> Clojure?
>
> The next primitive construction I need to translate is substitution:
>
> <category>
>   <pattern>* RAN *</pattern>
>   <template>
>     <srai><star index="1"/> RUNNING <star index="2"/></srai>
>   </template>
> </category>
>
> This code matches the substring RAN in the middle of a set of other
> substrings, and substitutes it for RUNNING, leaving the values before
> and after it untouched for the next recursion. And I need to know how
> to do:
>
> <category>
>   <pattern>* MADONNA *</pattern>
>   <template>
>     <think>
>       <set name="celebrity">Madonna</set>
>     </think>
>     <srai><star index="1"/> <star index="2"/></srai>
>   </template>
> </category>
>
> The above category "extracts" a substring from the input and saves it
> to a (global) variable; the other substrings are up for another round
> of pattern matching. Another important low-level one is:
>
> <topic name="* MYTOPIC *">
>   <category>
>     <pattern>*</pattern>
>     <template>
>       <srai>SOMEOTHERFUNCTION</srai>
>     </template>
>   </category>
> </topic>
>
> This is again the catch-all <*> pattern, but in a context, represented
> by the substring MYTOPIC in between these other substrings. So in this
> case, the default <pattern/> has a <template/> that calls
> SOMEOTHERFUNCTION. Is this something I would do with Multimethods in
> Clojure?
>
> There's lots more, but this is the primitive stuff that I need to
> comprehend first. My model does what I call "semantic compression" -
> it transforms and analytically stores (parts of) the input string -,
> then finds a matching object which has methods to generate facts and
> rules, the core of an output, which might then be extended front and
> back, depending on what's in the input and what's in the current state
> (that's "semantic expansion")...and finally, the first letter of the
> output is cast to uppercase, a dot or bang or questionmark is put at
> the end, and a special object writes the formated output (say, to a
> webpage, or to an IRC channel). I know how to do this in AIML, at
> least up to the point when the interpreter crashes, because I used the
> language in a way it wasn't designed to be used (but it's valid AIML -
> the spec allows some unmentioned things; plus it is functional, with
> continuation-passing to boot). I want to learn how to do this in
> Clojure, and appreciate any pointers and tips.
>
> Best regards,
>
> Dirk Scheuring
>
> [1] Simple FP example in 
> AIML:http://list.alicebot.org/pipermail/alicebot-style/2002-September/0002...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to