You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Frank Schima <fj...@foraker.com> on 2007/12/27 16:56:17 UTC

Synonyms in Lucene 2.2

Hello all,


I'm trying to implement a synonym engine in Lucene 2.2 based on the code in
the Lucene In Action book. However, I'm getting compile errors:


My Synonym filter looks like this:

import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.TokenFilter;
import org.apache.lucene.analysis.Token;
import java.io.IOException;
import java.util.Stack;

public class SynonymFilter extends TokenFilter {
  public static final String TOKEN_TYPE_SYNONYM = "SYNONYM";

  private Stack synonymStack;
  private SynonymEngine engine;

  public SynonymFilter(TokenStream in, SynonymEngine engine) {
    super(in);
    synonymStack = new Stack();
    this.engine = engine;
  }
....

But "Stack" is not recognized. What am I doing wrong?

-- 
View this message in context: http://www.nabble.com/Synonyms-in-Lucene-2.2-tp14514848p14514848.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: Synonyms in Lucene 2.2

Posted by Erick Erickson <er...@gmail.com>.
Oh, now I get it <G>. While I thoroughly approve of the strong
typing in generics, I continually trip over code written for the 1.4
code base not being approved by the 1.5 compiler...

Best
Erick

On Dec 27, 2007 12:29 PM, Frank Schima <fj...@foraker.com> wrote:

>
> Hi Erick,
>
>
>
> Erick Erickson wrote:
> >
> > I don't think this has anything to do with Lucene, the problem
> > seems to be that your compiler can't find the Java Stack
> > class.
> >
> > You need to set your classpath to include wherever
> > java.utils is on your disk.
> >
>
> I agree it's a Java issue. I'm just using the standard Java 1.5 compiler.
>
> Thank the gods for Eclipse. It suggested the following fixes which compile
> for me (note the "<token>" terms added):
>
> import org.apache.lucene.analysis.TokenStream;
> import org.apache.lucene.analysis.TokenFilter;
> import org.apache.lucene.analysis.Token;
> import java.io.IOException;
> import java.util.Stack;
>
> public class SynonymFilter extends TokenFilter {
>  public static final String TOKEN_TYPE_SYNONYM = "SYNONYM";
>
>  private Stack<Token> synonymStack;
>  private SynonymEngine engine;
>
>  public SynonymFilter(TokenStream in, SynonymEngine engine) {
>    super(in);
>    synonymStack = new Stack<Token>();
>    this.engine = engine;
>  }
> ...
>
>
> Cheers!
> Frank
>
>
>
>
> --
> View this message in context:
> http://www.nabble.com/Synonyms-in-Lucene-2.2-tp14514848p14515933.html
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Re: Synonyms in Lucene 2.2

Posted by Frank Schima <fj...@foraker.com>.
Hi Erick,



Erick Erickson wrote:
> 
> I don't think this has anything to do with Lucene, the problem
> seems to be that your compiler can't find the Java Stack
> class.
> 
> You need to set your classpath to include wherever
> java.utils is on your disk.
> 

I agree it's a Java issue. I'm just using the standard Java 1.5 compiler. 

Thank the gods for Eclipse. It suggested the following fixes which compile
for me (note the "<token>" terms added):

import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.TokenFilter;
import org.apache.lucene.analysis.Token;
import java.io.IOException;
import java.util.Stack;

public class SynonymFilter extends TokenFilter {
  public static final String TOKEN_TYPE_SYNONYM = "SYNONYM";

  private Stack<Token> synonymStack;
  private SynonymEngine engine;

  public SynonymFilter(TokenStream in, SynonymEngine engine) {
    super(in);
    synonymStack = new Stack<Token>();
    this.engine = engine;
  }
...


Cheers!
Frank




-- 
View this message in context: http://www.nabble.com/Synonyms-in-Lucene-2.2-tp14514848p14515933.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: Synonyms in Lucene 2.2

Posted by Erick Erickson <er...@gmail.com>.
I don't think this has anything to do with Lucene, the problem
seems to be that your compiler can't find the Java Stack
class.

You need to set your classpath to include wherever
java.utils is on your disk.


Erick


On Dec 27, 2007 10:56 AM, Frank Schima <fj...@foraker.com> wrote:

>
> Hello all,
>
>
> I'm trying to implement a synonym engine in Lucene 2.2 based on the code
> in
> the Lucene In Action book. However, I'm getting compile errors:
>
>
> My Synonym filter looks like this:
>
> import org.apache.lucene.analysis.TokenStream;
> import org.apache.lucene.analysis.TokenFilter;
> import org.apache.lucene.analysis.Token;
> import java.io.IOException;
> import java.util.Stack;
>
> public class SynonymFilter extends TokenFilter {
>  public static final String TOKEN_TYPE_SYNONYM = "SYNONYM";
>
>  private Stack synonymStack;
>  private SynonymEngine engine;
>
>  public SynonymFilter(TokenStream in, SynonymEngine engine) {
>    super(in);
>    synonymStack = new Stack();
>    this.engine = engine;
>  }
> ....
>
> But "Stack" is not recognized. What am I doing wrong?
>
> --
> View this message in context:
> http://www.nabble.com/Synonyms-in-Lucene-2.2-tp14514848p14514848.html
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>