Forum/API

TKQL OR

hedin April 14, 2009

how to code body rows linked OR not AND as usualy.

query some

some [is instance of] [class a]

(OR)

some [is instance of] [class b]

 

Comments

User photo
beth
True Knowledge Ltd

You can do this

 

query some

cls [is in the group] [group: [class a]; [class b]]

some [is an instance of] cls

April 14, 2009 11:26.
User photo
hedin

Ok thanks, but if it is more general.

some [is instance of] [class a]

(OR)

some [some other relation] [some object]

April 15, 2009 08:40.
User photo
beth
True Knowledge Ltd

One way you could do that is like this

 

query some

param_rel [is in the group] [group: [is the first parameter of]; [is the second parameter of]]

rel param_rel [group: [is an instance of]; [some other relation]]

obj param_rel [group: [class a]; [some object]]

some rel obj

 

but that is a bit convoluted.  You might be better off writing them as separate queries and taking the union of the results in the program that calls the queries.

April 15, 2009 10:07.
User photo
hedin

Hmmm this will fetch

some  [some other relation]  [class a]

or i missed something ...

yep, i see that i may decomposite complex query for a number of simplier queries, and some more work (union, filter, etc) in my software ...

But i hope to do query, get answer and use it :-)

"some" may be not a point of query, but only a small part of it ...

April 15, 2009 12:53.
User photo
hedin

Sorry cant clearly understand the query you writen.

May you make a working example, so i can test it and manipulate a bit?

April 15, 2009 13:06.
User photo
beth
True Knowledge Ltd

It should pair them up properly.  Here's an example

 

query x

param_rel [is in the group] [group: [is the first parameter of]; [is the second parameter of]]

rel param_rel [group: [is an instance of]; [is the capital of]]

obj param_rel [group: [supermarket]; [france]]

x rel obj

 

This will do:

1st line:  gets two values for param_rel. Starts with the first value by setting param_rel:=[is the first parameter of]

2nd line: run the query "rel [is the first parameter of] [group: [is an instance of]; [is the capital of]]", which sets rel = [is an instance of]

3rd line: run the query "obj [is the first parameter of] [group: [supermarket]; [france]]", which sets obj = [supermarket]

4th line: run the query "x [is an instance of] [supermarket]"


Next it returns to the start and uses the second value that it got from the [is in the group] query.  Now the following lines look like this:

2nd line: run the query "rel [is the second parameter of] [group: [is an instance of]; [is the capital of]]", which sets rel = [is the capital of]

3rd line: run the query "obj [is the second parameter of] [group: [supermarket]; [france]]", which sets obj = [france]

4th line: run the query "x [is the capital of] [france]"

Then it's finished and returns all the answers.  It never pairs the wrong lines up together because param_rel is fixed after line 1 until it reaches the end of the query, so it can't take different values at lines 2 and 3.

 

April 15, 2009 13:31.
User photo
hedin

Ok thanks now i see how to use it.

how many pairs may i put in the group? if [is the first parameter of] important syntacsys or a may name pairs on my own will?

April 16, 2009 06:48.
User photo
beth
True Knowledge Ltd

We've got [is the third parameter of], but for beyond that I've just added a relation [is the numbered parameter of] which you use like this

 

query x

x [is the numbered parameter of] [group: [integer: ["4"]]; [group: [cat]; [dog]; [mouse]; [fish]; [tree]]]

 

and it should return the answer [fish], and you can put any number instead of 4.  If you use 1,2,or 3 then you get the same result as with the more specific relation.  The only bound on the number of parameters here is the 256 character limit that we currently have on all True Knowledge ID's.


It should go live soon, when you decide to start using it check it first and let me know if it's not started working by then.

April 16, 2009 18:31.