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

jswordcvs at crosswire.org jswordcvs at crosswire.org
Sat Oct 9 14:45:07 MST 2004


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

Modified Files:
	Msg.properties PhraseParamWord.java IndexSearcher.java 
	Msg.java 
Log Message:
indexing updates

Index: Msg.properties
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/parse/Msg.properties,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Msg.properties	27 Jun 2004 22:09:15 -0000	1.2
--- Msg.properties	9 Oct 2004 21:45:05 -0000	1.3
***************
*** 22,23 ****
--- 22,25 ----
  PassageLeftParamWord.IllegalPassage=Syntax Error: Invalid passage "{0}"
  CustomTokenizer.UnmatchedEscape=Syntax Error: Unmatched brackets - [ and ]
+ PhraseParamWord.SingleParam=Can''t get a word from a sub-expression (processing ''"'').
+ PhraseParamWord.NoThesaurus=Couldn't create a thesaurus.

Index: IndexSearcher.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/parse/IndexSearcher.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** IndexSearcher.java	2 Oct 2004 23:51:12 -0000	1.2
--- IndexSearcher.java	9 Oct 2004 21:45:05 -0000	1.3
***************
*** 11,15 ****
  import org.crosswire.common.util.ResourceUtil;
  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;
--- 11,14 ----
***************
*** 65,79 ****
       * @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;
      }
  
--- 64,71 ----
       * @see org.crosswire.jsword.book.search.Searcher#search(java.lang.String, org.crosswire.jsword.passage.Key)
       */
!     public Key search(String search) throws BookException
      {
          output = CustomTokenizer.tokenize(search, commands);
!         return search(output);
      }
  
***************
*** 290,298 ****
       * Accessor for the cached list of known special lookup words
       */
!     public static Map getPreferredMap()
      {
          // Check the maps have been created
          getWordMap();
!         return preferredMap;
      }
  
--- 282,290 ----
       * Accessor for the cached list of known special lookup words
       */
!     public static String getPreferredSyntax(Class command)
      {
          // Check the maps have been created
          getWordMap();
!         return (String) preferredMap.get(command);
      }
  

Index: PhraseParamWord.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/parse/PhraseParamWord.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** PhraseParamWord.java	2 Oct 2004 23:51:12 -0000	1.1
--- PhraseParamWord.java	9 Oct 2004 21:45:05 -0000	1.2
***************
*** 1,10 ****
  package org.crosswire.jsword.book.search.parse;
  
  import java.util.Iterator;
  
  import org.crosswire.jsword.book.BookException;
! import org.crosswire.jsword.book.search.Index;
  import org.crosswire.jsword.passage.Key;
! import org.crosswire.jsword.passage.NoSuchKeyException;
  
  /**
--- 1,15 ----
  package org.crosswire.jsword.book.search.parse;
  
+ import java.util.Collection;
  import java.util.Iterator;
  
  import org.crosswire.jsword.book.BookException;
! import org.crosswire.jsword.book.SentanceUtil;
! 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;
! import org.crosswire.jsword.passage.PassageTally;
! import org.crosswire.jsword.passage.RestrictionType;
  
  /**
***************
*** 40,44 ****
      public String getWord(IndexSearcher engine) throws BookException
      {
!         throw new BookException(Msg.LEFT_PARAM);
      }
  
--- 45,49 ----
      public String getWord(IndexSearcher engine) throws BookException
      {
!         throw new BookException(Msg.SINGLE_PARAM);
      }
  
***************
*** 51,55 ****
          StringBuffer buff = new StringBuffer();
  
-         int paren_level = 1;
          while (true)
          {
--- 56,59 ----
***************
*** 63,76 ****
              if (word instanceof PhraseParamWord)
              {
-                 paren_level++;
-             }
- 
-             if (word instanceof PassageRightParamWord)
-             {
-                 paren_level--;
-             }
- 
-             if (paren_level == 0)
-             {
                  break;
              }
--- 67,70 ----
***************
*** 80,93 ****
          }
  
!         try
          {
!             Index index = engine.getIndex();
  
!             return index.getKey(buff.toString());
          }
!         catch (NoSuchKeyException ex)
          {
!             throw new BookException(Msg.ILLEGAL_PASSAGE, ex, new Object[] { buff.toString() });
          }
      }
  }
--- 74,141 ----
          }
  
!         return bestMatch(engine, buff.toString());
!     }
! 
!     /* (non-Javadoc)
!      * @see org.crosswire.jsword.book.search.Matcher#bestMatch(java.lang.String, org.crosswire.jsword.passage.Key)
!      */
!     public Key bestMatch(IndexSearcher engine, String sought) throws BookException
!     {
!         if (thesaurus == null)
          {
!             try
!             {
!                 thesaurus = ThesaurusFactory.createThesaurus();
!             }
!             catch (InstantiationException ex)
!             {
!                 throw new BookException(Msg.NO_THESAURUS, ex);
!             }
!         }
  
!         String[] words = SentanceUtil.getWords(sought);
!         words = Grammar.stripSmallWords(words);
!         // log.fine("words="+StringUtil.toString(words));
! 
!         PassageTally tally = new PassageTally();
!         tally.blur(BLUR_BY, RestrictionType.NONE);
! 
!         for (int i = 0; i < words.length; i++)
!         {
!             tally.addAll(engine.getIndex().findWord(words[i]));
          }
! 
!         // This uses updatePassageTallyFlat() so that words like God
!         // that have many startsWith() matches, and hence many verse
!         // matches, do not end up with wrongly high scores.
!         for (int i = 0; i < words.length; i++)
          {
!             // log.fine("  root="+root);
!             Collection col = thesaurus.getSynonyms(words[i]);
!             String[] grWords = (String[]) col.toArray(new String[col.size()]);
! 
!             // log.fine("  gr_words="+StringUtil.toString(gr_words));
!             PassageTally temp = new PassageTally();
! 
!             for (int j = 0; j < grWords.length; j++)
!             {
!                 temp.addAll(engine.getIndex().findWord(grWords[j]));
!             }
! 
!             temp.flatten();
!             tally.addAll(temp);
          }
+ 
+         return tally;
      }
+ 
+     /**
+      * How we get related words
+      */
+     private Thesaurus thesaurus;
+ 
+     /**
+      * How many verses do we blur by?
+      */
+     private static final int BLUR_BY = 2;
  }

Index: Msg.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/search/parse/Msg.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** Msg.java	29 Sep 2004 22:21:23 -0000	1.9
--- Msg.java	9 Oct 2004 21:45:05 -0000	1.10
***************
*** 45,48 ****
--- 45,50 ----
      static final Msg ILLEGAL_PASSAGE = new Msg("PassageLeftParamWord.IllegalPassage"); //$NON-NLS-1$
      static final Msg UNMATCHED_ESCAPE = new Msg("CustomTokenizer.UnmatchedEscape"); //$NON-NLS-1$
+     static final Msg SINGLE_PARAM = new Msg("PhraseParamWord.SingleParam"); //$NON-NLS-1$
+     static final Msg NO_THESAURUS = new Msg("PhraseParamWord.NoThesaurus"); //$NON-NLS-1$
  
      /**



More information about the jsword-svn mailing list