Stevan Apter wrote:
> thanks for asking ken.
>
> e:{$[(#b)=i:(|/'b:(w@[EMAIL PROTECTED]
(w:(`$" "\:x@[EMAIL PROTECTED]
in".?"))in`)in\:/:A)?1b;E@[EMAIL PROTECTED]
> " "~n:c@[EMAIL PROTECTED]
(c:{x@[EMAIL PROTECTED]
i)ss/:N;c
> .q.ssr[c;n;" "/:$(),P'(w[k],p:1_'(0,1+k:b[i]?1b)_`,w)"I"$n]]}
Wonderful. I will post this over on the Arc forum, I think they are
headed your way.
So how big a chunk can a K guru toss off without taking a breath, if you
will? I suppose it is like any language, developing bits and pieces
before connecting it all. My suspicion is one can get off more
functionality simply from the lower character count, once they are all
known fluently.
kenny
>
> it's just a single eye-watering case statement:
>
> if no keyword match in A, then return a default response from E
> else if no substitution in the response c picked from C, return c
> else substitute and return
>
> it's easier to break the q code into smaller chunks. a revised version
> here: http://www.nsl.com/k/eliza.q
>
>
> "Ken Tilton" <kennytilton@[EMAIL PROTECTED]
> wrote in message
> news:47c0813e$0$8080$607ed4bc@[EMAIL PROTECTED]
>
>>
>>
>> Stevan Apter wrote:
>>
>>> in q:
>>>
>>> D:(("1 father|mother|brother|sister 2";"tell me about your 0.");
>>> ("1 am|i'm 2";"why are you 2|have you always been 2?");
>>> ("1 i 2";"why do you 2?");
>>> ("1 you 2";"we're talking about you, not me.|please don't be so
>>> personal"))
>>>
>>> E:"|"vs"that's very interesting. do go on.|
>>> tell me more|
>>> i'm not sure i understand you fully|
>>> can you elaborate on that?"
>>>
>>> S:{(`$"|"vs first w where not b;raze w where b:(first each w:" "vs
>>> x)in"0123456789")}each D[;0]
>>> R:"|"vs'D[;1]
>>> P:{(y,x,z)(x,y)?z}[`$("you";"your";"yourself";"i'm";"i
>>> am");`$("i";"my";"myself";"you are";"you're")]
>>>
>>> e:{w:(`$" "vs x except".?")except`; / words
>>> except punctuation, blanks
>>> b:w in\:/:S[;0]; / boolean
>>> mask: words X rules
>>> if[count[b]=i:(any each b)?1b;:E first 1?count E]; / if no key
>>> match on a rule, early exit
>>> p:1_'(0,1+k:b[i]?1b)_`,w; / split input
>>> on key
>>> r:{x first 1?count x}R i; / pick a rule
>>> n:r first raze r ss/:"0123456789"; / which part
>>> of input to replace
>>> ssr[r;n;" "sv string(),P each(w[k],p)"I"$n]} / construct
>>> reply
>>>
>>> in k it's about half the size, but i'll spare you.
>>
>>
>> I'd love to see it, or a link to any other sample K code. I recall
>> seeing a one page implementation of a spreadsheet, that was wild.
>>
>> kenny
--
http://smuglispweeny.blogspot.com/
http://www.theoryyalgebra.com/
"In the morning, hear the Way;
in the evening, die content!"
-- Confucius


|