Created
August 30, 2019 17:18
-
-
Save tomasonjo/5855f43a805c536220e27f9ca2969807 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Analyze the first chapter | |
c = chapters[0] | |
# Get a list of persons | |
doc=nlp(c) | |
involved = list(set([ent.text for ent in doc.ents if ent.label_=='PERSON'])) | |
# replace names of involved in the text | |
# with an id and save the mapping | |
decode = dict() | |
for i,x in enumerate(involved): | |
# Get mapping | |
decode['$${}$$'.format(i)] = x | |
# Preprocess text | |
c = c.replace(x,' $${}$$ '.format(i)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment