Page 1 of 1

Querying sentences - FactSentence function

Posted: 07 Jan 2023 14:53
by ogulbran
To get an overview of how my sentence templates are working for all my facts I am trying to make a query showing all facts (of a specific type) with the narrative sentences that will be produced.

I am not sure I do understand what the FactSenctence function is meant to produce. Each fact is listed in my query and I have one column with the expression "=FactSenctence(%FACT%,,PRINCIPAL)". For most rows this produce no result - but for a few of the facts it makes a sentence based on the template sentence (and the result is different for rows of same fact type).

Can anyone explain me?

Best regards,
Øivind

Re: Querying sentences - FactSentence function

Posted: 07 Jan 2023 15:26
by tatewise
Hi Øivind.

I guess you are using a Fact type of Query and to filter down to all facts of a specific type you have a Rows tab filter such as:
Add if =FactLabel(%FACT%) contains ["Fact Label"]

Then a Column with Expression: =FactSentence(%FACT%,,PRINCIPAL) should work for all Individual facts.

Maybe you are using an Individual type of Query. That won't work reliably with that Column expression.

Try the FHUG Knowledge Base > Downloads > Fact Queries > All Facts Filter by Label which allows the Type of Fact to be chosen and already has the =FactSentence(...) as a Column expression.

Re: Querying sentences - FactSentence function

Posted: 08 Jan 2023 10:09
by ogulbran
Thanks for fast reply. Good resource with queries in the Knowledge base that I was not aware of.

But I had done this correct, so I still get the same result.

Have done some testing, and it seems to depend on my fact set. If I delete all my special fact sets it works well.

But the sentences work correctly based on my fact set f.ex. in the "sentence" windows when I view a fact for an individual.

Any idea of what the problem can be?

Best regards,
Øivind

Re: Querying sentences - FactSentence function

Posted: 08 Jan 2023 13:15
by tatewise
I think I have discovered the problem.
If the Sentence Template starts with <br> or <para> then the leading newline characters upset the Query Column display.

I have tried various ways of testing for or removing those leading newline characters without success.
So the best solution is to have three Columns with these Headings & Expressions for the three cases:
Sentence . . . . . . . . . . =FactSentence(%FACT%,,PRINCIPAL) for the normal cases.
<br> Sentence . . . . . =MidText(FactSentence(%FACT%,,PRINCIPAL),3,0) for the <br> cases.
<para> Sentence . . . =MidText(FactSentence(%FACT%,,PRINCIPAL),5,0) for the <para> cases.

Re: Querying sentences - FactSentence function

Posted: 08 Jan 2023 14:56
by ogulbran
Exactly - that was the problem - and a good solution!

Thank you very much!

Best regards,
Øivind