Example #1
0
    def testGraphFindLabelSpecifyAllowedLabelPredicates(self):
        g = Graph()
        g.addTriple('u:ri', curieToUri('rdfs:label'), Literal('rdfsLabel'))
        self.assertEquals(None, g.findLabel(uri='u:ri', labelPredicates=[]))
        self.assertEquals(Literal('rdfsLabel'), g.findLabel(uri='u:ri', labelPredicates=[curieToUri('rdfs:label')]))

        g.addTriple('u:ri2', curieToUri('skos:altLabel'), Literal('altLabel'))
        self.assertEquals(None, g.findLabel(uri='u:ri2', labelPredicates=[curieToUri('rdfs:label')]))
        self.assertEquals(Literal('altLabel'), g.findLabel(uri='u:ri2', labelPredicates=[curieToUri('rdfs:label'), curieToUri('skos:altLabel')]))
Example #2
0
    def testGraphFindLabel(self):
        g = Graph()
        g.addTriple('u:ri', curieToUri('rdfs:label'), Literal('rdfsLabel'))
        self.assertEquals(Literal('rdfsLabel'), g.findLabel(uri='u:ri'))

        g.addTriple('u:ri', curieToUri('rdfs:label'), Literal('rdfsLabelEN', lang='en'))
        self.assertEquals(Literal('rdfsLabelEN', lang='en'), g.findLabel(uri='u:ri'))

        g.addTriple('u:ri', curieToUri('skos:prefLabel'), Literal('skosPrefLabel'))
        self.assertEquals(Literal('rdfsLabelEN', lang='en'), g.findLabel(uri='u:ri'))

        g.addTriple('u:ri', curieToUri('skos:prefLabel'), Literal('skosPrefLabelNL', lang='nl'))
        self.assertEquals(Literal('skosPrefLabelNL', lang='nl'), g.findLabel(uri='u:ri'))

        g.addTriple('u:ri', curieToUri('rdfs:label'), Literal('rdfsLabelNL', lang='nl'))
        self.assertEquals(Literal('rdfsLabelNL', lang='nl'), g.findLabel(uri='u:ri'))

        g.addTriple('u:ri', curieToUri('foaf:name'), Literal('foafNameNL', lang='nl'))
        self.assertEquals(Literal('foafNameNL', lang='nl'), g.findLabel(uri='u:ri'))