Esempio n. 1
0
    def test_load_from_graph_ContextHashBasedString(self):
        context = NIFContext(
            uri=
            'http://freme-project.eu#hash_0_33_cf35b7e267d05b7ca8aba0651641050b_Diego%20Maradona%20is%20fr',
            mention="Diego Maradona is from Argentina.",
            is_hash_based_uri=True)
        context.add_phrase(
            uri=
            'http://freme-project.eu#hash_19_33_158118325b076b079d3969108872d855_Diego%20Maradona%20is%20fr',
            is_hash_based_uri=True,
            beginIndex=0,
            endIndex=14,
            score=0.9869992701528016,
            taClassRef=[
                'http://dbpedia.org/ontology/SportsManager',
                'http://dbpedia.org/ontology/Person',
                'http://nerd.eurecom.fr/ontology#Person'
            ],
            annotator='http://freme-project.eu/tools/freme-ner',
            taIdentRef='http://dbpedia.org/resource/Diego_Maradona',
            taMsClassRef='http://dbpedia.org/ontology/SoccerManager')
        g = Graph().parse(format='turtle',
                          data=self.example_ContextHashBasedString)
        uri = URIRef(
            'http://freme-project.eu#hash_0_33_cf35b7e267d05b7ca8aba0651641050b_Diego%20Maradona%20is%20fr'
        )
        parsed_context = NIFContext.load_from_graph(g, uri)

        self.assertTrue(turtle_equal(context.turtle, parsed_context.turtle))
Esempio n. 2
0
    def test_load_from_graph(self):
        g = Graph().parse(format='turtle', data=self.example_turtle)
        uri = URIRef(
            'http://www.cse.iitb.ac.in/~soumen/doc/CSAW/doc/yn_08Oct08_file_0/#offset_0_1411'
        )
        context = NIFContext.load_from_graph(g, uri)

        self.assertEqual(self.example_text, context.mention)
        self.assertEqual(0, context.beginIndex)
        self.assertEqual(len(self.example_text), context.endIndex)
Esempio n. 3
0
    def test_load_ContextHashBasedString(self):
        g = Graph().parse(format='turtle',
                          data=self.example_ContextHashBasedString)
        uri = URIRef(
            'http://freme-project.eu#hash_0_33_cf35b7e267d05b7ca8aba0651641050b_Diego%20Maradona%20is%20fr'
        )
        parsed_context = NIFContext.load_from_graph(g, uri)

        self.assertTrue(parsed_context.isContextHashBasedString)
        for phrase in parsed_context.phrases:
            self.assertTrue(phrase.isContextHashBasedString)
        self.assertTrue(
            turtle_equal(parsed_context.turtle,
                         self.example_ContextHashBasedString))