[jsword-svn]
jsword/java/jswordtest/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/jswordtest/org/crosswire/jsword/book/search/parse
In directory www.crosswire.org:/tmp/cvs-serv8429/java/jswordtest/org/crosswire/jsword/book/search/parse
Modified Files:
WordsTest.java CustomTokenizerTest.java DictionaryTest.java
ParserTest.java FixtureParamWord.java
Log Message:
Fixes for [JS-7] and [JS-6]
Lots of search work and re-factoring
Index: CustomTokenizerTest.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jswordtest/org/crosswire/jsword/book/search/parse/CustomTokenizerTest.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** CustomTokenizerTest.java 13 Jun 2004 00:05:22 -0000 1.4
--- CustomTokenizerTest.java 29 Sep 2004 22:21:23 -0000 1.5
***************
*** 48,52 ****
public void testGetStringArray() throws Exception
{
! Map commands = LocalParser.getWordMap();
List output = null;
--- 48,52 ----
public void testGetStringArray() throws Exception
{
! Map commands = IndexSearcher.getWordMap();
List output = null;
Index: WordsTest.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jswordtest/org/crosswire/jsword/book/search/parse/WordsTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** WordsTest.java 16 Aug 2004 22:08:44 -0000 1.2
--- WordsTest.java 29 Sep 2004 22:21:23 -0000 1.3
***************
*** 38,46 ****
}
! private LocalParser engine = null;
protected void setUp() throws Exception
{
! Map commands = LocalParser.getWordMap();
commands.put("t1", new FixtureParamWord("Rut 2")); //$NON-NLS-1$ //$NON-NLS-2$
--- 38,46 ----
}
! private IndexSearcher engine = null;
protected void setUp() throws Exception
{
! Map commands = IndexSearcher.getWordMap();
commands.put("t1", new FixtureParamWord("Rut 2")); //$NON-NLS-1$ //$NON-NLS-2$
***************
*** 50,54 ****
// We shouldn't need a SearchableBible here because all of these should
// complete without any searching being done.
! engine = new LocalParser();
// FIXME: These fail because the the engine is not initialized with a valid index.
engine.init(null);
--- 50,54 ----
// We shouldn't need a SearchableBible here because all of these should
// complete without any searching being done.
! engine = new IndexSearcher();
// FIXME: These fail because the the engine is not initialized with a valid index.
engine.init(null);
***************
*** 62,115 ****
public void testAddCommandWord() throws Exception
{
! assertEquals(engine.search(new Search("t1", false)).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search(new Search("t2", false)).getName(), "Deu 28:1-1Sa 1:1"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search(new Search("/t1", false)).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search(new Search("/t2", false)).getName(), "Deu 28:1-1Sa 1:1"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search(new Search("|t1", false)).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search(new Search("|t2", false)).getName(), "Deu 28:1-1Sa 1:1"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testRetainCommandWord() throws Exception
{
! assertEquals(engine.search(new Search("t2&t1", false)).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search(new Search("t1&t2", false)).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search(new Search("t2+t1", false)).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search(new Search("t1+t2", false)).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search(new Search("t2,t1", false)).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search(new Search("t1,t2", false)).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testRemoveCommandWord() throws Exception
{
! assertEquals(engine.search(new Search("t2-t1", false)).getName(), "Deu 28-Rut 1, Rut 3:1-1Sa 1:1"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search(new Search("t1-t2", false)).getName(), ""); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testBlurCommandWord() throws Exception
{
! assertEquals(engine.search(new Search("t3 ~1", false)).getName(), "Mar 2:2-4"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search(new Search("t3 ~2", false)).getName(), "Mar 2:1-5"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search(new Search("t3 ~3", false)).getName(), "Mar 2:1-6"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search(new Search("t3 ~4", false)).getName(), "Mar 2:1-7"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search(new Search("t3 ~5", false)).getName(), "Mar 2:1-8"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testStartsParamWord() throws Exception
{
! //assertEquals(engine.search(new Search("startswith joshu", false)), engine.search(new Search("joshua", false)));
! //assertEquals(engine.search(new Search("sw joshu", false)), engine.search(new Search("joshua", false)));
}
public void testSubXParamWord() throws Exception
{
! assertEquals(engine.search(new Search("t3 / ( t2 )", false)).getName(), "Deu 28:1-1Sa 1:1, Mar 2:3"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search(new Search("t3/(t2)", false)).getName(), "Deu 28:1-1Sa 1:1, Mar 2:3"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search(new Search("t1 & t2 | t3", false)).getName(), "Rut 2, Mar 2:3"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search(new Search("t1 & t2 - t3", false)).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search(new Search("( t1 & t2 ) | t3", false)).getName(), "Rut 2, Mar 2:3"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search(new Search("t1 & ( t2 | t3 )", false)).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search(new Search("t1 & ( t2 | t3 ) & ( t3 | t2 )", false)).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search(new Search("t1&(t2|t3)&(t3|t2)", false)).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search(new Search("t1&(t2|(t3))&(t3|t2)", false)).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
}
--- 62,115 ----
public void testAddCommandWord() throws Exception
{
! assertEquals(engine.search("t1", Search.UNRESTRICTED).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t2", Search.UNRESTRICTED).getName(), "Deu 28:1-1Sa 1:1"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("/t1", Search.UNRESTRICTED).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("/t2", Search.UNRESTRICTED).getName(), "Deu 28:1-1Sa 1:1"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("|t1", Search.UNRESTRICTED).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("|t2", Search.UNRESTRICTED).getName(), "Deu 28:1-1Sa 1:1"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testRetainCommandWord() throws Exception
{
! assertEquals(engine.search("t2&t1", Search.UNRESTRICTED).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t1&t2", Search.UNRESTRICTED).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t2+t1", Search.UNRESTRICTED).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t1+t2", Search.UNRESTRICTED).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t2,t1", Search.UNRESTRICTED).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t1,t2", Search.UNRESTRICTED).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testRemoveCommandWord() throws Exception
{
! assertEquals(engine.search("t2-t1", Search.UNRESTRICTED).getName(), "Deu 28-Rut 1, Rut 3:1-1Sa 1:1"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t1-t2", Search.UNRESTRICTED).getName(), ""); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testBlurCommandWord() throws Exception
{
! assertEquals(engine.search("t3 ~1", Search.UNRESTRICTED).getName(), "Mar 2:2-4"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t3 ~2", Search.UNRESTRICTED).getName(), "Mar 2:1-5"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t3 ~3", Search.UNRESTRICTED).getName(), "Mar 2:1-6"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t3 ~4", Search.UNRESTRICTED).getName(), "Mar 2:1-7"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t3 ~5", Search.UNRESTRICTED).getName(), "Mar 2:1-8"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testStartsParamWord() throws Exception
{
! //assertEquals(engine.search("startswith joshu", Search.UNRESTRICTED), engine.search("joshua", Search.UNRESTRICTED));
! //assertEquals(engine.search("sw joshu", Search.UNRESTRICTED), engine.search("joshua", Search.UNRESTRICTED));
}
public void testSubXParamWord() throws Exception
{
! assertEquals(engine.search("t3 / ( t2 )", Search.UNRESTRICTED).getName(), "Deu 28:1-1Sa 1:1, Mar 2:3"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t3/(t2)", Search.UNRESTRICTED).getName(), "Deu 28:1-1Sa 1:1, Mar 2:3"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t1 & t2 | t3", Search.UNRESTRICTED).getName(), "Rut 2, Mar 2:3"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t1 & t2 - t3", Search.UNRESTRICTED).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("( t1 & t2 ) | t3", Search.UNRESTRICTED).getName(), "Rut 2, Mar 2:3"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t1 & ( t2 | t3 )", Search.UNRESTRICTED).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t1 & ( t2 | t3 ) & ( t3 | t2 )", Search.UNRESTRICTED).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t1&(t2|t3)&(t3|t2)", Search.UNRESTRICTED).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
! assertEquals(engine.search("t1&(t2|(t3))&(t3|t2)", Search.UNRESTRICTED).getName(), "Rut 2"); //$NON-NLS-1$ //$NON-NLS-2$
}
***************
*** 131,136 ****
public void testUpdatePassage() throws Exception
{
! //assertEquals(engine.search(new Search("grammar joseph", false)), engine.search(new Search("joseph / joseph's", false)));
! //assertEquals(engine.search(new Search("new Search(gr joseph", false)), engine.search(new Search("joseph / joseph's", false)));
}
}
\ No newline at end of file
--- 131,136 ----
public void testUpdatePassage() throws Exception
{
! //assertEquals(engine.search("grammar joseph", Search.UNRESTRICTED), engine.search("joseph / joseph's", Search.UNRESTRICTED));
! //assertEquals(engine.search("gr joseph", Search.UNRESTRICTED), engine.search("joseph / joseph's", Search.UNRESTRICTED));
}
}
\ No newline at end of file
Index: ParserTest.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jswordtest/org/crosswire/jsword/book/search/parse/ParserTest.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** ParserTest.java 16 Aug 2004 22:08:44 -0000 1.6
--- ParserTest.java 29 Sep 2004 22:21:23 -0000 1.7
***************
*** 49,74 ****
// We shouldn't need a SearchableBible here because all of these should
// fail before any searching is done.
! LocalParser engine = new LocalParser();
// FIXME: These fail because the the engine is not initialized with a valid index.
engine.init(null);
//try { engine.search(new Search("moses aaron", false)); fail(); } catch (BookException ex) { }
! try { engine.search(new Search("(", false)); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search(new Search("~", false)); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search(new Search(")", false)); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search(new Search("&", false)); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search(new Search(",", false)); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search(new Search("+", false)); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search(new Search("-", false)); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search(new Search("/", false)); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search(new Search("|", false)); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search(new Search("sw", false)); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search(new Search("startswith", false)); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search(new Search("gr", false)); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search(new Search("grammar", false)); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! //try { engine.search(new Search("moses ( aaron )", false)); fail(); } catch (BookException ex) { }
! //try { engine.search(new Search("moses & ( aaron", false)); fail(); } catch (BookException ex) { }
! //try { engine.search(new Search("moses & ( aaron", false)); fail(); } catch (BookException ex) { }
! //try { engine.search(new Search("( moses ( aaron ) )", false)); fail(); } catch (BookException ex) { }
}
--- 49,74 ----
// We shouldn't need a SearchableBible here because all of these should
// fail before any searching is done.
! IndexSearcher engine = new IndexSearcher();
// FIXME: These fail because the the engine is not initialized with a valid index.
engine.init(null);
//try { engine.search(new Search("moses aaron", false)); fail(); } catch (BookException ex) { }
! try { engine.search("(", Search.UNRESTRICTED); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search("~", Search.UNRESTRICTED); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search(")", Search.UNRESTRICTED); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search("&", Search.UNRESTRICTED); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search(",", Search.UNRESTRICTED); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search("+", Search.UNRESTRICTED); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search("-", Search.UNRESTRICTED); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search("/", Search.UNRESTRICTED); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search("|", Search.UNRESTRICTED); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search("sw", Search.UNRESTRICTED); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search("startswith", Search.UNRESTRICTED); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search("gr", Search.UNRESTRICTED); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! try { engine.search("grammar", Search.UNRESTRICTED); fail(); } catch (BookException ex) { } //$NON-NLS-1$
! //try { engine.search("moses ( aaron )", Search.UNRESTRICTED); fail(); } catch (BookException ex) { }
! //try { engine.search("moses & ( aaron", Search.UNRESTRICTED); fail(); } catch (BookException ex) { }
! //try { engine.search("moses & ( aaron", Search.UNRESTRICTED); fail(); } catch (BookException ex) { }
! //try { engine.search("( moses ( aaron ) )", Search.UNRESTRICTED); fail(); } catch (BookException ex) { }
}
***************
*** 78,82 ****
version = new FileBible();
commands = Options.getSearchHashtable();
! engine = new Parser(version, commands);
PassageTally tally = engine.bestMatch("for god so loved the world that he gave his one and only son");
--- 78,82 ----
version = new FileBible();
commands = Options.getSearchHashtable();
! engine = new Searcher(version, commands);
PassageTally tally = engine.bestMatch("for god so loved the world that he gave his one and only son");
Index: DictionaryTest.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jswordtest/org/crosswire/jsword/book/search/parse/DictionaryTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** DictionaryTest.java 9 Apr 2004 13:39:10 -0000 1.3
--- DictionaryTest.java 29 Sep 2004 22:21:23 -0000 1.4
***************
*** 2,5 ****
--- 2,7 ----
package org.crosswire.jsword.book.search.parse;
+ import org.crosswire.jsword.book.search.Grammar;
+
import junit.framework.TestCase;
Index: FixtureParamWord.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jswordtest/org/crosswire/jsword/book/search/parse/FixtureParamWord.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** FixtureParamWord.java 27 Jul 2004 21:42:38 -0000 1.4
--- FixtureParamWord.java 29 Sep 2004 22:21:23 -0000 1.5
***************
*** 20,26 ****
/* (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(new MsgBase("Can't get a word from a startswith command"){}); //$NON-NLS-1$
--- 20,26 ----
/* (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(new MsgBase("Can't get a word from a startswith command"){}); //$NON-NLS-1$
***************
*** 28,34 ****
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.ParamWord#getPassage(org.crosswire.jsword.book.search.parse.Parser)
*/
! public Key getKeyList(LocalParser engine)
{
try
--- 28,34 ----
/* (non-Javadoc)
! * @see org.crosswire.jsword.book.search.parse.ParamWord#getPassage(org.crosswire.jsword.book.search.parse.Searcher)
*/
! public Key getKeyList(IndexSearcher engine)
{
try
More information about the jsword-svn
mailing list