def handle(self, *args, **options): try: names = name.all_data() all_books = book.all_data() for book_name in constants.BOOKS: book_chapters = all_books[book_name] for chapter in range(1,len(book_chapters)): for (verse, text) in enumerate(book_chapters[chapter]): found_names = set() for word in text.split(): sanitized = word.strip('.,;:-') if sanitized in names and sanitized not in found_names: found_names.add(sanitized) print('|'.join([str(hash((book_name, chapter, verse))),book_name,str(chapter),str(verse),sanitized])) except Exception as e: traceback.print_exc(file=self.stdout)
def handle(self, *args, **options): names_by_verse_key = dict() excludes= ['So', 'On', 'No'] try: names = {name.lower(): meaning for (name, meaning) in name.all_data().items()} books = book.all_data() collapsed = self.collapse_verses(books) for verse_key, text in collapsed: for word in text.split(): sanitized_word = word.strip('.,;:" ') if sanitized_word in excludes: continue if sanitized_word.lower() in names: self.map_name(names_by_verse_key, verse_key, sanitized_word) except: traceback.print_exc()