In [2]:
import pandas as pd
GenesisDF = pd.read_excel("GenesisDF.xlsx")
from spacy.en import English
nlp = English()

In [3]:
del GenesisDF['link']
del GenesisDF['Unnamed: 0']

In [4]:
GenesisDF['NamedEntiryRecognition']=GenesisDF['passageText'].apply(lambda x: nlp(x).ents)

In [5]:
GenesisDF.head()


Out[5]:
passage passageText NamedEntiryRecognition
0 Genesis1:1 b'In the beginning God created the heaven and ... ()
1 Genesis1:2 b'And the earth was without form, and void; an... ()
2 Genesis1:3 b'And God said, Let there be light: and there ... ()
3 Genesis1:4 b'And God saw the light, that it was good: and... ()
4 Genesis1:5 b'And God called the light Day, and the darkne... ((Night), (first ))

In [6]:
def getNounChunks(x):
    chunksList = []
    for chunk in nlp(x).noun_chunks:
        chunksList.append(chunk)
    return chunksList

In [7]:
GenesisDF['NounChunks'] = GenesisDF['passageText'].apply(lambda x: getNounChunks(x))

In [8]:
GenesisDF.head(10)


Out[8]:
passage passageText NamedEntiryRecognition NounChunks
0 Genesis1:1 b'In the beginning God created the heaven and ... () [(God ), (the , heaven ), (the , earth)]
1 Genesis1:2 b'And the earth was without form, and void; an... () [(the , earth ), (form), (darkness ), (the , f...
2 Genesis1:3 b'And God said, Let there be light: and there ... () [(b'And ), (God ), (light), (light)]
3 Genesis1:4 b'And God saw the light, that it was good: and... () [(God ), (the , light), (it ), (God ), (the , ...
4 Genesis1:5 b'And God called the light Day, and the darkne... ((Night), (first )) [(God ), (the , light , Day), (he ), (the , ev...
5 Genesis1:6 b'And God said, Let there be a firmament in th... () [(b'And ), (God ), (a , firmament ), (the , mi...
6 Genesis1:7 b'And God made the firmament, and divided the ... () [(God ), (the , firmament), (the , waters ), (...
7 Genesis1:8 b'And God called the firmament Heaven. And the... ((second ),) [(God ), (the , firmament ), (the , evening ),...
8 Genesis1:9 b'And God said, Let the waters under the heave... ((one ),) [(b'And ), (God ), (the , waters ), (the , hea...
9 Genesis1:10 b'And God called the dry land Earth; and the g... ((Earth),) [(b'And ), (God ), (the , dry , land ), (the ,...

In [9]:
def getNSubj(x):
    NSubjList = []
    doc = nlp(x)
    for token in doc:
        if token.dep_ == 'nsubj':
            NSubjList.append(token)
    return NSubjList

In [10]:
GenesisDF['NSubjs'] = GenesisDF['passageText'].apply(lambda x: getNSubj(x))

In [11]:
GenesisDF.head(10)


Out[11]:
passage passageText NamedEntiryRecognition NounChunks NSubjs
0 Genesis1:1 b'In the beginning God created the heaven and ... () [(God ), (the , heaven ), (the , earth)] [God ]
1 Genesis1:2 b'And the earth was without form, and void; an... () [(the , earth ), (form), (darkness ), (the , f... [earth , darkness , Spirit ]
2 Genesis1:3 b'And God said, Let there be light: and there ... () [(b'And ), (God ), (light), (light)] [God ]
3 Genesis1:4 b'And God saw the light, that it was good: and... () [(God ), (the , light), (it ), (God ), (the , ... [b'And , God , it , God ]
4 Genesis1:5 b'And God called the light Day, and the darkne... ((Night), (first )) [(God ), (the , light , Day), (he ), (the , ev... [God , he , evening ]
5 Genesis1:6 b'And God said, Let there be a firmament in th... () [(b'And ), (God ), (a , firmament ), (the , mi... [God , it ]
6 Genesis1:7 b'And God made the firmament, and divided the ... () [(God ), (the , firmament), (the , waters ), (... [b'And , God , which , which , it ]
7 Genesis1:8 b'And God called the firmament Heaven. And the... ((second ),) [(God ), (the , firmament ), (the , evening ),... [God , evening ]
8 Genesis1:9 b'And God said, Let the waters under the heave... ((one ),) [(b'And ), (God ), (the , waters ), (the , hea... [God , land , it ]
9 Genesis1:10 b'And God called the dry land Earth; and the g... ((Earth),) [(b'And ), (God ), (the , dry , land ), (the ,... [b'And , God , he , God , it ]

In [15]:
GenesisDF.to_csv("Visualize_Genesis.csv")

In [ ]: