Converting txt strings to facts

33 views
Skip to first unread message

Robin Bloomfield

unread,
Jan 13, 2024, 9:09:31 AMJan 13
to ErgoAI and XSB Users Forum
Apologies if this is such a newbie question, but I am using an LLM to generate text that I want to assert as Ergo fact e.g. claim(1, ' the sky is red'). The strings I get back from the http post query are just that, is there an easy way to convert? I want to insert{claim(1, ' the sky is red') not insert{'claim(1, ' the sky is red')'}. 

Michael Kifer

unread,
Jan 13, 2024, 11:53:40 PMJan 13
to ErgoAI-X...@coherentknowledge.com


On 1/13/24 9:09 AM, Robin Bloomfield wrote:
Apologies if this is such a newbie question, but I am using an LLM to generate text that I want to assert as Ergo fact e.g. claim(1, ' the sky is red'). The strings I get back from the http post query are just that, is there an easy way to convert? I want to insert{claim(1, ' the sky is red') not insert{'claim(1, ' the sky is red')'}.  --


Yes, it is explained in the programmer's manual, section

Reading and Compiling Input Terms

see readAll.


For instance,


ergo>  string('${p(a,b)}.')[readAll(?Result)]@\parse, ?Result=[code(?Term, ?)@\plg], insert{?Term}.


?Result = [code(p(a,b),[ok, eof])@\prolog]
?Term = p(a,b)


ergo> p(?X,?Y).

?X = a
?Y = b


ergo> string('${obj[m->123]}.')[readAll(?Result)]@\parse, ?Result=[code(?Term, ?)@\plg], insert{?Term}.

?Result = [code(${obj[m->123]@main},[ok, eof])@\prolog]
?Term = ${obj[m->123]@main}

ergo> ?a[?m->?r].

?a = obj
?m = m
?r = 123

Robin Bloomfield

unread,
Jan 15, 2024, 3:30:15 PMJan 15
to ErgoAI and XSB Users Forum, Michael Kifer
Hi Michael,
Many thanks, just what I needed.
best wishes
Robin
Reply all
Reply to author
Forward
0 new messages