First, thanks to Jens K. for pointing a stupid error on my part regarding the use of test_token_stream(). <br><br>My current problem, a custom tokenizer I&#39;ve written in Ruby does not properly create an index (or at least searches on the index don&#39;t work). Using test_token_stream() I have verified that my tokenizer properly creates the token_stream; certainly each Token&#39;s attributes are set properly. Nevertheless, simple searches return zero results. <br>
<br>The essence of my tokenizer is to skip beyond XML tags in a file and break up and return text components as tokens. I use this approach as opposed to an Hpricot approach because I need to keep track of the location of the text with respect to XML tags since after a search for a phrase I&#39;ll want to extract the nearby XML tags as they contain important context. My tokenizer (XMLTokenizer) contains a the obligatory initialize, next and text methods (shown below) as well as a lot of parsing methods that are called at the top level by the method XMLTokenizer.get_next_token which is the primary action within next. I didn&#39;t add the details of get_next_token as I&#39;m assuming that if each token produced by get_next_token has the proper attributes then it shouldn&#39;t be the cause of the problem. What more should I be looking for? I&#39;ve been looking for a custom tokenizer written in Ruby to model after; any suggestions? <br>
<br>&nbsp;&nbsp;&nbsp; def initialize(xmlText)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @xmlText = xmlText.gsub(/[;,!]/, &#39; &#39;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @currPtr = 0<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @currWordStart = nil<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @currTextStart = 0<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @nextTagStart = 0<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @startOfTextRegion = 0<br>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @currTextStart = \<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; XMLTokenizer.skip_beyond_current_tag(@currPtr, @xmlText)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @nextTagStart = \<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; XMLTokenizer.skip_beyond_current_text(@currTextStart, @xmlText) <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @currPtr = @currTextStart<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @startOfTextRegion = 1<br>&nbsp;&nbsp;&nbsp; end<br><br>&nbsp;&nbsp;&nbsp; def next<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tkn = get_next_token<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if tkn != nil<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; puts &quot;%5d |%4d |%5d&nbsp;&nbsp; | %s&quot; % [tkn.start, tkn.end, tkn.pos_inc, tkn.text]<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return tkn<br>&nbsp;&nbsp;&nbsp; end<br><br>&nbsp;&nbsp;&nbsp; def text=(text)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; initialize(text)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @xmlText<br>&nbsp;&nbsp;&nbsp; end<br><br>Below is text from a previous, related message that shows that StopFiltering is not working:<br><br><pre>
&gt;<i> I&#39;ve written a tokenizer/analyzer that parses a file extracting tokens and<br></i>&gt;<i> operate this analyzer/tokenizer on ASCII data consisting of XML files (the<br></i>&gt;<i> tokenizer skips over XML elements but maintains relative positioning). I&#39;ve<br>
</i>&gt;<i> written many units tests to check the produced token stream and was<br></i>&gt;<i> confident that the tokenizer was working properly. Then I noticed two<br></i>&gt;<i> problems:<br></i>&gt;<i> <br></i>&gt;<i>    1. StopFilter (using English stop words) does not properly filter the<br>
</i>&gt;<i>    token stream output from my tokenizer. If I explicitly pass an array of stop<br></i>&gt;<i>    words to the stop filter it still doesn&#39;t work. If I simply switch my<br></i>&gt;<i>    tokenizer to a StandardTokenizer the stop words are appropriately filtered<br>
</i>&gt;<i>    (of course the XML tags are treated differently).<br></i>&gt;<br>&gt;<i>    2. When I try a simple search no results come up. I can see that my<br></i>&gt;<i>    tokenizer is adding files to the index but a simple search (using<br>
</i>&gt;<i>    Ferret::Index::Index.search_each) produces no results.<br></i></pre><br>Any suggestions are appreciated. <br><br>John<br>