Blog RSS Feed

New Tool: Bible Word Locator

Try it out.

Screenshots

See ‘said.’
All the occurrences of the word said in the Bible. Note the narrative bands in Genesis, the Old Testament history books, and the gospels.

See ‘father’ and ‘son.’
Occurrences of the words father and son. Clusters in Chronicles and a couple of places in the New Testament show where to find the genealogies.

See ‘Moses,’ ‘David,’ and ‘Jesus.’
Occurrences of the words Moses, David, and Jesus. It’s easy to tell where the main stories about each person are.

Background

Part of the Similar Diversity work includes a visualization of the word you in various holy books. This visualization provided me the impetus to produce something more interactive for the Bible.

How It Works

First, I counted the number of words in the ESV Bible (767,847, including headings but excluding footnotes, if you’re interested).

Next I assigned each word in the Bible a unique, incremented number. Then it was just a matter of going through the positions and grouping them by word. The result is a database table with two columns: word (varchar(18)) and positions (mediumtext). The positions column consists of a space-separated string of numbers.

When you enter a search query, the program finds the positions of words matching your query and then plots those positions on a chart. (The chart is 1/4 the size it would be if each word position got one pixel; it would have to be 1,083×709 pixels at a one-pixel-per-word ratio.)

The Code

The code is in PHP, using the GD library. I decided this project would be a good time to try out the SQLite database that comes with PHP instead of going with MySQL. I have no complaints, though Perl creates incompatible tables with current PHP versions (5.2.4) unless you use PDO in PHP to access the tables. It worked fine after a bit of Googling revealed the workaround.

Limitations

Since the chart is 1/4 full-size, each pixel represents four words, and each dot occupies nine pixels. Given the coarse resolution, it’s best to use the locator to identify trends and then switch to the Bible text for further analysis.

It doesn’t do exact matches, only beginning-of-word matches. Only want to search for Eve, omitting results for evening? You’re out of luck.

It would be interesting to be able to click a dot and see the context of each occurrence.

Introducing Labs

Launching this tool gives me an excuse to launch the new Labs section of this site, which houses small, one-off experiments like this one and the Chapter Browser.

7 Responses to “New Tool: Bible Word Locator”

  1. I can’t see past Hebrews on the Bible word locator. What do I need to do.

  2. openbible says:

    My guess is that it’s probably confusing that the last gray line says “Hebrews.” But everything below that line is Hebrews and after.

  3. Jonathan says:

    So, would it be a difficult extension to the SQL to allow two-word phrases? Ie, find all occurrences of “Spirit” and then search within that for where “Holy” is the previous or next word, for example? I can’t immediately think of the SQL that achieves that, though I’m sure it’s possible.

  4. tim bulkeley says:

    This is really interesting, I often use the Bibleworks stats tool to do something similar. It has the advantages that it is based on a complex search, and that you can “zoom” it to chapters in a book or books in the Bible…

    Interestingly family words seem to be high frequency in Chronicles not only because of the genealogies, but also from steady use in every chapter.

  5. openbible says:

    @Jonathan: The database schema I’m using makes it difficult but not impossible to handle phrase searches without loading lots into memory. I’ll see if I can come up with something. Thanks for the suggestion.

    @Tim: Interesting. I didn’t know BibleWorks did visual statistics. A quick search on their site only revealed one screenshot of the feature, and it’s from BibleWorks 5, so it may no longer accurately reflect the interface: http://www.bibleworks.com/reviews/reviews_thoennes.htm .

  6. tim bulkeley says:

    They’re not very visual, just tables and bar charts, but by giving the data chapter by chapter they do enable a more fine-grained complement to what your tool does. I find the chapter level data useful in spotting topics of chapter/sections of books. It still looks as uninteresting as version 5 – but then Bibleworks strength has never been its beauty! You choose the level chapter/book and the sort of statistic:
    verses with hit
    hits
    % vvs with hit / vvs in ch
    % hits/ hits in version
    % vvs with hit / vvs in version
    % hits in ch / words in ch
    % hits in ch / words in version
    And similar list for book level.

  7. Tait says:

    I would love it if a feature was added where the dots become links to the verse they represent in the Bible. eg. Look up “light”, click the first dot, it takes you to Genesis 1:3. That would allow users to find the specific location of a Bible character or story with greater ease, making the program almost like a stripped-down, speedy concordance.

    I like the concept anyway!