Exemple #1
0
from structure import Context, Novel

ENTITIES_FILENAME = 'entities.json'


def process(novel):
    edb = EntityDatabase()
    edb.load(ENTITIES_FILENAME)

    context = Context()

    def process_chapter_done(chapter):
        context.process_chapter_done(chapter)

    def process_sentence(sentence):
        context.process_sentence(sentence, edb)

    novel.for_each(chapter_done=process_chapter_done, sentence=process_sentence)


if __name__ == '__main__':
    parser = argparse.ArgumentParser(
        description='List all potential entities, namely proper nouns.')
    parser.add_argument('input', type=str, help='input tagged novel file')
    args = parser.parse_args()

    novel = Novel(args.input)
    print("novel loaded...")
    process(novel)
    novel.save(args.input + '.entities')
Exemple #2
0
"""
import argparse

from entities import EntityDatabase
from structure import Novel

ENTITIES_FILENAME = 'entities.json'


def process(novel):
    edb = EntityDatabase()
    edb.load(ENTITIES_FILENAME)

    def process_chapter_done(chapter):
        chapter.identify_speakers(edb)

    novel.for_each(chapter_done=process_chapter_done)


if __name__ == '__main__':
    parser = argparse.ArgumentParser(
        description='List all potential entities, namely proper nouns.')
    parser.add_argument('input', type=str, help='input tagged novel file')
    args = parser.parse_args()

    novel = Novel(args.input)
    print("novel loaded...")
    process(novel)
    novel.save(args.input + '.normalized')