Jump to content


Photo

RegexForAccordance

regex

  • Please log in to reply
26 replies to this topic

#1 Darin Franklin

Darin Franklin

    Bronze

  • Active Members
  • PipPip
  • 96 posts
  • Gender:Male
  • Accordance Version:12.x
  • Platforms:Mac OS X, Android

Posted 11 December 2014 - 12:48 AM

I thought it would be fun to search Hebrew and Greek Bible texts with regular expressions, so I wrote a Mac app to do just that.  RegexForAccordance can search any text module in Accordance (English too).

Screen%20Shot%20Hebrew.png

RegexForAccordance gets Unicode text from Accordance through AppleScript and then searches it line by line. Here are a few examples of what you can do.

Find Greek words that end with ημι
Text Module: GNT-T
Range: Matt-Rev
Search: \w+ημι\b
Filters: Remove Diacritics
Result: τιθημι, φημι, αφιημι, Συνιστημι, συμφημι

Find Repeated Phrases in the Greek New Testament
Text Module: GNT-T
Range: Matt-Rev
Option: Ignore Case
Filters: None (Remove Diacritics for more matches)
Search: \b(.+)\s+\1\b
Result:

Screen%20Shot%20Greek%20Repeated.png

By including the verse reference in the search, you can produce some interesting verse lists.

Find verse 3:16 in every book
http://www.accordanc...showtopic=13286
Text Module: KJV
Range: Gen-Rev
Option: Include Reference
Search: \b3:16\b
Result: Gen 3:16, Exod 3:16, ..., Rev 3:16.

Find "Tweetable" verses in ESV (140 characters or less, including the reference)
http://www.accordanc...showtopic=14557
Text Module: ESV
Range: Gen-Rev
Option: Include Reference
Filters: Remove Pilcrows and Trailing Spaces
Search: ^.{1,140}$
Results: 18445 verses

The statistics table on the right side of the search window shows the count and length of each hit, so you can do statistical studies on letters, words, or phrases.

Count Hebrew Vowels in Psalm 22
Text Module: HMT-W4
Range: Ps 22
Filters: Remove Cantillation
Search: .
Result:
Screen%20Shot%20Hebrew%20Vowels.png

RegexForAccordance uses ICU Regular Expression syntax, provided by Apple.

