W3C home > Mailing lists > Public > public-qt-comments@w3.org > April 2008

[Bug 5633] [FT] INCORRECT DISTANCE COMPUTATION IN FTDISTANCE

From: <bugzilla@farnsworth.w3.org>
Date: Tue, 15 Apr 2008 02:40:04 +0000
CC:
To: public-qt-comments@w3.org
Message-Id: <E1Jlb5Y-0006bA-Vt@farnsworth.w3.org>

http://www.w3.org/Bugs/Public/show_bug.cgi?id=5633





------- Comment #5 from thomas.baby@oracle.com  2008-04-15 02:40 -------
The resolution is to modify functions xxDistance (xx=word, para, or sentence)
to sort their inputs:

declare function fts:wordDistance (
             $tokenInfo1 as element(fts:tokenInfo),
             $tokenInfo2 as element(fts:tokenInfo) )
   as xs:integer
{
   (: Ensure tokens are in order :)
   let $sorted := 
     for $ti in ($tokenInfo1, $tokenInfo2) 
     order by $ti/@startPos ascending, $ti/@endPos ascending
     return $ti
   return
     (: -1 because we count starting at 0 :)
     $sorted[2]/@startPos - $sorted[1]/@endPos - 1
};


declare function fts:paraDistance (
             $tokenInfo1 as element(fts:tokenInfo),
             $tokenInfo2 as element(fts:tokenInfo) )
   as xs:integer 
{
   (: Ensure tokens are in order :)
   let $sorted := 
     for $ti in ($tokenInfo1, $tokenInfo2) 
     order by $ti/@startPos ascending, $ti/@endPos ascending
     return $ti
   return
     (: -1 because we count starting at 0 :)
     $sorted[2]/@startPara - $sorted[1]/@endPara - 1
};


declare function fts:sentenceDistance (
             $tokenInfo1 as element(fts:tokenInfo),
             $tokenInfo2 as element(fts:tokenInfo) )
   as xs:integer
{
   (: Ensure tokens are in order :)
   let $sorted := 
     for $ti in ($tokenInfo1, $tokenInfo2) 
     order by $ti/@startPos ascending, $ti/@endPos ascending
     return $ti
   return
     (: -1 because we count starting at 0 :)
     $sorted[2]/@startSent - $sorted[1]/@endSent - 1
};
Received on Tuesday, 15 April 2008 02:40:35 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 16:57:22 UTC