def _create_from_subject_predicate(self, subject, predicate): list = [] for s, p, o in self.graph.triples((subject, predicate, None)): type = predicate.split('#')[-1] if Label.is_valid_type(type): o = self._create_label(o, type) elif Note.is_valid_type(type): o = self._create_note(o, type) else: o = self._get_id_for_subject(o, self.to_text(o)) list.append(o) return list
def _create_from_subject_predicate(graph, subject, predicate): list = [] for s, p, o in graph.triples((subject, predicate, None)): type = predicate.split('#')[-1] if Label.is_valid_type(type): o = _create_label(o, type) elif Note.is_valid_type(type): o = _create_note(o, type) else: o = _split_uri(o, 1) if o: list.append(o) return list
def _create_from_subject_predicate(graph, subject, predicate): list = [] for s, p, o in graph.triples((subject, predicate, None)): type = predicate.split('#')[-1] if Label.is_valid_type(type): o = _create_label(o, type) elif Note.is_valid_type(type): o = _create_note(o, type) else: o = _split_uri(o, 1) if o: list.append(o) return list
def _create_from_subject_predicate(graph, subject, predicate, note_uris=None): list = [] for s, p, o in graph.triples((subject, predicate, None)): type = predicate.split('#')[-1] if Label.is_valid_type(type): o = _create_label(o, type) elif Note.is_valid_type(type): if o.toPython() not in note_uris: note_uris.append(o.toPython()) o = _create_note(graph, o, type, False) else: o = None else: o = uri_to_id(o) if o: list.append(o) return list
def testIsValidType(self): self.assertTrue(Label.is_valid_type('prefLabel')) self.assertFalse(Label.is_valid_type('voorkeursLabel')) l = Label('Knokke-Heist') self.assertTrue(l.is_valid_type('prefLabel'))
def testIsValidType(self): self.assertTrue(Note.is_valid_type('note')) self.assertFalse(Label.is_valid_type('notitie')) n = Note('A community in West-Flanders.', 'definition', 'en') self.assertTrue(n.is_valid_type('definition'))
def testIsValidType(self): self.assertTrue(Note.is_valid_type('note')) self.assertFalse(Label.is_valid_type('notitie')) n = Note('A community in West-Flanders.', 'definition', 'en') self.assertTrue(n.is_valid_type('definition'))
def testIsValidType(self): self.assertTrue(Label.is_valid_type('prefLabel')) self.assertFalse(Label.is_valid_type('voorkeursLabel')) l = Label('Knokke-Heist') self.assertTrue(l.is_valid_type('prefLabel'))
def _create_label(self, literal, type): if not Label.is_valid_type(type): raise ValueError('Type of Label is not valid.') return Label(self.to_text(literal), type, self._get_language_from_literal(literal))