Beispiel #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))
Beispiel #2
0
    def test_create_populated_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')

        self.assertEqual(0, context.phrases[0].beginIndex)
        self.assertEqual(14, context.phrases[0].endIndex)
        self.assertEqual("Diego Maradona", context.phrases[0].mention)
        self.assertEqual(0.9869992701528016, context.phrases[0].score)
        self.assertTrue(
            turtle_equal(context.turtle, self.example_ContextHashBasedString))
Beispiel #3
0
    def test_add_phrase(self):
        c = NIFContext(
            uri=
            'http://www.cse.iitb.ac.in/~soumen/doc/CSAW/doc/yn_08Oct08_file_0',
            mention=self.example_text)

        b = c.add_phrase(91, 102)
        self.assertEqual(91, b.beginIndex)
        self.assertEqual(102, b.endIndex)
        self.assertEqual("Afghanistan", b.mention)
        self.assertEqual(
            "http://www.cse.iitb.ac.in/~soumen/doc/CSAW/doc/yn_08Oct08_file_0",
            b.context)