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

Efficient dictionary lookup

Subject: Efficient dictionary lookup
From: Martin Holmes <mholmes@xxxxxxx>
Date: Thu, 22 Mar 2012 14:39:01 -0700
 Efficient dictionary lookup
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; basically I'm checking a word form to see if it appears in a spell-checker dictionary.

The dictionary currently consists of a whitespace-separated text string (although it could be formatted any way I choose), and I've been using fn:matches() and fn:contains() to check whether or not the form appears in the dictionary:

<xsl:function name="f:wordExists" as="xs:boolean">
<xsl:param name="inString" as="xs:string"/>
<xsl:value-of select="contains($dictModern, concat(' ', lower-case($inString), ' '))"/>
</xsl:function>


<xsl:function name="f:wordExists" as="xs:boolean">
<xsl:param name="inString" as="xs:string"/>
<xsl:value-of select="matches($dictModern, concat('\s', $inString), '\s', 'i')"/>
</xsl:function>


Both options appear to be very costly in terms of time, and I'm wondering what the most efficient way to do this might be. Is there a faster way to do text lookups like this?

Ultimately I guess I'll implement this as an external Java process, but for the moment I'm working with XSLT, and I'd like to get some speed improvement if I can.

All help appreciated,
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.