Exemplo n.º 1
0
def extract_elements_from_document(doc: Doc):
    participants = []
    svos = []
    for sentence in doc.sents:
        # print(sentence)
        # utils.to_nltk_tree(sentence.root).pretty_print()
        out_participants, out_svos = extract.extract_process_elements(sentence)
        participants += out_participants
        svos += out_svos

    return participants, svos
Exemplo n.º 2
0
    def test_example_phrase_six(self):
        filepath = "../examples/example_phrase_six"
        nlp = spacy.load("en")

        text = open(filepath).read().replace("\n", " ")
        doc = nlp(text)

        svos = []
        for sentence in doc.sents:
            utils.to_nltk_tree(sentence.root).pretty_print()
            participants, svos = extract.extract_process_elements(sentence)
            for svo in svos:
                print(utils.svo_full_name(svo))
        self.assertEqual(len(svos), 1, "SVO list length is incorrect")
Exemplo n.º 3
0
    def test_example_phrase_five(self):
        filepath = "../examples/example_phrase_five"
        nlp = spacy.load("en")

        text = open(filepath).read().replace("\n", " ")
        doc = nlp(text)

        participants = []
        for sentence in doc.sents:
            [
                utils.to_nltk_tree(sent.root).pretty_print()
                for sent in doc.sents
            ]
            participants, svos = extract.extract_process_elements(sentence)
            for participant in participants:
                print(utils.participant_full_name(participant))
        self.assertEqual(len(participants), 1,
                         "Participants list length is incorrect")