[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Efficient dictionary lookup

Subject: Re: Efficient dictionary lookup
From: Martin Holmes <mholmes@xxxxxxx>
Date: Thu, 22 Mar 2012 17:49:20 -0700
 Re: Efficient dictionary lookup
On 12-03-22 02:44 PM, David Carlisle wrote:
On 22/03/2012 21:39, Martin Holmes wrote:
 > HI all,
 >
 > As part of a small pilot project, I'm implementing a set of spelling
 > normalization rules applied through XSLT 2.0 using Saxon 9. One
 > operation that happens extremely frequently is a dictionary lookup;
[SNIP]


sounds like you want to use a key then the processor will almost certainly create an efficient lookup index.

If your dictionary is in a file say dict.xml
<words>
<word>one</word>
<word>hello</word>
</words>

then

<xsl:key name="w" match="word" use="."/>

declares the index and

key('w',$word,doc('dict.xml'))

will return the word if it is in the dictionary.

That is much faster, indeed. It's still not fast -- the spellcheck dictionary is big -- but it's interesting to see that processing it as an XML structure with <xsl:key> is so much faster than processing it as a string.


Cheers,
Martin

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.