Abnum is an alphabetic numerals python package/library including various letter value substituting systems from ancient times to modern artificial ones.
Currently supported scripts are: greek (ancient), hebrew and english. Planned is a support for arabic, coptic, sanskrit and ethiopian scripts. Some of the systems have been referred with certain name and methodology in the past, these include:
But since not all languages have specific name for this literary device and because of purely recreational purposes I decided to put all systems under same generic library.
Many languages have acrophonic (not alphabetic) numerals also. Most well known perhaps are roman numbers: I, V, X, L, C, D, M. Greeks had Attic (also called Herodianic) numerals, but any of these should not be confuced with alphabetic numerals implemented on Abnum library.
Import Abnum class and scripts from the abnum package:
In [1]:
from abnum import Abnum, greek, hebrew, english
Initialize abnum object which holds all main functionality for alphabet numeral value calculation:
In [2]:
g = Abnum(greek)
phrase = 'ο Λογος'
print phrase, (g.convert(phrase), g.value(phrase))
Thus we can see that ο Λογος (the Word, philosophical/theological concept) is transliterated to 'o Logos' and its alphabetic numeral value (or isopsephic value in this case of greek example) is 443.
Abnum uses romanize transliteration module for converting a script to roman letters. But is also works other way around. You can get a greek script presentation of the word as well:
In [3]:
print g.convert('o Logos')
Some of the scripts have capital letters and some doesn't. This is affected on the functioning in a way that for example in greek and english small and capital letters have same value and their form is reserved on conversion.
In [4]:
print g.convert('GAIOS IOYLIOS KAISAR'), ',', \
g.convert('GAIOS IOYLIOS KAISAR'.title())
But scripts like hebrew doesn't have separate small or capital letters. Transliteration module in this case have special meaning on capital letters and their numerical value is not same with small letters. Capital "M" has a value 600 and small "m" 40 in hebrew gematria. Big letter are used as final letters as described by ancient "Mispar gadol" method of gematria. See the difference of spelling and value for the Hebrew word God:
In [5]:
h = Abnum(hebrew)
print h.value('alhiM'), h.convert('alhiM')
print h.value('alhim'), h.convert('alhim')
Value conversion is made by default mapping, but in some cases (either because of using different letter value mapping from the various traditions or artificial one for tests) you may want to provide your own mapping. Take for example default english data mapping provided (Marty Leeds) which is:
In [6]:
e1 = Abnum(english)
print e1.data
But in english script, there are several different mappings, which you could use instead. So let's see one example:
In [7]:
word = "the key"
print "Using a default english mapping and getting a value for the word: '%s' = %s" % (word, e1.value(word))
# defining custom mapping, simple english gematria
mapping = ([1, 'a'], [2, 'b'], [3, 'c'], [4, 'd'], [5, 'e'], [6, 'f'], [7, 'g'], [8, 'h'], [9, 'i'],
[10, 'j'], [11, 'k'], [12, 'l'], [13, 'm'], [14, 'n'], [15, 'o'], [16, 'p'], [17, 'q'], [18, 'r'],
[19, 's'], [20, 't'], [21, 'u'], [22, 'v'], [23, 'w'], [24, 'x'], [25, 'y'], [26, 'z'])
e2 = Abnum(english, mapping) # must exclude all other letters to prevent exception...
print "Using a custom english mapping and getting a value for the word: '%s' = %s" % (word, e2.value(word))
Other useful feature from romanize module is implemented by preprocess functionality, when special accent letters are converted to corresponding normal letters. This is because in alphabetic numerals conversion accents don't carry any special meaning. You can use prerocessing via second parameter in convert method.
In [8]:
print g.convert('ἀδελφέ, βοήθει', True)
Now phrase is ready for value calculation. Note that use can use transliteration version of the string for calculation as well.
In [9]:
print g.value(g.convert('ἀδελφέ, βοήθει', True)), '=', g.value('adelfe boêhei')
Two other methods for analyzing value of the phrases are: char_table and char_table_data. See examples below:
In [10]:
g.char_table('ο Λογος')
Out[10]:
In [11]:
a, b, c = g.char_table_data('ο Λογος')
In [12]:
a
Out[12]:
In [13]:
b
Out[13]:
In [14]:
c
Out[14]:
And last but not the least Abnum package supports finding number patterns from phrases with find -method. This is useful for examining possible word and phrase patterns on bigger text corpuses. And this is actually the reason why library was made in first hand. As a real historical example I will use a poem created by first and second century isopsephist, probably the father of Claudius Galen, architect Niko, who was said to have mastered this art to its extremes.
"Helios, you allow the light to assume its spiral shape with your
swith horses, thus you have sent every day your rays to men having
completed everything, since you established the route of Sun and
(then) the never ending Earth, the outpuring Water, Air and Fire,
everything proceeds ordinally."
Let's Abnum library calculate the value of the each line (in greek) and then find number patterns that were in the mind of original authors. Original artifact available in the Museum of Pergamum has second part of the poem broken, but first part is fully reconstructed here:
In [15]:
ss = ["ΑΙΛΙΟΥ ΝΕΙΚΩΝΟΣ ・ ẠΨΚϚ ・ ΑΡΧΙΤΕΚΤΟΝΟΣ",
"ΗΛΙΕ ΘΟΑΙΣ ΙΠΠΟΙΣΙΝ ΕΙΛΙΣΣΩΝ ΦΛΟΓΑ",
"ΩΣ ΠΑΝΤΕΛΗ ΘΝΗΤΟΙΣΙ ΤΗ ΤΟΤΕ Γ ΗΜΕΡΑ",
"ΑΚΤΕΙΝΑΣ ΕΦΗΚΑΣ ΘΕΜΕΝΟΣ ΗΛΙΟΥ ΔΡΟΜΟΥΣ",
"ΚΑΙ ΤΗΝ ΑΠΕΙΡΟΝ ΓΑΙΑΝ ΗΔΕ ΥΓΡΟΥ ΧΥΣΕΙΣ",
"ΑΕΡΑ ΤΕ ΚΑΙ ΠΥΡ ΕΝ ΤΑΞΕΙ ΦΟΡΟΥΜΕΝΑ",
"ṂĖ"]
for s in ss:
print g.value(g.preprocess(s)), s
s = g.preprocess(' '.join(ss))
print "Total value: %s" % g.value(s)
v1 = 1726
v2 = 15000
print ""
print "Find phrases with a value %s and %s:" % (v1, v2)
print ""
for x in g.find(s, v1, True):
print v1, x
print ""
for x in g.find(s, v2, True):
print v2, x
In [16]:
#g.char_table(s.decode('utf8').lower().encode('utf8'))
g.char_table(s)
Out[16]:
In [17]:
a, b, c = g.char_table_data(s)
b
Out[17]:
In [18]:
from IPython.core.display import HTML
with open('abnum.css') as f:
css = f.read()
HTML('<style>%s</style>' % css)
Out[18]:
Copyright (c) 2015 Marko Manninen