Jump to content

Please read the Forum Rules before posting.

Photo
- - - - -

e-Sword compound / complex search [Regular Expression]


11 replies to this topic

#1 Tracey

Tracey

    e-Sword Supporter

  • Veterans
  • PipPipPip
  • 36 posts
Offline

Posted 24 July 2011 - 03:32 PM

How I can search e-Sword for the following (2 separate searches - case insensitive):

Search #1- all occurrences of: "of the Lord" OR "of God" (quotations delimiting the desired phrase).

Search #2 - all occurrences words starting with "tax<wildcard>" OR "tribut<wildcard>".
For example search for words: ("tax" OR "taxed" OR "taxation"..., but NOT Artaxerxes) AND ("tribute" OR "tributary" OR "tributaries", but NOT contribution NOR distributed NOR distributeth).

Any help will be greatly appreciated.
Thanks, Tracey

#2 jonathon

jonathon

    e-Sword Fanatic

  • Contributors
  • PipPipPipPipPip
  • 753 posts
Offline

Posted 24 July 2011 - 03:38 PM

How I can search e-Sword for the following (2 separate searches - case insensitive):


Both searches require using the Regex search function.

jonathon

#3 Josh Bond

Josh Bond

    Administrator

  • Administrators
  • PipPipPipPipPip
  • 2,891 posts
  • LocationGallatin, TN
Offline

Posted 24 July 2011 - 03:46 PM

How I can search e-Sword for the following (2 separate searches - case insensitive):

Search #1- all occurrences of: "of the Lord" OR "of God" (quotations delimiting the desired phrase).

Search #2 - all occurrences words starting with "tax<wildcard>" OR "tribut<wildcard>".
For example search for words: ("tax" OR "taxed" OR "taxation"..., but NOT Artaxerxes) AND ("tribute" OR "tributary" OR "tributaries", but NOT contribution NOR distributed NOR distributeth).

Any help will be greatly appreciated.
Thanks, Tracey


You might want to read this part of the e-Sword User's Guide, which covers your first question exactly: http://www.biblesupp...nual/#lesson2.0 The tutorial also touches on Regular Expression searching but not in detail.

1) To find the exact occurrence of "of the Lord", you do not need to use quotes. Instead, click Bible/Search. Type your search phrase (no quotes). From the pull down menu to the right, select "Search for the exact phrase". Click the binocular icon (search icon) to the far right.

2) e-Sword supports Regular Expressions. That is really what your asking. Click Bible/Search. To find tax, taxed, or taxation (and other variants beginning with "tax") but not Artaxerxes (or a word ending in tax or with tax in the middle), your search query would be: \btax
Next, from the pull down menu, select "Regular Expressions (REGEX)". Click the binocular icon (search icon) to the far right. The same would apply to "tribute". To find "tribute" but not words with "tribute" in them, your search term would be: \btribute

3) To find the exact occurance "of the Lord' OR "of God", your search query would be: of the Lord|of God
and be sure to ue the Regular Expression search.

I can see this would be a great tutorial.

Edit: Misread the question, added #3 to answer.

#4 Tracey

Tracey

    e-Sword Supporter

  • Veterans
  • PipPipPip
  • 36 posts
Offline

Posted 25 July 2011 - 10:02 AM

<snip>I can see this would be a great tutorial.</snip>

Yes, a Regular Expression tutorial would be helpful.
Also, (a Plain-English / an End-User / a Non-Programmer) comprehensive explanation of Regular Expression Usage in the e-Sword-Manual-vX.pdf would be very helpful too.

Is there a way to complex search with Regular Expressions for \contains (in addition to \begins-with and \ends-with)?
I tried \cgeneration for generationS and REgeneration, but the search came up empty.
Thanks, Tracey
Just FYI, it would be very helpful if End Users did NOT have to switch back and forth between Regular Expressions and non-Regular Expressions.
I do NOT remember searching with case sensitivity, but I noticed that using the Regular Expressions grays out the case sensitivity option.

