[jsword-svn]
jsword/java/jsword/org/crosswire/jsword/book/search/parse s
jswordcvs at crosswire.org
jswordcvs at crosswire.org
Wed Sep 29 15:21:25 MST 2004
Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/parse
In directory www.crosswire.org:/tmp/cvs-serv8429/java/jsword/org/crosswire/jsword/book/search/parse
Modified Files:
GrammarParamWord.java StartsParamWord.java ParamWord.java
RemoveCommandWord.java SubLeftParamWord.java
RetainCommandWord.java SubRightParamWord.java Word.java
BlurCommandWord.java CommandWord.java AddCommandWord.java
DefaultWord.java PassageLeftParamWord.java
PassageRightParamWord.java Msg.java
Added Files:
IndexSearcher.java
Log Message:
Fixes for [JS-7] and [JS-6]
Lots of search work and re-factoring
Index: BlurCommandWord.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/parse/BlurCommandWord.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** BlurCommandWord.java 25 Aug 2004 22:54:37 -0000 1.8
--- BlurCommandWord.java 29 Sep 2004 22:21:23 -0000 1.9
***************
*** 33,39 ****
{
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.CommandWord#updatePassage(org.crosswire.jsword.book.search.parse.Parser, org.crosswire.jsword.passage.Passage)
*/
! public void updatePassage(LocalParser engine, Key key) throws BookException
{
String word = engine.iterateWord();
--- 33,39 ----
{
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.CommandWord#updatePassage(org.crosswire.jsword.book.search.parse.Searcher, org.crosswire.jsword.passage.Passage)
*/
! public void updatePassage(IndexSearcher engine, Key key) throws BookException
{
String word = engine.iterateWord();
Index: ParamWord.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/parse/ParamWord.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** ParamWord.java 27 Jul 2004 21:42:37 -0000 1.6
--- ParamWord.java 29 Sep 2004 22:21:23 -0000 1.7
***************
*** 41,45 ****
* @exception BookException If this action is not appropriate
*/
! public String getWord(LocalParser engine) throws BookException;
/**
--- 41,45 ----
* @exception BookException If this action is not appropriate
*/
! public String getWord(IndexSearcher engine) throws BookException;
/**
***************
*** 51,54 ****
* @exception BookException If this action is not appropriate
*/
! public Key getKeyList(LocalParser engine) throws BookException;
}
--- 51,54 ----
* @exception BookException If this action is not appropriate
*/
! public Key getKeyList(IndexSearcher engine) throws BookException;
}
Index: PassageRightParamWord.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/parse/PassageRightParamWord.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** PassageRightParamWord.java 27 Jul 2004 21:42:37 -0000 1.5
--- PassageRightParamWord.java 29 Sep 2004 22:21:23 -0000 1.6
***************
*** 31,37 ****
{
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.ParamWord#getWord(org.crosswire.jsword.book.search.parse.Parser)
*/
! public String getWord(LocalParser engine) throws BookException
{
throw new BookException(Msg.RIGHT_PARAM);
--- 31,37 ----
{
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.ParamWord#getWord(org.crosswire.jsword.book.search.parse.Searcher)
*/
! public String getWord(IndexSearcher engine) throws BookException
{
throw new BookException(Msg.RIGHT_PARAM);
***************
*** 39,45 ****
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.ParamWord#Key(org.crosswire.jsword.book.search.parse.Parser)
*/
! public Key getKeyList(LocalParser engine) throws BookException
{
throw new BookException(Msg.RIGHT_BRACKETS);
--- 39,45 ----
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.ParamWord#Key(org.crosswire.jsword.book.search.parse.Searcher)
*/
! public Key getKeyList(IndexSearcher engine) throws BookException
{
throw new BookException(Msg.RIGHT_BRACKETS);
Index: CommandWord.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/parse/CommandWord.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** CommandWord.java 27 Jul 2004 21:42:37 -0000 1.6
--- CommandWord.java 29 Sep 2004 22:21:23 -0000 1.7
***************
*** 6,10 ****
/**
* CommandWord extends Word to allow actions that alter a base
! * Passage. Implementations of this interface may use the Parser to
* get at a default Bible (or they may have one hard coded if necessary)
* or to get at ParamWords that follow this command.
--- 6,10 ----
/**
* CommandWord extends Word to allow actions that alter a base
! * Passage. Implementations of this interface may use the Searcher to
* get at a default Bible (or they may have one hard coded if necessary)
* or to get at ParamWords that follow this command.
***************
*** 44,47 ****
* @param ref The Passage to alter (if necessary)
*/
! public void updatePassage(LocalParser engine, Key ref) throws BookException;
}
--- 44,47 ----
* @param ref The Passage to alter (if necessary)
*/
! public void updatePassage(IndexSearcher engine, Key ref) throws BookException;
}
Index: Msg.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/parse/Msg.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Msg.java 16 Aug 2004 22:08:42 -0000 1.8
--- Msg.java 29 Sep 2004 22:21:23 -0000 1.9
***************
*** 42,46 ****
static final Msg BLUR_BLANK = new Msg("BlurCommandWord.BlurBlank"); //$NON-NLS-1$
static final Msg BLUR_FORMAT = new Msg("BlurCommandWord.BlurFormat"); //$NON-NLS-1$
! static final Msg ENGINE_SYNTAX = new Msg("LocalParser.EngineSyntax"); //$NON-NLS-1$
static final Msg ILLEGAL_PASSAGE = new Msg("PassageLeftParamWord.IllegalPassage"); //$NON-NLS-1$
static final Msg UNMATCHED_ESCAPE = new Msg("CustomTokenizer.UnmatchedEscape"); //$NON-NLS-1$
--- 42,46 ----
static final Msg BLUR_BLANK = new Msg("BlurCommandWord.BlurBlank"); //$NON-NLS-1$
static final Msg BLUR_FORMAT = new Msg("BlurCommandWord.BlurFormat"); //$NON-NLS-1$
! static final Msg ENGINE_SYNTAX = new Msg("IndexSearcher.EngineSyntax"); //$NON-NLS-1$
static final Msg ILLEGAL_PASSAGE = new Msg("PassageLeftParamWord.IllegalPassage"); //$NON-NLS-1$
static final Msg UNMATCHED_ESCAPE = new Msg("CustomTokenizer.UnmatchedEscape"); //$NON-NLS-1$
Index: SubLeftParamWord.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/parse/SubLeftParamWord.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** SubLeftParamWord.java 27 Jul 2004 21:42:37 -0000 1.6
--- SubLeftParamWord.java 29 Sep 2004 22:21:23 -0000 1.7
***************
*** 36,42 ****
{
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.ParamWord#getWord(org.crosswire.jsword.book.search.parse.Parser)
*/
! public String getWord(LocalParser engine) throws BookException
{
throw new BookException(Msg.LEFT_PARAM);
--- 36,42 ----
{
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.ParamWord#getWord(org.crosswire.jsword.book.search.parse.Searcher)
*/
! public String getWord(IndexSearcher engine) throws BookException
{
throw new BookException(Msg.LEFT_PARAM);
***************
*** 44,50 ****
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.ParamWord#getPassage(org.crosswire.jsword.book.search.parse.Parser)
*/
! public Key getKeyList(LocalParser engine) throws BookException
{
Iterator it = engine.iterator();
--- 44,50 ----
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.ParamWord#getPassage(org.crosswire.jsword.book.search.parse.Searcher)
*/
! public Key getKeyList(IndexSearcher engine) throws BookException
{
Iterator it = engine.iterator();
***************
*** 79,83 ****
}
! LocalParser subEngine = new LocalParser();
subEngine.init(engine.getIndex());
subEngine.setSearchMap(engine.getSearchMap());
--- 79,83 ----
}
! IndexSearcher subEngine = new IndexSearcher();
subEngine.init(engine.getIndex());
subEngine.setSearchMap(engine.getSearchMap());
Index: PassageLeftParamWord.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/parse/PassageLeftParamWord.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** PassageLeftParamWord.java 16 Aug 2004 22:08:42 -0000 1.7
--- PassageLeftParamWord.java 29 Sep 2004 22:21:23 -0000 1.8
***************
*** 36,42 ****
{
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.ParamWord#getWord(org.crosswire.jsword.book.search.parse.Parser)
*/
! public String getWord(LocalParser engine) throws BookException
{
throw new BookException(Msg.LEFT_PARAM);
--- 36,42 ----
{
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.ParamWord#getWord(org.crosswire.jsword.book.search.parse.Searcher)
*/
! public String getWord(IndexSearcher engine) throws BookException
{
throw new BookException(Msg.LEFT_PARAM);
***************
*** 44,50 ****
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.ParamWord#Key(org.crosswire.jsword.book.search.parse.Parser)
*/
! public Key getKeyList(LocalParser engine) throws BookException
{
Iterator it = engine.iterator();
--- 44,50 ----
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.ParamWord#Key(org.crosswire.jsword.book.search.parse.Searcher)
*/
! public Key getKeyList(IndexSearcher engine) throws BookException
{
Iterator it = engine.iterator();
Index: AddCommandWord.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/parse/AddCommandWord.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** AddCommandWord.java 16 Aug 2004 22:08:42 -0000 1.7
--- AddCommandWord.java 29 Sep 2004 22:21:23 -0000 1.8
***************
*** 32,38 ****
{
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.CommandWord#updatePassage(org.crosswire.jsword.book.search.parse.Parser, org.crosswire.jsword.passage.Passage)
*/
! public void updatePassage(LocalParser engine, Key key) throws BookException
{
key.addAll(engine.iteratePassage());
--- 32,38 ----
{
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.CommandWord#updatePassage(org.crosswire.jsword.book.search.parse.Searcher, org.crosswire.jsword.passage.Passage)
*/
! public void updatePassage(IndexSearcher engine, Key key) throws BookException
{
key.addAll(engine.iteratePassage());
Index: Word.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/parse/Word.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Word.java 13 Jun 2004 00:05:21 -0000 1.1
--- Word.java 29 Sep 2004 22:21:23 -0000 1.2
***************
*** 2,6 ****
/**
! * The search.Parser uses a Vector of SearchWords to calculate a search.
* SearchWords itself is an empty interface, that is simply a place holder -
* extended by CommandWord and Word to provide interfaces that
--- 2,6 ----
/**
! * The search.Searcher uses a Vector of SearchWords to calculate a search.
* SearchWords itself is an empty interface, that is simply a place holder -
* extended by CommandWord and Word to provide interfaces that
--- NEW FILE: IndexSearcher.java ---
package org.crosswire.jsword.book.search.parse;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.crosswire.common.util.ClassUtil;
import org.crosswire.common.util.Logger;
import org.crosswire.jsword.book.BookException;
import org.crosswire.jsword.book.Search;
import org.crosswire.jsword.book.search.Index;
import org.crosswire.jsword.book.search.Searcher;
import org.crosswire.jsword.passage.Key;
/**
* The central interface to all searching.
*
* Functionality the I invisage includes:<ul>
* <li>A simple search syntax that goes something like this.<ul>
* <li>aaron, moses (verses containing aaron and moses. Can also use & or +)
* <li>aaron/moses (verses containing aaron or moses. Can also use |)
* <li>aaron - moses (verses containing aaron but not moses)
* <li>aaron ~5 , moses (verses with aaron within 5 verses of moses)
* <li>soundslike aaron (verses with words that sound like aaron. Can also use sl ...)
* <li>thesaurus happy (verses with words that mean happy. Can also use th ...)
* <li>grammar have (words like has have had and so on. Can also use gr ...)</ul>
* <li>The ability to add soundslike type extensions.</ul>
*
* <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 Joe Walker [joe at eireneh dot com]
* @version $Id: IndexSearcher.java,v 1.1 2004/09/29 22:21:23 joe Exp $
*/
public class IndexSearcher implements Searcher
{
/* (non-Javadoc)
* @see org.crosswire.jsword.book.search.Searcher#init(org.crosswire.jsword.book.search.Index)
*/
public void init(Index newindex)
{
this.index = newindex;
this.commands = getWordMap();
}
/* (non-Javadoc)
* @see org.crosswire.jsword.book.search.Searcher#search(java.lang.String, org.crosswire.jsword.passage.Key)
*/
public Key search(String search, Key restriction) throws BookException
{
output = CustomTokenizer.tokenize(search, commands);
Key key = search(output);
if (restriction != Search.UNRESTRICTED)
{
key.retainAll(restriction);
}
return key;
}
/**
* Take a search string and decipher it into a Passage.
* @param sought The string to be searched for
* @return The matching verses
*/
protected Key wordSearch(String sought) throws BookException
{
return index.findWord(sought);
}
/**
* Take a search string and decipher it into a Passage.
* @return The matching verses
*/
protected Key search(List matches) throws BookException
{
Key key = index.findWord(null);
// Need a CommandWord, but a ParamWord we can deal with using an
// AddCommandWord chucked on the front
if (matches.get(0) instanceof ParamWord)
{
// Add a default AddCommandWord to the front it there is
matches.add(0, new AddCommandWord());
}
wit = matches.iterator();
while (wit.hasNext())
{
Object temp = wit.next();
try
{
CommandWord command = (CommandWord) temp;
command.updatePassage(this, key);
}
catch (ClassCastException ex)
{
ex.printStackTrace();
throw new BookException(Msg.ENGINE_SYNTAX, new Object[] { temp });
}
}
// Set these to null so that people can't play around
// with them once they're done with, and to save memory.
matches = null;
wit = null;
return key;
}
/**
* A basic version of getPassage(String[]) simply calls getPassage(String)
* in a loop for each word, adding the Verses to an Passage that is returned
* @param words The words to search for
* @return The Passage
* @throws BookException If anything goes wrong with this method
*/
protected Key getPassage(String[] words) throws BookException
{
Key ref = index.findWord(null);
for (int i = 0; i < words.length; i++)
{
ref.addAll(wordSearch(words[i]));
}
return ref;
}
/**
* Accessor for the Bible to search.
* @return The current Bible
*/
protected Index getIndex()
{
return index;
}
/**
* Accessor for the available SearchWords. This is probably
* the same as from Options.getSearchHashtable() but just in
* case anyone has been playing around with it...
* @return The Word Hashtable
*/
protected Map getSearchMap()
{
return commands;
}
/**
* Accessor for the available SearchWords. This is probably
* the same as from Options.getSearchHashtable() but just in
* case anyone has been playing around with it...
*/
protected void setSearchMap(Map commands)
{
this.commands = commands;
}
/**
* Most Words need to access parameters, this method allows them access to
* the Searcher's own Enumerator. Use with care, and only if you are a Word
* taking part in the current search.
* @return The current Iterator
*/
protected Iterator iterator()
{
return wit;
}
/**
* @throws BookException
*/
public Key iteratePassage() throws BookException
{
if (!iterator().hasNext())
{
throw new BookException(Msg.RETAIN_BLANK);
}
Object next = iterator().next();
if (!(next instanceof ParamWord))
{
log.error("next=" + next); //$NON-NLS-1$
}
ParamWord param = (ParamWord) next;
Key ref = param.getKeyList(this);
return ref;
}
/**
* @throws BookException
*/
public String iterateWord() throws BookException
{
if (!iterator().hasNext())
{
throw new BookException(Msg.RETAIN_BLANK);
}
Object next = iterator().next();
if (!(next instanceof ParamWord))
{
log.error("next=" + next); //$NON-NLS-1$
}
ParamWord param = (ParamWord) next;
String word = param.getWord(this);
return word;
}
/**
* Accessor for the cached list of known special lookup words
*/
public static Map getWordMap()
{
if (wordMap == null)
{
Map classes = ClassUtil.getImplementorsMap(Word.class);
wordMap = new HashMap();
for (Iterator it = classes.keySet().iterator(); it.hasNext(); )
{
String key = (String) it.next();
Class clazz = (Class) classes.get(key);
try
{
wordMap.put(key, clazz.newInstance());
}
catch (Exception ex)
{
log.error("can't add CommandWord: key=" + key + " Class=" + clazz.getName(), ex); //$NON-NLS-1$ //$NON-NLS-2$
}
}
}
return wordMap;
}
/**
* The log stream
*/
private static final Logger log = Logger.getLogger(IndexSearcher.class);
/**
* The cache of known words
*/
private static Map wordMap = null;
/**
* The parsed version of the current string
*/
private List output = null;
/**
* The commands that we know about
*/
private Map commands = null;
/**
* While the answer is being worked out ...
*/
private Iterator wit = null;
/**
* The index
*/
private Index index = null;
}
Index: StartsParamWord.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/parse/StartsParamWord.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** StartsParamWord.java 16 Aug 2004 22:08:42 -0000 1.9
--- StartsParamWord.java 29 Sep 2004 22:21:23 -0000 1.10
***************
*** 4,12 ****
import org.crosswire.jsword.book.BookException;
import org.crosswire.jsword.passage.Key;
/**
! * The Search Word for a Word to search for. The default if no other SearchWords
! * match.
*
* <p><table border='1' cellPadding='3' cellSpacing='0'>
--- 4,13 ----
import org.crosswire.jsword.book.BookException;
+ import org.crosswire.jsword.book.search.Thesaurus;
+ import org.crosswire.jsword.book.search.ThesaurusFactory;
import org.crosswire.jsword.passage.Key;
/**
! * The Search Word for a Word to search for.
*
* <p><table border='1' cellPadding='3' cellSpacing='0'>
***************
*** 33,40 ****
public class StartsParamWord implements ParamWord
{
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.ParamWord#getWord(org.crosswire.jsword.book.search.parse.Parser)
*/
! public String getWord(LocalParser engine) throws BookException
{
throw new BookException(Msg.STARTS_WORD);
--- 34,49 ----
public class StartsParamWord implements ParamWord
{
+ /**
+ * Default ctor
+ */
+ public StartsParamWord() throws InstantiationException
+ {
+ thesaurus = ThesaurusFactory.createThesaurus();
+ }
+
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.ParamWord#getWord(org.crosswire.jsword.book.search.parse.Searcher)
*/
! public String getWord(IndexSearcher engine) throws BookException
{
throw new BookException(Msg.STARTS_WORD);
***************
*** 45,58 ****
* 100% match for the Passage interface. Maybe this needs to be fixed
* somehow.
! * @see org.crosswire.jsword.book.search.parse.ParamWord#getKeyList(org.crosswire.jsword.book.search.parse.LocalParser)
*/
! public Key getKeyList(LocalParser engine) throws BookException
{
String word = engine.iterateWord();
! Collection col = engine.getIndex().getStartsWith(word);
String[] words = (String[]) col.toArray(new String[col.size()]);
return engine.getPassage(words);
}
}
--- 54,72 ----
* 100% match for the Passage interface. Maybe this needs to be fixed
* somehow.
! * @see org.crosswire.jsword.book.search.parse.ParamWord#getKeyList(org.crosswire.jsword.book.search.parse.IndexSearcher)
*/
! public Key getKeyList(IndexSearcher engine) throws BookException
{
String word = engine.iterateWord();
! Collection col = thesaurus.getSynonyms(word);
String[] words = (String[]) col.toArray(new String[col.size()]);
return engine.getPassage(words);
}
+
+ /**
+ * The source of thesaurus data
+ */
+ private Thesaurus thesaurus = null;
}
Index: GrammarParamWord.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/parse/GrammarParamWord.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** GrammarParamWord.java 16 Aug 2004 22:08:42 -0000 1.9
--- GrammarParamWord.java 29 Sep 2004 22:21:23 -0000 1.10
***************
*** 4,7 ****
--- 4,10 ----
import org.crosswire.jsword.book.BookException;
+ import org.crosswire.jsword.book.search.Grammar;
+ import org.crosswire.jsword.book.search.Thesaurus;
+ import org.crosswire.jsword.book.search.ThesaurusFactory;
import org.crosswire.jsword.passage.Key;
***************
*** 33,40 ****
public class GrammarParamWord implements ParamWord
{
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.ParamWord#getWord(org.crosswire.jsword.book.search.parse.LocalParser)
*/
! public String getWord(LocalParser engine) throws BookException
{
throw new BookException(Msg.GRAMMAR_WORD);
--- 36,51 ----
public class GrammarParamWord implements ParamWord
{
+ /**
+ * Default ctor
+ */
+ public GrammarParamWord() throws InstantiationException
+ {
+ thesaurus = ThesaurusFactory.createThesaurus();
+ }
+
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.ParamWord#getWord(org.crosswire.jsword.book.search.parse.IndexSearcher)
*/
! public String getWord(IndexSearcher engine) throws BookException
{
throw new BookException(Msg.GRAMMAR_WORD);
***************
*** 42,55 ****
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.ParamWord#getPassage(org.crosswire.jsword.book.search.parse.LocalParser)
*/
! public Key getKeyList(LocalParser engine) throws BookException
{
String root = Grammar.getRoot(engine.iterateWord());
! Collection col = engine.getIndex().getStartsWith(root);
String[] words = (String[]) col.toArray(new String[col.size()]);
return engine.getPassage(words);
}
}
--- 53,71 ----
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.ParamWord#getPassage(org.crosswire.jsword.book.search.parse.IndexSearcher)
*/
! public Key getKeyList(IndexSearcher engine) throws BookException
{
String root = Grammar.getRoot(engine.iterateWord());
! Collection col = thesaurus.getSynonyms(root);
String[] words = (String[]) col.toArray(new String[col.size()]);
return engine.getPassage(words);
}
+
+ /**
+ * The source of thesaurus data
+ */
+ private Thesaurus thesaurus = null;
}
Index: RetainCommandWord.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/parse/RetainCommandWord.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** RetainCommandWord.java 27 Jul 2004 21:42:37 -0000 1.6
--- RetainCommandWord.java 29 Sep 2004 22:21:23 -0000 1.7
***************
*** 32,38 ****
{
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.CommandWord#updatePassage(org.crosswire.jsword.book.search.parse.Parser, org.crosswire.jsword.passage.Passage)
*/
! public void updatePassage(LocalParser engine, Key key) throws BookException
{
key.retainAll(engine.iteratePassage());
--- 32,38 ----
{
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.CommandWord#updatePassage(org.crosswire.jsword.book.search.parse.Searcher, org.crosswire.jsword.passage.Passage)
*/
! public void updatePassage(IndexSearcher engine, Key key) throws BookException
{
key.retainAll(engine.iteratePassage());
Index: SubRightParamWord.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/parse/SubRightParamWord.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** SubRightParamWord.java 27 Jul 2004 21:42:37 -0000 1.5
--- SubRightParamWord.java 29 Sep 2004 22:21:23 -0000 1.6
***************
*** 31,37 ****
{
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.ParamWord#getWord(org.crosswire.jsword.book.search.parse.Parser)
*/
! public String getWord(LocalParser engine) throws BookException
{
throw new BookException(Msg.RIGHT_PARAM);
--- 31,37 ----
{
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.ParamWord#getWord(org.crosswire.jsword.book.search.parse.Searcher)
*/
! public String getWord(IndexSearcher engine) throws BookException
{
throw new BookException(Msg.RIGHT_PARAM);
***************
*** 39,45 ****
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.ParamWord#getPassage(org.crosswire.jsword.book.search.parse.Parser)
*/
! public Key getKeyList(LocalParser engine) throws BookException
{
throw new BookException(Msg.RIGHT_BRACKETS);
--- 39,45 ----
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.ParamWord#getPassage(org.crosswire.jsword.book.search.parse.Searcher)
*/
! public Key getKeyList(IndexSearcher engine) throws BookException
{
throw new BookException(Msg.RIGHT_BRACKETS);
Index: RemoveCommandWord.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/parse/RemoveCommandWord.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** RemoveCommandWord.java 16 Aug 2004 22:08:42 -0000 1.7
--- RemoveCommandWord.java 29 Sep 2004 22:21:23 -0000 1.8
***************
*** 32,38 ****
{
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.CommandWord#updatePassage(org.crosswire.jsword.book.search.parse.Parser, org.crosswire.jsword.passage.Passage)
*/
! public void updatePassage(LocalParser engine, Key key) throws BookException
{
key.removeAll(engine.iteratePassage());
--- 32,38 ----
{
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.CommandWord#updatePassage(org.crosswire.jsword.book.search.parse.Searcher, org.crosswire.jsword.passage.Passage)
*/
! public void updatePassage(IndexSearcher engine, Key key) throws BookException
{
key.removeAll(engine.iteratePassage());
Index: DefaultWord.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/parse/DefaultWord.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** DefaultWord.java 8 Sep 2004 19:55:07 -0000 1.5
--- DefaultWord.java 29 Sep 2004 22:21:23 -0000 1.6
***************
*** 42,48 ****
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.ParamWord#getWord(org.crosswire.jsword.book.search.parse.LocalParser)
*/
! public String getWord(LocalParser engine)
{
return text;
--- 42,48 ----
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.ParamWord#getWord(org.crosswire.jsword.book.search.parse.IndexSearcher)
*/
! public String getWord(IndexSearcher engine)
{
return text;
***************
*** 58,64 ****
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.ParamWord#getPassage(org.crosswire.jsword.book.search.parse.LocalParser)
*/
! public Key getKeyList(LocalParser engine) throws BookException
{
return engine.wordSearch(text);
--- 58,64 ----
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.ParamWord#getPassage(org.crosswire.jsword.book.search.parse.IndexSearcher)
*/
! public Key getKeyList(IndexSearcher engine) throws BookException
{
return engine.wordSearch(text);
***************
*** 66,72 ****
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.CommandWord#updatePassage(org.crosswire.jsword.book.search.parse.Parser, org.crosswire.jsword.passage.Passage)
*/
! public void updatePassage(LocalParser engine, Key key) throws BookException
{
// We need to have DefaultWord pretend to be a CommandWord so that
--- 66,72 ----
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.CommandWord#updatePassage(org.crosswire.jsword.book.search.parse.Searcher, org.crosswire.jsword.passage.Passage)
*/
! public void updatePassage(IndexSearcher engine, Key key) throws BookException
{
// We need to have DefaultWord pretend to be a CommandWord so that
More information about the jsword-svn
mailing list