def func(): b = Bible("ESV") pat = re.compile(r"\d+,?\d+") verse, bkname = b.get("Psalms", "1", "1") print verse print bkname nums = defaultdict(int) for k in b.books.keys(): for c in b.books[k].keys(): for v in b.books[k][c].keys(): versetext = b.books[k][c][v] groups = re.findall(pat, versetext) if len(groups) > 0: print groups, versetext for g in groups: nums[g[0]] += 1 print nums import matplotlib.pyplot as plt from numpy.random import normal gaussian_numbers = normal(size=10) print gaussian_numbers ln = nums.items() sln = sorted(ln) print sln sln = sln[1:] plt.bar(map(int, map(lambda p: p[0], sln)), map(lambda p: p[1], sln)) plt.title("Benford's Law in Bible Numbers") plt.xlabel("Initial Digit") plt.ylabel("Count") plt.show()
if s == "help": print("Usage:\n\t<book> <chap>:<verse\n\tchange - change Bible version\n\texit, q, quit - quit") continue # Having gone past all the options, we assume # that s is a book chapter:verse sp = s.split() if len(sp) == 1: print("Normally this would print the entire book, but not now!") #book = sp[0] #for b in blist: # print(b[book]) else: cv = sp[-1].split(":") c = cv[0] # chapter v = cv[1] # verse book = " ".join(sp[:-1]) print(book, c, v) for b in blist: val, book = b.get(book, c, v) if val is not None: print("{}: {}".format(b.version, val)) else: break
if s == "change": print("Changing...") blist = chooseversion() continue if s == "help": print( "Usage:\n\t<book> <chap>:<verse\n\tchange - change Bible version\n\texit, q, quit - quit" ) continue # Having gone past all the options, we assume # that s is a book chapter:verse sp = s.split() if len(sp) == 1: print("Normally this would print the entire book, but not now!") #book = sp[0] #for b in blist: # print(b[book]) else: cv = sp[-1].split(":") c = cv[0] # chapter v = cv[1] # verse book = " ".join(sp[:-1]) print(book, c, v) for b in blist: val, book = b.get(book, c, v) if val is not None: print("{}: {}".format(b.version, val)) else: break