#5 Josh Bond

Josh Bond

    Administrator

  • Administrators
  • PipPipPipPipPip
  • 2,891 posts
  • LocationGallatin, TN
Offline

Posted 25 July 2011 - 10:42 AM

Is there a way to complex search with Regular Expressions for \contains (in addition to \begins-with and \ends-with)?

To search for all words with "generation" in the word, simply query: generation
And select regular expression search. By default, e-Sword will treat a search term, without a word boundary \b, as a find anywhere text.

I do NOT remember searching with case sensitivity, but I noticed that using the Regular Expressions grays out the case sensitivity option.

When you enter a search term for a Regular Expression search, it is case sensitive by default. Searching for "god" will find only lowercase instances of the word. To find JESUS or Jesus: JESUS|Jesus

Also, (a Plain-English / an End-User / a Non-Programmer) comprehensive explanation of Regular Expression Usage in the e-Sword-Manual-vX.pdf would be very helpful too.

I agree. I want to update the manual for an Advanced section regular expression usage. The problem I'm having thus far is finding the right syntax for the way Rick Meyers (e-Sword developer) implemented the regular expression searching. For example, standard regular expression syntax doesn't seem to work when excluding words during a regular expression search (if you want to find all verses with tribute anywhere in a word but exclude the verse if Lord or LORD is present). Some of what I know about regular expression searching may be MS word specific though and that may be throwing me off.

The regular expression "make the previous character optional" ? works. For example, if your Bible has the world color in one verse, and colour in another verse (spelled differently) this syntax will find either spelling: colou?r
The question mark makes the u optional.

#6 Josh Bond

Josh Bond

    Administrator

  • Administrators
  • PipPipPipPipPip
  • 2,891 posts
  • LocationGallatin, TN
Offline

Posted 25 July 2011 - 11:40 AM

This works as expected. Find all words beginning with l.
\bl\w*\b
\b marks the word boundaries. l is the beginning of the word. \w finds alphanumeric characters. * finds any number of characters before the end \b boundary mark.

Finds all words ending with l.

\b\w*l\b


Finds all verses ending with the word: God

God $


Finds all verses beginning with the word: God

^ God


e-Sword does not seem to recognize the & (and operator). And e-Sword does not seem to recognize the ! operator (not find, or exclude something). e-Sword does not recognize this standard regular expression for case case insensitive: (?i)god It should find uppercase or lowercase God (or god). Looks like it worked in a previous version, though.

#7 jonathon

jonathon

    e-Sword Fanatic

  • Contributors
  • PipPipPipPipPip
  • 753 posts
Offline

Posted 25 July 2011 - 11:52 AM

Yes, a Regular Expression tutorial would be helpful.


Regex Search

Regex is a computer term for “regular expression”.

The most important elements1 to remember are:
  • Term Symbol Action1
  • Dot . Match single character
  • Include [-] Match any listed character
  • NEGATED [^] Match any unlisted Character
  • Wild-card ? Match optional Single character
  • Wild-card * Match any number of characters
  • Plus + Match at least Once
  • Caret ^ Match at start of Line
  • Dollar $ Match at end of Line
  • Virgule Less than \< Match at start of word
  • Virgule Greater than \> Match at end of Word
  • Bar | Match either Side
  • Parenthesis ( ) Limit the search to terms within parenthesis
  • Virgule \
  • Virgule lower case b \b Word Boundary (Anchor)
  • Virgule lower case s \s White Space (Character Class)

Example One: St Paul

Search for all the times St Paul is mentioned in the Bible: The search term is ([S|P]aul)2; Save the results to a verse list;

Regex searches are case sensitive. A search for “paul” will not list any verses that mention “Paul”;

