[jsword-devel] regex searching

trent.jsword at trentonadams.ca trent.jsword at trentonadams.ca
Thu Feb 25 17:10:41 MST 2010


Well, I don't know how fast loading verses is in jsword, but my app takes .18 seconds, or possibly a little more depending on what you search for, for searching the entire bible. The bible text is on one verse per line, so there's no need to load one verse at a time. An example of a slow search, which is rare, would be "the.*or", which takes 18.32 seconds because it loads almost the entire bible over the internet, being that LARGE portions of scripture are found, lol) 

Try "blood.*sacrifice" on http://www.trentonadams.ca/biblesearch for an example of a relatively fast search. 

I can't imagine it being a "huge" amount slower with jsword, unless the file types that the data is stored in are particularly slow loading verses. But, jsword seems snappy enough, so I doubt it would be a problem. 

But, if regex was implemented, you could allow the person to specify "within X verses of each other". i.e. "wash" would be in v3 and "word" would be in v4 But it would probably require strange verse concatenations for one attempt, no concatenations for another attempt, shifting one verse at a time through the whole bible, etc, unless you wrote a regular expression parser of your own, that could find certain parts in one verse, and other parts in another. But that gets really complicated. So, on first thought, finding regular expressions between verses would be VERY time consuming. But that's just off the top of my head, so who knows, you might be able to do something fast. ;) 

----- "Sijo Cherian" <sijo.cherian at gmail.com> wrote: 
> From: "Sijo Cherian" <sijo.cherian at gmail.com> 
> To: "J-Sword Developers Mailing List" <jsword-devel at crosswire.org> 
> Sent: Thursday, February 25, 2010 5:46:17 PM GMT -06:00 US/Canada Central 
> Subject: Re: [jsword-devel] regex searching 
> 
> What about finding terms across verse boudaries? As far as I remember the index documents are on per verse basis. So there is no way lucene query can find nearby words in a paragraph (across verse boundaries). Regex can help if we string-together verses or use Passage, but like DM mentioned, it will be slow to run regex (regex can be compiled once, but it has to run on so many verse strings). 

> 
BTW Is anyone working on getting search result highlighting? What needs to done besides using lucene-highlighter during the search? 

> 
-Sijo 

> 
> On Wed, Feb 24, 2010 at 11:05 PM, DM Smith < dmsmith at crosswire.org > wrote: 
> 

JSword search indexes support the full search syntax of Lucene. This has some support for regular expressions. Specifically, it allows for * to mean zero or more characters. I think we've got the Lucene flag to allow prefix wild cards. Note that this is more like what a shell uses: it is not a modifier for the previous character. 
> 
> It was correctly noted that wash.*word will not search the verse as a whole. Lucene search is based on words. The correct pattern in Lucene would be wash*word, as '.' does not mean any character but rather it means a punctuation mark. So "wash.*word" would be split into "wash *word" and would find all verses with the word "wash" and any word ending with "word", such as "sword". 
> 
> The default connector for JSword is OR. It would be good to add the ability for a user to change it to AND. With that, "wash* word" would produce the expected results as it would be interpreted as "wash* AND word" instead of "wash* OR word". (Choice would be some thing like "Search for ALL words instead of ANY words.") We made OR the default because it more closely matched various familiar search engines, such as Google, and because it is the default of Lucene. 
> 
> Lucene does have a regular expression capability, but it is not part of JSword. It would be a good addition. Still, it would be based on words and not on the text of a verse. 
> 
> Adding the ability to search an arbitrary regular expression would be a good addition. I don't think it would be too hard to add it. Jsword already has the interface for any search implementation. Java's Regex is a variant of Perl's but has a bit more power. There are some issues: We'll be adding highlighting to Lucene's search. Adding that to Regex would be a separate effort. The regex search would be mutually exclusive from Lucene search, so that would need to be made obvious. (In The SWORD Project for Windows, they have both it is a bit confusing as it is not clear.) 
> 
> And yes, it will need to go throw the "plain" text of each verse. It will be about as slow as creating an index. Basically, it will need to take the raw verse and strip the markup. (This is part of JSword already and Lucene indexing uses it.) And perhaps strip out the punctuation. Finally doing the search. 
> 
> If you want, add an issue or two to Jira ( www.crosswire.org/bugs ) under JSword. That way it won't be forgotten. 
> 
> In Christ, 
> DM 


> 
> 
> 
> On 02/23/2010 08:33 PM, Trenton D. Adams wrote: 
> 

But then again, I wonder if it's even needed, who knows. 
> 
> ----- "Trenton D. Adams"< trent.jsword at trentonadams.ca > wrote: 
> 
> 
> 

From: "Trenton D. Adams"< trent.jsword at trentonadams.ca > 
> To: "J-Sword Developers Mailing"< jsword-devel at crosswire.org > 
> Sent: Tuesday, February 23, 2010 7:29:08 PM GMT -06:00 US/Canada Central 
> Subject: [jsword-devel] regex searching 
> 
> Hello, 
> 
> I'm getting the impression that regular expression searching is not at 
> all possible without implementing something that loads the books 
> itself, and goes through each verse of the bible. Is this true? 
> 
> It seems like the Lucene Index just doesn't support regular expression 
> searches, eh? And it also seems like SearcherFactory is currently not 
> finished being implemented as a SearcherFactory, correct? Or, perhaps 
> other methods need to be added, like createSearcher(Book, Class 
> searcherClass)??? Then you could provide another searcher type. 
> 
> What would be appropriate for this? adding the new 
> SearcherFactory.createSearcher(), adding another "find" method to 
> AbstractBook/Book that is something like "find(SearchRequest, 
> Searcher)"??? 
> 
> Are the books and everything abstract enough that I can search them by 
> loading the text? Or would I have to restrict it to the book types I 
> know how to parse? 
> 
> Anything else? 
> 
> Thanks. 
> 
> _______________________________________________ 
> jsword-devel mailing list 
> jsword-devel at crosswire.org 
> http://www.crosswire.org/mailman/listinfo/jsword-devel 
> 
> _______________________________________________ 
> jsword-devel mailing list 
> jsword-devel at crosswire.org 
> http://www.crosswire.org/mailman/listinfo/jsword-devel 
> 
> 
> 
> _______________________________________________ 
> jsword-devel mailing list 
> jsword-devel at crosswire.org 
> http://www.crosswire.org/mailman/listinfo/jsword-devel 
> 
> 

> -- 
> Regards, 
> Sijo 
> 
> _______________________________________________ jsword-devel mailing list jsword-devel at crosswire.org http://www.crosswire.org/mailman/listinfo/jsword-devel 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.crosswire.org/pipermail/jsword-devel/attachments/20100225/1b8ac227/attachment-0001.html>


More information about the jsword-devel mailing list