예제 #1
0
    def runAnalyzis(self):
        self.relations = []
        #the selection model needs to be here, since the table model is reinstalled when the user asks for new suggestions
        self.table.selectionModel().currentChanged.connect(self.selectionChanged)
        
        #populate existing relations for not suggesting entities that are already linked to the current resource
        directRelations = datamanager.findDirectRelations(self.resource.uri())
        for predicate in directRelations.keys():
            for resource in directRelations[predicate]:
                self.relations.append(resource)
        
        inverseRelations = datamanager.findInverseRelations(self.resource.uri())
        for tuple in inverseRelations:
            resource = tuple[0]
            self.relations.append(resource)

        self.loop = gobject.MainLoop()
        datamanager.analyzeText(self.text, self.newEntityHandler, self.finishedAnalyzisHandler)
        
        datamanager.analyzeText(self.title, self.newEntityHandler, self.finishedAnalyzisHandler)
        
        if self.doImageAnalysis:
            print "analysing image %s" % self.path
            datamanager.analyzeResource(self.path, self.newEntityHandler, self.textExtractedHandler, self.finishedImageAnalyzisHandler)
        
        
        self.loop.run()
예제 #2
0
    def createModel(self):

        self.model = RelationsTableModel(self)
        #self.model.setHeaders([i18n("Relation"), i18n("Title"), i18n("Date"), i18n("Type") ])
        self.model.setHeaders(["", i18n("Title"), i18n("Type"), i18n("Date")])

        if self.resource:
            relations = datamanager.findDirectRelations(self.resource.uri())

            data = []
            for predicate in relations.keys():
                for resource in relations[predicate]:
                    data.append((predicate, resource, True))

            inverseRelations = datamanager.findInverseRelations(
                self.resource.uri())
            for tuple in inverseRelations:
                resource = tuple[0]
                predicate = tuple[1]
                #for resource in inverseRelations[predicate]:
                #TODO: see why we get some resources with a void predicate sometimes
                if predicate and predicate.uri() and len(
                        str(predicate.uri().toString())) > 0:
                    data.append((predicate, resource, False))

            self.model.setRelations(data)
예제 #3
0
    def runAnalyzis(self):
        self.relations = []
        # the selection model needs to be here, since the table model is reinstalled when the user asks for new suggestions
        self.table.selectionModel().currentChanged.connect(self.selectionChanged)

        # populate existing relations for not suggesting entities that are already linked to the current resource
        directRelations = datamanager.findDirectRelations(self.resource.uri())
        for predicate in directRelations.keys():
            for resource in directRelations[predicate]:
                self.relations.append(resource)

        inverseRelations = datamanager.findInverseRelations(self.resource.uri())
        for tuple in inverseRelations:
            resource = tuple[0]
            self.relations.append(resource)

        self.loop = gobject.MainLoop()
        datamanager.analyzeText(self.text, self.newEntityHandler, self.finishedAnalyzisHandler)

        datamanager.analyzeText(self.title, self.newEntityHandler, self.finishedAnalyzisHandler)

        if self.doImageAnalysis:
            print "analysing image %s" % self.path
            datamanager.analyzeResource(
                self.path, self.newEntityHandler, self.textExtractedHandler, self.finishedImageAnalyzisHandler
            )

        self.loop.run()
예제 #4
0
    def createModel(self):
        
        self.model = RelationsTableModel(self)
        #self.model.setHeaders([i18n("Relation"), i18n("Title"), i18n("Date"), i18n("Type") ])
        self.model.setHeaders(["", i18n("Title"), i18n("Type"),i18n("Date") ])
        
        if self.resource:
            relations = datamanager.findDirectRelations(self.resource.uri())

            data = []
            for predicate in relations.keys():
                for resource in relations[predicate]:
                    data.append((predicate, resource, True))

            inverseRelations = datamanager.findInverseRelations(self.resource.uri())
            for tuple in inverseRelations:
                resource = tuple[0]
                predicate = tuple[1]
                #for resource in inverseRelations[predicate]:
                #TODO: see why we get some resources with a void predicate sometimes
                if predicate and predicate.uri() and len(str(predicate.uri().toString())) > 0:
                    data.append((predicate, resource, False))
            
            self.model.setRelations(data)