[jsword-svn] jsword/java/jsword/org/crosswire/jsword/book/search/lucene s

jswordcvs at crosswire.org jswordcvs at crosswire.org
Thu Mar 24 21:02:54 MST 2005


Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/lucene
In directory www.crosswire.org:/tmp/cvs-serv17165/java/jsword/org/crosswire/jsword/book/search/lucene

Modified Files:
	LuceneIndex.java 
Added Files:
	LuceneThesarus.java 
Log Message:
Added a marginally workable solution for match.

Index: LuceneIndex.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/lucene/LuceneIndex.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** LuceneIndex.java	24 Mar 2005 03:14:29 -0000	1.12
--- LuceneIndex.java	25 Mar 2005 04:02:52 -0000	1.13
***************
*** 37,40 ****
--- 37,41 ----
  import org.crosswire.jsword.passage.NoSuchKeyException;
  import org.crosswire.jsword.passage.NoSuchVerseException;
+ import org.crosswire.jsword.passage.PassageTally;
  import org.crosswire.jsword.passage.Verse;
  import org.crosswire.jsword.passage.VerseFactory;
***************
*** 169,174 ****
          checkActive();
  
!         Key tally = book.createEmptyKeyList();
!         // Tally tally = new PassageTally();
  
          if (search != null)
--- 170,175 ----
          checkActive();
  
! //        Key tally = book.createEmptyKeyList();
!          PassageTally tally = new PassageTally();
  
          if (search != null)
***************
*** 183,189 ****
                  {
                      Verse verse = VerseFactory.fromString(hits.doc(i).get(LuceneIndex.FIELD_NAME));
! //                  int score = (int) (hits.score(i) * 100);
! //                  tally.add(verse, score);
!                     tally.addAll(verse);
                  }
              }
--- 184,190 ----
                  {
                      Verse verse = VerseFactory.fromString(hits.doc(i).get(LuceneIndex.FIELD_NAME));
!                   int score = (int) (hits.score(i) * 100);
!                   tally.add(verse, score);
! //                    tally.addAll(verse);
                  }
              }

--- NEW FILE: LuceneThesarus.java ---
package org.crosswire.jsword.book.search.lucene;

import java.io.File;
import java.io.IOException;
import java.io.StringReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.SimpleAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.search.Hits;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.Searcher;
import org.crosswire.common.activate.Activatable;
import org.crosswire.common.activate.Activator;
import org.crosswire.common.activate.Lock;
import org.crosswire.common.progress.Job;
import org.crosswire.common.progress.JobManager;
import org.crosswire.common.util.Logger;
import org.crosswire.common.util.NetUtil;
import org.crosswire.common.util.Reporter;
import org.crosswire.jsword.book.Book;
import org.crosswire.jsword.book.BookData;
import org.crosswire.jsword.book.BookException;
import org.crosswire.jsword.book.IndexStatus;
import org.crosswire.jsword.book.search.Index;
import org.crosswire.jsword.book.search.Thesaurus;
import org.crosswire.jsword.passage.BibleInfo;
import org.crosswire.jsword.passage.Key;
import org.crosswire.jsword.passage.KeyUtil;
import org.crosswire.jsword.passage.NoSuchKeyException;
import org.crosswire.jsword.passage.NoSuchVerseException;
import org.crosswire.jsword.passage.PassageTally;
import org.crosswire.jsword.passage.Verse;
import org.crosswire.jsword.passage.VerseFactory;

/**
 * Implement the Thesarus using Lucene fuzzy searches.
 *
 * <p><table border='1' cellPadding='3' cellSpacing='0'>
 * <tr><td bgColor='white' class='TableRowColor'><font size='-7'>
 *
 * Distribution Licence:<br />
 * JSword is free software; you can redistribute it
 * and/or modify it under the terms of the GNU General Public License,
 * version 2 as published by the Free Software Foundation.<br />
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.<br />
 * The License is available on the internet
 * <a href='http://www.gnu.org/copyleft/gpl.html'>here</a>, or by writing to:
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 * MA 02111-1307, USA<br />
 * The copyright to this program is held by it's authors.
 * </font></td></tr></table>
 * @see gnu.gpl.Licence
 * @author DM Smith [dmsmith555 at gmail dot com]
 * @version $Id: LuceneThesarus.java,v 1.1 2005/03/25 04:02:52 dmsmith Exp $
 */
public class LuceneThesarus implements Thesaurus
{

    /* (non-Javadoc)
     * @see org.crosswire.jsword.book.search.Thesaurus#getSynonyms(java.lang.String)
     */
    public Collection getSynonyms(String word) throws BookException
    {
        // Use fuzzy search
        Object[] synonymns =  { (word + '~') };
        return Arrays.asList(synonymns);
    }
}



More information about the jsword-svn mailing list