Optimize the word search algorithm. Comparison using product
set is a better solution to evaluate whether a node is included in a partial node-set or not.
This commit is contained in:
parent
214e74af91
commit
65beb8b026
Notes:
svn2git
2020-12-08 03:00:23 +00:00
svn path=/head/; revision=25765
1 changed files with 19 additions and 19 deletions
|
|
@ -9,31 +9,31 @@
|
||||||
<xsl:param name="transtable-sortkey.xml" select="'./transtable-sortkey.xml'" />
|
<xsl:param name="transtable-sortkey.xml" select="'./transtable-sortkey.xml'" />
|
||||||
|
|
||||||
<xsl:key name="transtable-lookup-key" match="word" use="orig" />
|
<xsl:key name="transtable-lookup-key" match="word" use="orig" />
|
||||||
|
<xsl:key name="transtable-lookup-group" match="group/word" use="../@id" />
|
||||||
<xsl:key name="transtable-sortkey-lookup-key" match="word" use="@orig" />
|
<xsl:key name="transtable-sortkey-lookup-key" match="word" use="@orig" />
|
||||||
|
|
||||||
<xsl:template name="transtable-lookup">
|
<xsl:template name="transtable-lookup">
|
||||||
<xsl:param name="word" select="''"/>
|
<xsl:param name="word" select="''"/>
|
||||||
<xsl:param name="word-group" select="''"/>
|
<xsl:param name="word-group" select="''"/>
|
||||||
|
|
||||||
<xsl:choose>
|
<xsl:for-each select="document($transtable.xml)">
|
||||||
<xsl:when test="document($transtable.xml)/transtable/group[@id = $word-group]">
|
<xsl:choose>
|
||||||
<xsl:for-each select="document($transtable.xml)/transtable/group[@id = $word-group]">
|
<!-- $p[count(.|$q) = count($q)] means product set of $p and $q-->
|
||||||
<xsl:choose>
|
<xsl:when test="
|
||||||
<xsl:when test="key('transtable-lookup-key', string($word))[../@id = $word-group]">
|
key('transtable-lookup-group', string($word-group))
|
||||||
<xsl:for-each select="key('transtable-lookup-key', string($word))[../@id = $word-group]">
|
[count(.|key('transtable-lookup-key', string($word)))
|
||||||
<xsl:value-of select="tran" />
|
= count(key('transtable-lookup-key', string($word)))]
|
||||||
</xsl:for-each>
|
">
|
||||||
</xsl:when>
|
<xsl:value-of select="
|
||||||
<xsl:otherwise>
|
key('transtable-lookup-group', string($word-group))
|
||||||
<xsl:value-of select="$word" />
|
[count(.|key('transtable-lookup-key', string($word)))
|
||||||
</xsl:otherwise>
|
= count(key('transtable-lookup-key', string($word)))]/tran" />
|
||||||
</xsl:choose>
|
</xsl:when>
|
||||||
</xsl:for-each>
|
<xsl:otherwise>
|
||||||
</xsl:when>
|
<xsl:value-of select="$word" />
|
||||||
<xsl:otherwise>
|
</xsl:otherwise>
|
||||||
<xsl:value-of select="$word" />
|
</xsl:choose>
|
||||||
</xsl:otherwise>
|
</xsl:for-each>
|
||||||
</xsl:choose>
|
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
<xsl:template name="transtable-sortkey-lookup">
|
<xsl:template name="transtable-sortkey-lookup">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue