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

jswordcvs at crosswire.org jswordcvs at crosswire.org
Sun May 1 18:29:34 MST 2005


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

Modified Files:
	BaseQuery.java LuceneThesarus.java LuceneIndex.java 
	RangeQuery.java BlurQuery.java OrQuery.java 
	ExtendedLuceneSyntax.java AndQuery.java BinaryQuery.java 
	Query.java QueryBuilder.java AndNotQuery.java 
Log Message:
Fixed the bug where notes were being indexed by adding getVerseText as a replacement for getPlainText. The latter is still needed for non-bibles.
Also cleaned up checkstyle reports and added/corrected javadoc.

Index: RangeQuery.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/lucene/RangeQuery.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** RangeQuery.java	25 Apr 2005 01:22:23 -0000	1.1
--- RangeQuery.java	2 May 2005 01:29:32 -0000	1.2
***************
*** 28,32 ****
   * </font></td></tr></table>
   * @see gnu.gpl.Licence
!  * @author DM Smith [ dmsmith555 at hotmail dot com]
   * @version $Id$
   */
--- 28,32 ----
   * </font></td></tr></table>
   * @see gnu.gpl.Licence
!  * @author DM Smith [ dmsmith555 at yahoo dot com]
   * @version $Id$
   */

Index: BaseQuery.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/lucene/BaseQuery.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** BaseQuery.java	25 Apr 2005 01:22:23 -0000	1.1
--- BaseQuery.java	2 May 2005 01:29:32 -0000	1.2
***************
*** 26,30 ****
   * </font></td></tr></table>
   * @see gnu.gpl.Licence
!  * @author DM Smith [ dmsmith555 at hotmail dot com]
   * @version $Id$
   */
--- 26,30 ----
   * </font></td></tr></table>
   * @see gnu.gpl.Licence
!  * @author DM Smith [ dmsmith555 at yahoo dot com]
   * @version $Id$
   */

Index: LuceneThesarus.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/lucene/LuceneThesarus.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** LuceneThesarus.java	1 Apr 2005 17:09:47 -0000	1.2
--- LuceneThesarus.java	2 May 2005 01:29:32 -0000	1.3
***************
*** 28,32 ****
   * </font></td></tr></table>
   * @see gnu.gpl.Licence
!  * @author DM Smith [dmsmith555 at gmail dot com]
   * @version $Id$
   */
--- 28,32 ----
   * </font></td></tr></table>
   * @see gnu.gpl.Licence
!  * @author DM Smith [dmsmith555 at yahoo dot com]
   * @version $Id$
   */

Index: BlurQuery.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/lucene/BlurQuery.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** BlurQuery.java	25 Apr 2005 01:22:23 -0000	1.1
--- BlurQuery.java	2 May 2005 01:29:32 -0000	1.2
***************
*** 27,31 ****
   * </font></td></tr></table>
   * @see gnu.gpl.Licence
!  * @author DM Smith [ dmsmith555 at hotmail dot com]
   * @version $Id$
   */
--- 27,31 ----
   * </font></td></tr></table>
   * @see gnu.gpl.Licence
!  * @author DM Smith [ dmsmith555 at yahoo dot com]
   * @version $Id$
   */

Index: LuceneIndex.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/lucene/LuceneIndex.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** LuceneIndex.java	25 Apr 2005 01:22:23 -0000	1.16
--- LuceneIndex.java	2 May 2005 01:29:32 -0000	1.17
***************
*** 293,299 ****
          int percent = 0;
          String name = ""; //$NON-NLS-1$
          for (Iterator it = key.iterator(); it.hasNext(); )
          {
!             Key subkey = (Key) it.next();
              if (subkey.canHaveChildren())
              {
--- 293,304 ----
          int percent = 0;
          String name = ""; //$NON-NLS-1$
+         String text = ""; //$NON-NLS-1$
+         BookData data = null;
+         Key subkey = null;
+         Verse verse = null;
+         Document doc = null;
          for (Iterator it = key.iterator(); it.hasNext(); )
          {
!             subkey = (Key) it.next();
              if (subkey.canHaveChildren())
              {
***************
*** 302,306 ****
              else
              {
!                 BookData data = null;
                  try
                  {
--- 307,311 ----
              else
              {
!                 data = null;
                  try
                  {
***************
*** 313,322 ****
                  }
  
!                 String text = data.getPlainText();
  
                  // Do the actual indexing
                  if (text != null && text.length() > 0)
                  {
!                     Document doc = new Document();
                      doc.add(Field.UnIndexed(FIELD_NAME, subkey.getOSISName()));
                      doc.add(Field.Text(FIELD_BODY, new StringReader(text)));
--- 318,327 ----
                  }
  
!                 text = data.getVerseText();
  
                  // Do the actual indexing
                  if (text != null && text.length() > 0)
                  {
!                     doc = new Document();
                      doc.add(Field.UnIndexed(FIELD_NAME, subkey.getOSISName()));
                      doc.add(Field.Text(FIELD_BODY, new StringReader(text)));
***************
*** 325,329 ****
  
                  // report progress
!                 Verse verse = KeyUtil.getVerse(subkey);
  
                  try
--- 330,334 ----
  
                  // report progress
!                 verse = KeyUtil.getVerse(subkey);
  
                  try

Index: OrQuery.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/lucene/OrQuery.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** OrQuery.java	25 Apr 2005 01:22:23 -0000	1.1
--- OrQuery.java	2 May 2005 01:29:32 -0000	1.2
***************
*** 26,30 ****
   * </font></td></tr></table>
   * @see gnu.gpl.Licence
!  * @author DM Smith [ dmsmith555 at hotmail dot com]
   * @version $Id$
   */
--- 26,30 ----
   * </font></td></tr></table>
   * @see gnu.gpl.Licence
!  * @author DM Smith [ dmsmith555 at yahoo dot com]
   * @version $Id$
   */

Index: ExtendedLuceneSyntax.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/lucene/ExtendedLuceneSyntax.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ExtendedLuceneSyntax.java	25 Apr 2005 01:22:23 -0000	1.1
--- ExtendedLuceneSyntax.java	2 May 2005 01:29:32 -0000	1.2
***************
*** 5,9 ****
  
  /**
!  *
   * <p><table border='1' cellPadding='3' cellSpacing='0'>
   * <tr><td bgColor='white' class='TableRowColor'><font size='-7'>
--- 5,11 ----
  
  /**
!  * ExtendedLuceneSyntax represents the extension of stock Lucene syntax
!  * with passage ranges and with blurring (searching in nearby verses)
!  * 
   * <p><table border='1' cellPadding='3' cellSpacing='0'>
   * <tr><td bgColor='white' class='TableRowColor'><font size='-7'>
***************
*** 24,28 ****
   * </font></td></tr></table>
   * @see gnu.gpl.Licence
!  * @author DM Smith [ dmsmith555 at hotmail dot com]
   * @version $Id$
   */
--- 26,30 ----
   * </font></td></tr></table>
   * @see gnu.gpl.Licence
!  * @author DM Smith [ dmsmith555 at yahoo dot com]
   * @version $Id$
   */

Index: BinaryQuery.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/lucene/BinaryQuery.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** BinaryQuery.java	25 Apr 2005 01:22:23 -0000	1.1
--- BinaryQuery.java	2 May 2005 01:29:32 -0000	1.2
***************
*** 22,26 ****
   * </font></td></tr></table>
   * @see gnu.gpl.Licence
!  * @author DM Smith [ dmsmith555 at hotmail dot com]
   * @version $Id$
   */
--- 22,26 ----
   * </font></td></tr></table>
   * @see gnu.gpl.Licence
!  * @author DM Smith [ dmsmith555 at yahoo dot com]
   * @version $Id$
   */

Index: AndQuery.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/lucene/AndQuery.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** AndQuery.java	25 Apr 2005 01:22:23 -0000	1.1
--- AndQuery.java	2 May 2005 01:29:32 -0000	1.2
***************
*** 26,30 ****
   * </font></td></tr></table>
   * @see gnu.gpl.Licence
!  * @author DM Smith [ dmsmith555 at hotmail dot com]
   * @version $Id$
   */
--- 26,30 ----
   * </font></td></tr></table>
   * @see gnu.gpl.Licence
!  * @author DM Smith [ dmsmith555 at yahoo dot com]
   * @version $Id$
   */

Index: Query.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/lucene/Query.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Query.java	25 Apr 2005 01:22:23 -0000	1.1
--- Query.java	2 May 2005 01:29:32 -0000	1.2
***************
*** 26,30 ****
   * </font></td></tr></table>
   * @see gnu.gpl.Licence
!  * @author Joe Walker [joe at eireneh dot com]
   * @version $Id$
   */
--- 26,30 ----
   * </font></td></tr></table>
   * @see gnu.gpl.Licence
!  * @author DM Smith [dmsmith555 at yahoo dot com]
   * @version $Id$
   */

Index: AndNotQuery.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/lucene/AndNotQuery.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** AndNotQuery.java	25 Apr 2005 01:22:23 -0000	1.1
--- AndNotQuery.java	2 May 2005 01:29:32 -0000	1.2
***************
*** 27,31 ****
   * </font></td></tr></table>
   * @see gnu.gpl.Licence
!  * @author DM Smith [ dmsmith555 at hotmail dot com]
   * @version $Id$
   */
--- 27,31 ----
   * </font></td></tr></table>
   * @see gnu.gpl.Licence
!  * @author DM Smith [ dmsmith555 at yahoo dot com]
   * @version $Id$
   */

Index: QueryBuilder.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/lucene/QueryBuilder.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** QueryBuilder.java	25 Apr 2005 01:22:23 -0000	1.1
--- QueryBuilder.java	2 May 2005 01:29:32 -0000	1.2
***************
*** 31,35 ****
   * </font></td></tr></table>
   * @see gnu.gpl.Licence
!  * @author Joe Walker [joe at eireneh dot com]
   * @version $Id$
   */
--- 31,35 ----
   * </font></td></tr></table>
   * @see gnu.gpl.Licence
!  * @author DM Smith [dmsmith555 at yahoo dot com]
   * @version $Id$
   */
***************
*** 62,75 ****
          String rangeModifier = null;
          // Look for a range +[...], -[...], or [...]
!         Matcher rangeMatcher = rangePattern.matcher(sought);
          if (rangeMatcher.find())
          {
              rangeModifier = rangeMatcher.group(1);
              range = new RangeQuery(rangeMatcher.group(2));
!             sought = sought.substring(rangeMatcher.end()-1);
          }
  
          // Look for a blur ~n
!         Matcher blurMatcher = blurPattern.matcher(sought);
          if (blurMatcher.find())
          {
--- 62,75 ----
          String rangeModifier = null;
          // Look for a range +[...], -[...], or [...]
!         Matcher rangeMatcher = RANGE_PATTERN.matcher(sought);
          if (rangeMatcher.find())
          {
              rangeModifier = rangeMatcher.group(1);
              range = new RangeQuery(rangeMatcher.group(2));
!             sought = sought.substring(rangeMatcher.end() - 1);
          }
  
          // Look for a blur ~n
!         Matcher blurMatcher = BLUR_PATTERN.matcher(sought);
          if (blurMatcher.find())
          {
***************
*** 88,92 ****
              query = new BaseQuery(sought);
          }
!         
          if (range != null)
          {
--- 88,92 ----
              query = new BaseQuery(sought);
          }
! 
          if (range != null)
          {
***************
*** 119,128 ****
       * perhaps surrounded by whitespace.
       */
!     private static final Pattern rangePattern = Pattern.compile("^\\s*([-+]?)\\[([^\\[\\]]+)\\]\\s*"); //$NON-NLS-1$
  
      /**
       * The pattern of a blur. ~, optionally followed by a number, representing the number of verses
       */
!     private static final Pattern blurPattern = Pattern.compile("\\s~(\\d*)?\\s"); //$NON-NLS-1$
  
  }
--- 119,128 ----
       * perhaps surrounded by whitespace.
       */
!     private static final Pattern RANGE_PATTERN = Pattern.compile("^\\s*([-+]?)\\[([^\\[\\]]+)\\]\\s*"); //$NON-NLS-1$
  
      /**
       * The pattern of a blur. ~, optionally followed by a number, representing the number of verses
       */
!     private static final Pattern BLUR_PATTERN = Pattern.compile("\\s~(\\d*)?\\s"); //$NON-NLS-1$
  
  }



More information about the jsword-svn mailing list