Find Palindromes in Hebrew
(similar search in Accordance: http://www.accordanc...Is-A-Palindrome )
Text module: HMT-W4
Filter: Remove Cantillation and Points
Search: \b(?:(\w)\w?\1|(\w)(\w)\w?\3\2|(\w)(\w)(\w)\w?\6\5\4)\b
Result: 102 distinct hits
Prov 30:1  דברי ׀ אגור בן־יקה המשא נאם הגבר לאיתיאל לאיתיאל ואכל׃

Find five consecutive words which begin with the letters אלהימ
Text module: HMT-W4
Filter: None
Search: \bא\w*\W+ל\w*\W+ה\w*\W+י\w*\W+מ\w*
Result: 2 verses
Zech 4:13  וַיֹּ֤אמֶר אֵלַי֙ לֵאמֹ֔ר הֲל֥וֹא יָדַ֖עְתָּ מָה־אֵ֑לֶּה וָאֹמַ֖ר לֹ֥א אֲדֹנִֽי׃
Lam 2:13  מָֽה־אֲעִידֵ֞ךְ מָ֣ה אֲדַמֶּה־לָּ֗ךְ הַבַּת֙ יְר֣וּשָׁלִַ֔ם מָ֤ה אַשְׁוֶה־לָּךְ֙ וַאֲנַֽחֲמֵ֔ךְ בְּתוּלַ֖ת בַּת־צִיּ֑וֹן כִּֽי־גָד֥וֹל כַּיָּ֛ם שִׁבְרֵ֖ךְ מִ֥י יִרְפָּא־לָֽךְ׃ ס

I hope that some of you will find this useful.
Its free and open source.  Download it from GitHub.
 
http://darinfranklin...xForAccordance/
  • Ken Han, Michael Miles, Abram K-J and 3 others like this

#2 Ken Simpson

Ken Simpson

    Mithril

  • Accordance
  • 2,486 posts
  • Gender:Male
  • Location:Sydney, Australia
  • Interests:My grandsons Micah and Nate!
    Astronomy
    Archaeology
    Physics
    Hebrew and Greek
    Papyrology
    Orthopædic Surgery
  • Accordance Version:12.x
  • Platforms:Mac OS X, Windows, iOS

Posted 11 December 2014 - 01:15 AM

Hi Darin, really like this.

 

Just a q’n. When I do the palindrome search, I get thousands of hits, not just 102. I can’t see that my setup is any different. Thoughts?


Regards
Ken
Lead Australian Accordance Demonstrator
Administrator, Accordance Exchange
Assistant Minister, Summer Hill Church

#3 Joe Weaks

Joe Weaks

    Platinum

  • Active Members
  • PipPipPipPipPip
  • 1,345 posts
  • Gender:Male
  • Location:Odessa, TX
  • Interests:I like things that are Orange, and possibly Blue.
  • Accordance Version:11.x

Posted 11 December 2014 - 01:25 AM

What a fun project. I look forward to checking it out, including several implementation questions I think of.
Thanks for sharing.
Joe Weaks
The Macintosh Biblioblog

Sometimes I'm so helpful even I can't stand it.

#4 דָנִיאֶל

דָנִיאֶל

    Ruby

  • Super Member
  • PipPipPipPipPipPipPip
  • 5,673 posts
  • Gender:Male
  • Accordance Version:12.x
  • Platforms:Mac OS X, Windows, Android

Posted 11 December 2014 - 01:45 AM

On more than one occasion I have wanted to be able to do this. Nice one.

I'll have to look back over the cases I had.

 

Thx

D


Sola lingua bona est lingua mortua
ἡ μόνη ἀγαθὴ γλῶσσα γλῶσσα νεκρὰ ἐστιν
lišanu ēdēnitu damqitu lišanu mītu

"Du stammst vom Herrn Adam und der Herrin Eva ab", sagte Aslan. "Und das ist zugleich Ehre genug, um das Häupt des ärmsten Bettlers zu erheben, und genug, um die Schultern des größten Kaisers auf Erden zu beugen. Sei zufrieden." Aslan, Die Chroniken von Narnia, Prinz Kaspian von Narnia. CS Lewis. Übersetzt von Wolfgang Holbein und Christian Rendel.

Accordance Syntax Search For Wallace's Greek Grammar Beyond the Basics : https://github.com/4...WallaceInSyntax

 

Accordance Crib Sheets: http://47rooks.com/l...ch-crib-sheets/

 

 

Accordance Configurations :

Mac : 2009 27" iMac
12GB RAM

Windows : MSI GE72 7RE Apache Pro laptop
Intel Core Duo Intel i7 Kabylake

Android : Samsung Note III 5.0, Samsung Tab S3 7.0 and Lenovo TAB4 8" 7.1


#5 Ken Simpson

Ken Simpson

    Mithril

  • Accordance
  • 2,486 posts
  • Gender:Male
  • Location:Sydney, Australia
  • Interests:My grandsons Micah and Nate!
    Astronomy
    Archaeology
    Physics
    Hebrew and Greek
    Papyrology
    Orthopædic Surgery
  • Accordance Version:12.x
  • Platforms:Mac OS X, Windows, iOS

Posted 11 December 2014 - 01:53 AM

Of course, no 1 can already be done with "*ημι"

 

But the regex really opens up some quirky and interesting possibilities.


Regards
Ken
Lead Australian Accordance Demonstrator
Administrator, Accordance Exchange
Assistant Minister, Summer Hill Church

#6 Anthony Sepulveda

Anthony Sepulveda

    Platinum

  • Active Members
  • PipPipPipPipPip
  • 848 posts
  • Gender:Male
  • Accordance Version:12.x
  • Platforms:Windows, iOS

Posted 11 December 2014 - 03:33 AM

It'd be great to see this implemented in Windows as well. Would anyone know how to get chunks of unicode text by script from Accordance for Windows?


  • Gordon and Fabian like this

Running Acc 13.0.0 on:      Running Acc 3.0.4 (Build 3.0.3.11461) on:

Windows 10 Home 64-bit      iOS 12.4.3 on iPad Mini 3

Ver. 1903 (18362.449)       iOS 13.2 on iPhone SE

HP Pavilion g6-2306el


#7 Ken Simpson

Ken Simpson

    Mithril

  • Accordance
  • 2,486 posts
  • Gender:Male
  • Location:Sydney, Australia
  • Interests:My grandsons Micah and Nate!
    Astronomy
    Archaeology
    Physics
    Hebrew and Greek
    Papyrology
    Orthopædic Surgery
  • Accordance Version:12.x
  • Platforms:Mac OS X, Windows, iOS

Posted 11 December 2014 - 03:59 AM

So, when I use the "\b3:16\b” and esvs it crashes every time.


Regards
Ken
Lead Australian Accordance Demonstrator
Administrator, Accordance Exchange
Assistant Minister, Summer Hill Church

#8 Rick Bennett

Rick Bennett

    Mithril

  • Accordance
  • 2,703 posts
  • Gender:Male
  • Location:Tampa Bay, FL
  • Interests: gadgets, coffee, running and cycling, Rays baseball
  • Accordance Version:12.x
  • Platforms:Mac OS X, Windows, iOS

Posted 11 December 2014 - 08:56 AM

This is pretty slick. Thanks for sharing. 


Rick Bennett
Director of Content Development

#9 Darin Franklin

Darin Franklin

    Bronze

  • Active Members
  • PipPip
  • 96 posts
  • Gender:Male
  • Accordance Version:12.x
  • Platforms:Mac OS X, Android

Posted 11 December 2014 - 11:44 AM

When I do the palindrome search, I get thousands of hits, not just 102. I can’t see that my setup is any different. Thoughts?

 

The palindrome search should show  "4358 hits | 3666 verses" on the left side, and "102 distinct hits" on the right. 



#10 Darin Franklin

Darin Franklin

    Bronze

  • Active Members
  • PipPip
  • 96 posts
  • Gender:Male
  • Accordance Version:12.x
  • Platforms:Mac OS X, Android

Posted 11 December 2014 - 11:50 AM

So, when I use the "\b3:16\b” and esvs it crashes every time.

 

Hmm...it works on my computer (Yosemite 10.10.1).  I know that it will crash Accordance with NRSVS when you do the range Gen-Rev, but ESVS is working fine.  I will debug this later. Thanks.



#11 Ken Simpson

Ken Simpson

    Mithril

  • Accordance
  • 2,486 posts
  • Gender:Male
  • Location:Sydney, Australia
  • Interests:My grandsons Micah and Nate!
    Astronomy
    Archaeology
    Physics
    Hebrew and Greek
    Papyrology
    Orthopædic Surgery
  • Accordance Version:12.x
  • Platforms:Mac OS X, Windows, iOS

Posted 11 December 2014 - 03:30 PM

 

The palindrome search should show  "4358 hits | 3666 verses" on the left side, and "102 distinct hits" on the right. 

 

This morning I get 3414 hits | 2947 verse with 89 distinct hits

 

Here is my setup

 

Attached File  Screen Shot 2014-12-12 at 07.29.18 .png   27.45KB   9 downloads Attached File  Screen Shot 2014-12-12 at 07.27.51 .png   208.46KB   7 downloads


Regards
Ken
Lead Australian Accordance Demonstrator
Administrator, Accordance Exchange
Assistant Minister, Summer Hill Church

#12 Joe Weaks

Joe Weaks

    Platinum

  • Active Members
  • PipPipPipPipPip
  • 1,345 posts
  • Gender:Male
  • Location:Odessa, TX
  • Interests:I like things that are Orange, and possibly Blue.
  • Accordance Version:11.x

Posted 11 December 2014 - 03:31 PM

 

This morning I get 3414 hits | 2947 verse with 89 distinct hits

 

Here is my setup

 

attachicon.gifScreen Shot 2014-12-12 at 07.29.18 .png attachicon.gifScreen Shot 2014-12-12 at 07.27.51 .png

 

The program factors in the time of day in producing the results.


  • Abram K-J likes this
Joe Weaks
The Macintosh Biblioblog

Sometimes I'm so helpful even I can't stand it.

#13 Darin Franklin

Darin Franklin

    Bronze

  • Active Members
  • PipPip
  • 96 posts
  • Gender:Male
  • Accordance Version:12.x
  • Platforms:Mac OS X, Android

Posted 11 December 2014 - 09:02 PM

 

This morning I get 3414 hits | 2947 verse with 89 distinct hits

 

Here is my setup

 

attachicon.gifScreen Shot 2014-12-12 at 07.29.18 .png attachicon.gifScreen Shot 2014-12-12 at 07.27.51 .png

 

 

You have a leading space in front of the first \b, so you miss the words at the beginning of a line or after a maqqef.



#14 Darin Franklin

Darin Franklin

    Bronze

  • Active Members
  • PipPip
  • 96 posts
  • Gender:Male
  • Accordance Version:12.x
  • Platforms:Mac OS X, Android

Posted 12 December 2014 - 12:14 AM

So, when I use the "\b3:16\b” and esvs it crashes every time.

 

Hi Ken. I fixed the problem.  The Accordance preferences for European verse notation and SBL standard abbreviations affect the verse reference format in the AppleScript output. I am using SBL, and I suspect that you are not.  I added support for all combinations.  You may download version 1.0.1 now.  Thanks.


  • EricC and Fabian like this

#15 Ken Simpson

Ken Simpson

    Mithril

  • Accordance
  • 2,486 posts
  • Gender:Male
  • Location:Sydney, Australia
  • Interests:My grandsons Micah and Nate!
    Astronomy
    Archaeology
    Physics
    Hebrew and Greek
    Papyrology
    Orthopædic Surgery
  • Accordance Version:12.x
  • Platforms:Mac OS X, Windows, iOS

Posted 12 December 2014 - 12:54 AM

Thanks Darin, for both explanations, though re the 2nd, I am not using European notation. SBL, always

 

Attached File  Screen Shot 2014-12-12 at 16.51.04 .png   180.46KB   0 downloads

 

However, you have fixed the crash! Thanks


Regards
Ken
Lead Australian Accordance Demonstrator
Administrator, Accordance Exchange
Assistant Minister, Summer Hill Church

#16 Ken Simpson

Ken Simpson

    Mithril

  • Accordance
  • 2,486 posts
  • Gender:Male
  • Location:Sydney, Australia
  • Interests:My grandsons Micah and Nate!
    Astronomy
    Archaeology
    Physics
    Hebrew and Greek
    Papyrology
    Orthopædic Surgery
  • Accordance Version:12.x
  • Platforms:Mac OS X, Windows, iOS

Posted 12 December 2014 - 12:56 AM

 

The program factors in the time of day in producing the results.

 

Joe! I never knew! That’s brilliant!


Regards
Ken
Lead Australian Accordance Demonstrator
Administrator, Accordance Exchange
Assistant Minister, Summer Hill Church

#17 Juan D. Pinto

Juan D. Pinto

    Member

  • Active Members
  • Pip
  • 31 posts
  • Gender:Male
  • Accordance Version:10.x
  • Platforms:Mac OS X, iOS

Posted 12 December 2014 - 02:16 AM

Darin this is so great! Thank you for the work you put into it and for making it free!



#18 Peter Brylov Christensen

Peter Brylov Christensen

    Gold

  • Active Members
  • PipPipPipPip
  • 370 posts
  • Gender:Male
  • Location:Denmark
  • Interests:Old Testament Exegesis, The Ancient Near East, the Hamito-Semitic languages, Ancient Greek, Mythology
  • Accordance Version:12.x
  • Platforms:Mac OS X

Posted 12 December 2014 - 06:36 AM

I'm very impressed with this app, Darin! Thank you for taking the time making this.

 

With kind regards

 

Peter Christensen

 

Oh, and for those who want to try out the app, but don't know how to work with regular expressions, the article on Wikipedia explains it nicely:

http://en.wikipedia....ular_expression


Edited by Pchris, 12 December 2014 - 06:49 AM.

  • Fabian likes this
Accordance Version: 11.0.8
Hardware: MacBook Pro 2.6 GHz Intel Core i7 (medio 2012)
Operating System: OSX 10.9.5 Mavericks.

#19 Anon

Anon

    Platinum

  • Validating
  • PipPipPipPipPip
  • 658 posts
  • Gender:Not Telling
  • Accordance Version:10.x
  • Platforms:None

Posted 14 January 2015 - 10:39 AM

Would the kind folks at Accordance please sherlock this, and do the honors of making this a feature of Accordance itself? I've been longing for advanced search features in the notes (as well as texts). Excellent idea, and nicely done.


Edited by James Tucker, 14 January 2015 - 10:40 AM.

  • Timothy Jenney, Darin Franklin, דָנִיאֶל and 4 others like this

#20 Peter Brylov Christensen

Peter Brylov Christensen

    Gold

  • Active Members
  • PipPipPipPip
  • 370 posts
  • Gender:Male
  • Location:Denmark
  • Interests:Old Testament Exegesis, The Ancient Near East, the Hamito-Semitic languages, Ancient Greek, Mythology
  • Accordance Version:12.x
  • Platforms:Mac OS X

Posted 15 January 2015 - 11:38 AM

Would the kind folks at Accordance please sherlock this, and do the honors of making this a feature of Accordance itself? I've been longing for advanced search features in the notes (as well as texts). Excellent idea, and nicely done.

 

 

+1

 

This would be a really great feature.


Accordance Version: 11.0.8
Hardware: MacBook Pro 2.6 GHz Intel Core i7 (medio 2012)
Operating System: OSX 10.9.5 Mavericks.





Also tagged with one or more of these keywords: regex

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users