AnsweredAssumed Answered

Why is my calc returning a different result on iOS and Desktop?

Question asked by Malcolm on Feb 6, 2019
Latest reply on Feb 7, 2019 by Markus Schneider

In the calc below "AUSNUT::FoodName" is a search term, in the test case we are searching for "Tomato". The field "Food Name" contains the text "Tomato, whole, canned".

 

My FMGO v16 gives me a result of zero from these figures

foodPos = 0

wordBoundary = ,

rank = 0

rankPos = 0

modFoodPos = 0

 

 

FMP v17 gives me a result of 0.1 from these figures

foodPos = 1

wordBoundary = ,

rank = 0

rankPos = 0

modFoodPos = 1

 

What is going on?

 

 

Let ( [

    foodPos = Position ( Food Name ; AUSNUT::FoodName ; 1 ; 1 )

;    wordBoundary = Middle ( Food Name ; foodPos + Length ( AUSNUT::FoodName ) ; 1 )

;    rank = PatternCount ( Left ( Food Name ; foodPos ) ; "," )

;    rankPos = Position (  Food Name ; "," ; 1 ; rank )

;    modFoodPos = foodPos - rankPos

];

 

  If (

    foodPos = 0

;    999

 

;    rank +  If ( modFoodPos < 10 ; modFoodPos / 10 ; modFoodPos ) + PatternCount ( "abcdefghijklmnopqrstuvwxyz" ; wordBoundary )

 

  )

 

)

/**

* We obtain the position of the search term in the food name

* lower numbers imply higher relevance

* However, we are aware that long/short words skew the position,

* we are aware that commas represent a hierarchy of relevance

* so we count the number of commas that occur before the search term

* The number of commas determine the first rank, the integer.

* The position is added to that as the fractional part.

* long/short words can still skew the result.

* We try to reduce the skew as much as possible by counting from the nearest preceding comma

* Finally, if the search term is only part of a word, such as cheese in cheesecake, we add one, equivalent to dropping down a rank.

*/

Outcomes