Strong's definitions are retrieved and processed from morphgnt and openscriptures. Few items are corrected and then data is saved as a CSV file. CSV file is a handy format for Python Pandas data processing library. Pandas will be used as a base interface to the Strong's data.
You need to have a nt-strongs.csv file on your local machine in the same directory as strongs.py main script. If CSV file is not found, warning will be given. In this case you can still pass directory and file name as a csv argument when using load_dataframe function.
In [1]:
import strongs
# reload ensures, that the latest version of strongs module is loaded
# this is useful when developing module, but not necessary on production
#reload(strongs)
# load strongs dictionary from other location, if initial load fails
#strongs.load_dataframe(csv = "strongs/nt-strongs.csv");
You can get dictionary items by all five fields: lemma, word, transliteration, translation and isopsephy value. This is done by find function on strongs -module. Example given below retrieves Strong's greek definition G99 from dictionary:
In [2]:
lemma = "G99"
# first argument is search item. second is field name
result = strongs.find(lemma, 'lemma')
# print result using Pandas table output
result
Out[2]:
As you can see, result contains all items having a substring "G99". You can get more limited result by passing search query using python regular expression engine.
\$ at the end means searched string must end with given query. Because all lemmas starts with G in Greek Strong's definitions, we don't need to handle beginning part of the search string in this case. But you would do that kind of limit with expression: '^'+lemma+'\$'. Let's get dictionary item with exact lemma:
In [3]:
strongs.find(lemma+'$', 'lemma')
Out[3]:
Alternatively you can pass compiled regex object to get item(s) even more efficiently. This is useful especially, if you do a lot of search queries with regular expression style.
In [4]:
import re
regex = re.compile('^'+lemma+'$')
result = strongs.find(regex, 'lemma')
result
Out[4]:
Finally, retrieving certain field content is done either by joining array of result item(s), which works well now, because there is only one search result:
In [5]:
print lemma + ": " + ''.join(result.word)
or by retrieving row by index:
In [6]:
print lemma + ": " + result.translation[3072]
Words stored on the database are simplified greek letters without accents/diacritics. That's why you may need to pre process greek words before making a search by word. To remove unwanted characters and remove accents you can use preprocess_greek function, which is included from isopsephy module to the strongs module. Here we are using "unaccented" word on search:
In [7]:
strongs.find("ψυχρος", 'word')
Out[7]:
And same with pre processing:
In [8]:
word = strongs.preprocess_greek("ψυχρός")
strongs.find(word, 'word')
Out[8]:
In [9]:
strongs.find("flute", 'translation')
Out[9]:
Main reason for making Strong's dictionary to iPython Notebook application is the ongoing isopsephy research. You can read more of the project from GitHub Isopsephy Project repository.
Main idea of the isopsephy is that all 27 letters of Greek alphabet has a numeric value (1-9, 10-90, 100-900). So all words can be calculated to have a sum of the alphabet values. On next example we find out all word on Strong's dictionary having the numerical value of 1008:
In [10]:
strongs.find(321, 'isopsephy')
Out[10]:
Strongs module also provides search results in html format that can be used to interact with strongs database via html form. On next three steps we:
If you download notebook to your local machine or use wakari notebook provider, you can see form in action. Otherwise you will just see static html and example result.
In [11]:
from strongs import search_strongs_dictionary_html, print_search_form_html, print_search_form_js
print_search_form_html()
Out[11]:
In [12]:
print_search_form_js()
Out[12]:
There are a few other related notebooks to dive more deep to the subject of isopsephy:
Copyright (c) 2014 Marko Manninen
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.