<jupyter_start><jupyter_text>Strong's Bible DictionaryPython 3 tools for Strong's Bible Dictionary. Data contains both Greek and Hebrew lemmas. Greek starting with *G* and Hebrew with *H*.Strong's definitions are retrieved and processed from [morphgnt](https://github.com/morphgnt/strongs-dictionary-xml) and [openscriptures](https://github.com/openscriptures/strongs/tree/master/). Few items are corrected and then data is saved as a CSV file. CSV file is a handy format for Python [Pandas](http://pandas.pydata.org/) data processing library. Pandas will be used as a base interface to retrieve the Strong's data.You need to have a [strongs.csv](https://raw.githubusercontent.com/markomanninen/strongs/master/strongs3/data_processed/strongs.csv) file on your local machine in the same directory with the main script.<jupyter_code>import strongs3 as strongs<jupyter_output>Retrieving Strong's data from local csv copy (/Users/marko/Documents/notebooks2/strongs3/data_processed/strongs.csv) ...<jupyter_text>Find item by lemma 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:<jupyter_code>lemma = "G99"
# first argument is search item. second is field name
result = strongs.find(lemma, 'lemma')
# print result using Pandas table output
result<jupyter_output><empty_output><jupyter_text>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](https://docs.python.org/2/library/re.html) 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:<jupyter_code>strongs.find(lemma+'$', 'lemma')<jupyter_output><empty_output><jupyter_text>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.<jupyter_code>import re
regex = re.compile('^'+lemma+'$')
result = strongs.find(regex, 'lemma')
result<jupyter_output><empty_output><jupyter_text>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:<jupyter_code>print (lemma + ": " + ''.join(result.word))<jupyter_output>G99: Αδριας<jupyter_text>or by retrieving row by index:<jupyter_code>print (lemma + ": " + result.strongs_def[1575])<jupyter_output>G99:  the Adriatic sea (including the Ionian)<jupyter_text>Search queries with other fields  Word Words stored on the database are simplified greek and hebrew letters without accents/diacritics/masoreths. That's why you may need to preprocess greek words before making a search by a word. To remove unwanted characters and remove accents you can use preprocess method, which is provided by [abnum3](https://github.com/markomanninen/abnum3) module on the strongs library.Here we are first using "unaccented" word on search:<jupyter_code>strongs.find("ψυχρος", 'word')<jupyter_output><empty_output><jupyter_text>And same with preprocessing:<jupyter_code>from strongs3.main import Abnum, greek, hebrew
grc = Abnum(greek)
word = grc.preprocess("ψυχρός")
strongs.find(word, 'word')<jupyter_output><empty_output><jupyter_text>TranslationUse *kjv_def* or *strongs_def* fields to search from translation of the dictionary words:<jupyter_code>strongs.find("flute", 'strongs_def')<jupyter_output><empty_output><jupyter_text>Note that result contains both Hebrew and Greek data. Result can be further filtered by using greek and hebrew hooks before find function:<jupyter_code>strongs.greek.find("flute", 'strongs_def')
strongs.hebrew.find("flute", 'strongs_def')<jupyter_output><empty_output><jupyter_text>Abnum My main reason for making Strong's dictionary to Jupyter Notebook application is the ongoing isopsephy/gematria research I've been doing since 2013. You can read more about the project from repositories:[GitHub Abnum 3 Project](https://github.com/markomanninen/abnum3) for Python 3[GitHub Isopsephy Project](https://github.com/markomanninen/isopsephy) for Python 2Main idea of the isopsephy is that all 27 letters of Greek alphabet has a numeric value (1-9: 1-9, 10-18: 10-90, 19:27: 100-900). So all words can be calculated to have a sum of the alphabet values. On the next example we find out all words on Strong's dictionary having the numerical value of 321:<jupyter_code>strongs.greek.find(321, 'abnum')<jupyter_output><empty_output><jupyter_text>MappingIn some cased we may want to use different alpha-numeric value mapping. This can be done with providing mapping information on the dictionary load function. Say that we want to use Ktav Ivri substitutions instead of default one:<jupyter_code># http://www.jewfaq.org/alephbet.htm
# http://www.agapebiblestudy.com/charts/letter_number_equivalent.htm
# https://www.academia.edu/s/22fded7fa9
KtavIvri_Mapping = (
    [1, 'alef'], [2, 'beth'], [3, 'gimel'], 
    [3, 'shin'], [4, 'daleth'], [4, 'tau'],
    [5, 'he'], [6, 'vau'], [7, 'zayin'], 
    [8, 'heth'], [9, 'teth'], [10, 'yod'], 
    [20, 'kaph'], [30, 'lamed'], [40, 'mem'], 
    [50, 'nun'], [60, 'samekh'], [70, 'ayin'], 
    [80, 'pe'], [90, 'tsade'], [100, 'qoph'], 
    [200, 'resh'], [20, 'final_kaph'], [40, 'final_mem'], 
    [50, 'final_nun'], [80, 'final_pe'], [90, 'final_tsade']
)<jupyter_output><empty_output><jupyter_text>Normally result will give abnum value: **821** for the lemma: **H115**<jupyter_code>strongs.find(r'^H115$', 'lemma')<jupyter_output><empty_output><jupyter_text>But loading dictionary with different mapping the abnum value for the lemma will give: **261**<jupyter_code>strongs.load_dictionary(mappings={'hebrew': KtavIvri_Mapping})
strongs.find(r'^H115$', 'lemma')<jupyter_output>Retrieving Strong's data from local csv copy (/Users/marko/Documents/notebooks2/strongs3/data_processed/strongs.csv) ...<jupyter_text>Statistics<jupyter_code>from strongs3.main import Abnum, greek, hebrew

grc = Abnum(greek)
heb = Abnum(hebrew, KtavIvri_Mapping)

g = strongs.greek.find()
h = strongs.hebrew.find()
g.describe()
h.describe()
grc_text = ''.join(g.word).lower().replace(" ", "")
grc_alphabet = set(grc_text)
heb_text = ''.join(h.word).lower().replace(" ", "")
heb_alphabet = set(heb_text)
stats = {'heb': {}, 'grc': {}}

print ("Length of the greek text: %s" % len(grc_text))
print ()
for item in sorted(zip(grc_alphabet, map(grc.value, grc_alphabet)), key=lambda tup: tup[1]):
    oc = grc_text.count(item[0])
    print ("Letter: %s Isopsephy: %s Occurences: %s (%.2f%%)" % (item[0], item[1], oc, 100*oc/len(grc_text)))
    stats['grc'][item[0]] = 100*oc/len(grc_text)
print ()
print ("Length of the hebrew text: %s" % len(heb_text))
print ()
for item in sorted(zip(heb_alphabet, map(heb.value, heb_alphabet)), key=lambda tup: tup[1]):
    oc = heb_text.count(item[0])
    print ("Letter: %s Isopsephy: %s Occurences: %s (%.2f%%)" % (item[0], item[1], oc, 100*oc/len(heb_text)))
    stats['heb'][item[0]] = 100*oc/len(grc_text)
%matplotlib inline

import matplotlib
matplotlib.rc('font', family='Arial')
plt = matplotlib.pyplot

def plot(D):
    r = range(len(D))
    plt.figure(figsize=(20,10))
    plt.tick_params(axis='both', which='major', labelsize=16)
    plt.bar(r, D.values(), align='center')
    plt.xticks(r, list(D.keys()))
    plt.show()

plot(stats['grc'])
plot(stats['heb'])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1308338720103426, 'fraction_numerical': 0.020426632191338074, 'mean_word_length': 5.931899641577061, 'pattern_counts': {'":': 2, '<': 57, '<?xml version=': 0, '>': 57, 'https://': 8, 'lorem ipsum': 0, 'www.': 3, 'xml': 1}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '15', 'dir': 'jupyter-structured-clean-dedup', 'id': '591469', 'license': 'MIT', 'n_tokens_mistral': 2757, 'n_tokens_neox': 2582, 'n_words': 778, 'path': "Strong's Bible Dictionary.ipynb", 'repo_name': 'markomanninen/strongs3', 'size': '7735'}