-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Global StandardAnalyzer with StopWords from File
PostPosted: Thu Jul 08, 2010 6:38 pm 
Newbie

Joined: Wed Dec 02, 2009 8:50 pm
Posts: 5
Hi,

In my project I am using StandardAnalyzer. My StandardAnalyzer uses the constructor which takes the stopwords file as below.

Code:
StandardAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_29, new File("C:/StopWords.txt"));


How do I specify this analyzer as my global analyzer in hibernate config file. I know how to specify standard analyzer with out the stopwords file. Don't know how to specify stopwords file.

Thank you,


Top
 Profile  
 
 Post subject: Re: Global StandardAnalyzer with StopWords from File
PostPosted: Fri Jul 09, 2010 3:46 am 
Pro
Pro

Joined: Wed Oct 03, 2007 2:31 pm
Posts: 205
The way I can think of doing this is like this:

1) Extend the StandardAnalyzer class and set the stop word file or pass it in via System.getProperty("stopWordFile")
2) Define the new analyzer like this in your configuration:
Code:
hibernate.search.analyzer=MyStandardAnalyzerWithStopWords


Not sure if this is the best way, plus I would need to have a go...


Top
 Profile  
 
 Post subject: Re: Global StandardAnalyzer with StopWords from File
PostPosted: Sat Jul 10, 2010 7:00 pm 
Newbie

Joined: Wed Dec 02, 2009 8:50 pm
Posts: 5
Thank you amin-mc. I did like you said and it is working fine.

Code:
import java.io.File;
import java.io.IOException;

import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.util.Version;

public class MyStandardAnalyzerWithStopWords extends StandardAnalyzer
{
  public MyStandardAnalyzerWithStopWords() throws IOException
  {
    super(Version.LUCENE_29, new File("D:/Configs/StopWords.txt"));
  }
}


and set MyStandardAnalyzerWithStopWords as the global analyzer.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.