AI Zone Admin Forum Add your forum

NEWS: Chatbots.org survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

Fact-set assignment trouble
 
 

Let me first say thank you to his group.  The help/training with this is fantastic.


Now onto the problem ...

I’m trying to assign a fact-set to a second variable to use for lookups.

I’m using a fact query to iterate through a concept:

concept: ~TEST_REQUIREMENTS( “test 1” “test 2” “Test 3”)

I can iterate through the list using the default fact-set:

?: TEST_REQUIREMENTS (give me requirement test) Size is:
^query(direct_sv ~TEST_REQUIREMENTS member ?)
_9 = length(@0)
size: _9
\n List is:
loop (_9)
{
^first(@0subject) ,

}

Output: 
HARRY:  Size is: size: 3
List is: test 1, test 2, Test 3

Works with no problem. 

I need to do a second query, so I want to assign the result from the default fact-set to another fact-set:

?: TEST_REQUIREMENTS (give me requirement test) Size is:
^query(direct_sv ~TEST_REQUIREMENTS member ?)
@1 = @0
_9 = length(@1)
size: _9
\n List is:
loop (_9)
{
^first(@1subject) ,

}

Output:
HARRY:  Size is: size: 0
List is:



Is there another way to get the fact-set 0 into fact-set 1?

 

 
  [ # 1 ]

query nominally takes up to 9 arguments (optional). There is an option argument about how many answers to get, and an option argument about where (other than default @0) to store the answers….
query(direct_sv noun verb object count fromset toset auxdata auxdata)

One can also ask the system to COPY data from one factset to another, but probably you just want it to put the query results in the right place initially.

 

 
  [ # 2 ]

Bruce, perfect, exactly what i needed.

Thank you!

 

 
  [ # 3 ]

I did a similar code to the above but can’t get it to work properly. I appreciate suggestions on how to correct:

  _9 = ^length(@0) + 1
  loop (_9)
  {
^query(direct_sv $tmp by ?)
_3 = ^pick(@0+)
_3 _4 _5 n
}

Suppose _9 is 5, so set @0 has 5 facts found from a table. With ^pick I get random values of those found, but only if I just did a :build do I get all 5 distinct facts. In any other case I’ll get a random combination of unique and repeated facts (e.g. 2,4,1,1,2). If I use ^first or ^last, I always get the same fact, the most recent or oldest respectively. It seems facts from the set are not getting removed with each call.

 

 
  [ # 4 ]

1 you are refreshing the fact set before each pick in the loop.
2. You don’t need a counted loop. the loop will terminate when pick fails because the set becomes empty
3. If you DID want a counted loop, it would be the length only, not length + 1


You want:

^query(direct_sv $tmp by ?)
  loop ()
  {
_3 = ^pick(@0+)
_3 _4 _5 n
}

 

 
  [ # 5 ]

I hate it when I do this. I just returned to delete the question but you answer VERY quickly (which is awesome).

Thanks!

 

 
  [ # 6 ]

So in the future I should count to 10 before answering. smile

 

 
  login or register to react