Example Two: Compound / Complex Search
Search for all occurrences of either tax* or tribut*.
The obvious, and wrong search term is “ tax* | tribut*
The problems with that search term include: Ignores instances when the word is capitalized; Does not look at word boundaries;
The search term should be “\b[Tt]ax*\b|\b[Tt]tribut*\b
  • The initial “\b” is a word boundary, and says to start with the next letter;
  • The “[“ indicates there is a choice of letters”;
  • The “Tt” are the letters that can be used;
  • The “]” indicates the choice of letters has ended;
  • The “ax” are required letters;
  • The “*” indicates any characters may follow;
  • The “\b” indicates white space ends the word;
  • The “|” indicates this is an alternative to search for;
  • The initial “\b” is a word boundary, and says to start with the next letter;
  • The “[“ indicates there is a choice of letters”;
  • The “Tt” are the letters that can be used;
  • The “]” indicates the choice of letters has ended;
  • The “ribut” are required letters;
  • The “*” indicates any characters may follow;
  • The “\b” indicates white space ends the word;

Example Three: People

How many people in the Bible have a first letter of “S”, and a last letter of “N”? Search term is [\bS*n\b]; Save the result to a verse list; You will have to read each verse, to see their names3;

1: Some of these symbols have a different meaning, when used as Boolean Search Operators.
2:[S|s|P|p] would cover both letters, in both cases. However, since both Paul and Saul are proper names, only the upper case letters need to be used.
3: Alternatively, one could look at people_places.dctx looking at all names that begin with “S”.


An e-Sword specific tutorial on Regex searching can be found at http://estudysource...._shares.aspx#40


jonathon

#8 Josh Bond

Josh Bond

    Administrator

  • Administrators
  • PipPipPipPipPip
  • 2,891 posts
  • LocationGallatin, TN
Offline

Posted 25 July 2011 - 12:10 PM


An e-Sword specific tutorial on Regex searching can be found at http://estudysource...._shares.aspx#40

jonathon

Difficult to read because of formatting but great concepts. Between those tips, what I've found, and what you've contributed, I think we have enough for a very good tutorial now.


No implementation for this, that you're aware of?

e-Sword does not seem to recognize the & (and operator): God&heavens (should search for a verse with God & heavens).

And e-Sword does not seem to recognize the ! operator (not find, or exclude something).

e-Sword does not recognize this standard regular expression for case insensitive: (?i)god It should find uppercase or lowercase God (or god). Looks like it worked in a previous version, though. A better example might be (?i)Jesus to find Jesus or JESUS. You can use the | though. Also works with any other app I try it on, just not e-Sword




#9 dyan

dyan

    e-Sword Addict

  • Veterans
  • PipPipPipPip
  • 89 posts
Offline

Posted 25 July 2011 - 12:15 PM

Another good tutorial on using regex in e-sword is found here:

http://www.layhands....gExWithE-Sword/

#10 jonathon

jonathon

    e-Sword Fanatic

  • Contributors
  • PipPipPipPipPip
  • 753 posts
Offline

Posted 25 July 2011 - 12:45 PM

No implementation for this, that you're aware of?


I don't know what Rick did when he implemented Regex search, but what works, and what does not work, literally depends upon the version of e-Sword that one is using. Bang functioned as expected in one version of e-Sword, but none of the others. Ampersand functioned as expected in one version of e-Sword, but none of the others. Those two did not function as expected in the same version of e-Sword.

Rick usually implements a function, and then leaves it alone.

I'd like to think that he is tuning the search functions for Biblical languages, but the results don't always reflect that. e-Sword 9.9.1 does search Greek better than e-Sword 9.7.2. For Hebrew and Aramaic, you are slightly better off using e-Sword 9.7.2. For either Old Church Slavonic or Georgian, e-Sword 9.8.2 (?) is your best option. On the gripping hand, I'm splitting hairs here. Other than Greek, the differences are minute, and could as easily be a result of the test strings I use, as anything else.

Something else I've noticed, is that the crafting done for creating searchable Biblical Language resources for e-Sword 9.7.2, does not always results in searchable Biblical language resources for e-Sword 9.9.1.

jonathon



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users




Similar Topics



Latest Blogs