Beispiel #1
0
    def save_keyword(self, syncher, graph, subject, data_source,
                     keyword_labels, save_set):
        keyword = syncher.get(subject)
        if not keyword:
            keyword = Keyword(data_source=self.data_source, url=subject)
            keyword._changed = True
            keyword._created = True
        else:
            keyword._created = False

        for _, literal in graph.preferredLabel(subject):
            with active_language(literal.language):
                if keyword.name != str(literal):
                    keyword.name = str(literal)
                    keyword._changed = True

        if keyword._changed:
            keyword.save()

        keyword.alt_labels.add(keyword_labels.get(str(subject), []))

        if not getattr(keyword, '_found', False):
            syncher.mark(keyword)
        return keyword
Beispiel #2
0
    def save_keyword(self, syncher, graph, subject, data_source, keyword_labels, save_set):
        keyword = syncher.get(subject)
        if not keyword:
            keyword = Keyword(
                data_source=self.data_source, url=subject)
            keyword._changed = True
            keyword._created = True
        else:
            keyword._created = False

        for _, literal in graph.preferredLabel(subject):
            with active_language(literal.language):
                if keyword.name != str(literal):
                    keyword.name = str(literal)
                    keyword._changed = True

        if keyword._changed:
            keyword.save()

        keyword.alt_labels.add(keyword_labels.get(str(subject), []))

        if not getattr(keyword, '_found', False):
            syncher.mark(keyword)
        return keyword