RE: [xsl] Re: text() word lists

Subject: RE: [xsl] Re: text() word lists
From: David.Pawson@xxxxxxxxxxx
Date: Mon, 9 Feb 2004 08:39:10 -0000
Not that I understand it,
but ( and ) seem to be included Michael?
 <word>)   -   71</word>
 <word>(this   -   11</word>
  

Is it modify by updating 
     for $w in tokenize(string(.), '[\s.?!,]+')[.] return 
line?

for $w in tokenize(string(.), '[\s.?!, )(]+')[.] return 
seems to work.
  Is it possible to remove all numbers too?
Or is that a part of the lexicographers toolset?

What was that question about perl vs xslt 2?
There is a nominal resemblance :-)

regards DaveP


    Sorry for the buggy code. Here is a working version:
    
    <xsl:stylesheet version="2.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
    <xsl:output indent="yes"/>
    <xsl:template match="/">
    <frequencies>
    <xsl:for-each-group group-by="." select="
       for $w in tokenize(string(.), '[\s.?!,]+')[.] return 
    lower-case($w)">
      <xsl:sort select="count(current-group())" order="descending"/>
      <word><xsl:value-of select="current-grouping-key(), '  -  
    ', count(current-group())"/></word> </xsl:for-each-group> 
    </frequencies> </xsl:template> </xsl:stylesheet>
    
    (The predicate [.] elimitates the zero-length string)
    
    Here's the start of the output for othello.xml:
    
    <?xml version="1.0" encoding="UTF-8"?>
    <frequencies>
       <word>i   -   816</word>
       <word>and   -   794</word>
       <word>the   -   762</word>
       <word>to   -   591</word>
       <word>of   -   476</word>
       <word>you   -   458</word>
       <word>a   -   445</word>
       <word>my   -   427</word>
       <word>that   -   368</word>
       <word>iago   -   351</word>
       <word>in   -   336</word>
       <word>othello   -   323</word>
       <word>not   -   313</word>
       <word>it   -   306</word>
       <word>is   -   286</word>
       <word>me   -   256</word>
       <word>cassio   -   236</word>
       <word>for   -   234</word>
       <word>with   -   222</word>
       <word>be   -   220</word>
       <word>he   -   220</word>
       <word>this   -   217</word>
       <word>desdemona   -   217</word>
       <word>but   -   217</word>
       <word>do   -   212</word>
       <word>your   -   207</word>
       <word>have   -   203</word>
       <word>her   -   202</word>
       <word>what   -   178</word>
       <word>him   -   171</word>
       <word>his   -   166</word>
       <word>as   -   166</word>
       <word>she   -   155</word>
       <word>so   -   151</word>
       <word>will   -   146</word>
       <word>o   -   143</word>
       <word>thou   -   142</word>
       <word>if   -   137</word>
       <word>emilia   -   136</word>
       <word>by   -   112</word>
    
    Michael Kay
    
    
    
    
    
    > > Sorted by descending frequency:
    > >
    > > <xsl:for-each-group select="
    > >    for $w in tokenize(string(foo), "[\s.?!]*") return
    > lower-case($w)">
    > >   <xsl:sort select="count(current-group())" order="descending"/>
    > >   <xsl:value-of select="current-grouping-key(), '  -  ', 
    > > count(current-group())"/> </xsl:for-each>
    > 
    > Sorry, but cannot make this work.
    > 
    > First had to remove the nested quotes. Then to change the 
    ending tag.
    > 
    > Now I get the message:
    > 
    > "Error at xsl:for-each-group on line 10 of file:/(Untitled):
    >   Exactly one of the attributes group-by, group-adjacent, 
    > group-starting-with, and group-ending-with must be specified"
    > 
    > Probably this is something trivial, but this is the first 
    time I'm 
    > trying an XSLT 2.0 grouping example.
    > 
    > 
    > Cheers,
    > 
    > Dimitre Novatchev.
    > FXSL developer,
    > 
    http://fxsl.sourceforge.net/ -- the home of FXSL
    Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
    
    
    
    
     XSL-List info and archive:  
    http://www.mulberrytech.com/xsl/xsl-list
    
    
     XSL-List info and archive:  
    http://www.mulberrytech.com/xsl/xsl-list
    

- 
DISCLAIMER: 

NOTICE: The information contained in this email and any attachments is 
confidential and may be privileged. If you are not the intended 
recipient you should not use, disclose, distribute or copy any of the 
content of it or of any attachment; you are requested to notify the 
sender immediately of your receipt of the email and then to delete it 
and any attachments from your system. 

RNIB endeavours to ensure that emails and any attachments generated by 
its staff are free from viruses or other contaminants. However, it 
cannot accept any responsibility for any  such which are transmitted.
We therefore recommend you scan all attachments. 

Please note that the statements and views expressed in this email and 
any attachments are those of the author and do not necessarily represent 
those of RNIB. 

RNIB Registered Charity Number: 226227 

Website: http://www.rnib.org.uk 

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread