Exemplo n.º 1
0
 def to_triple(self, person):
     global g
     g = rdflib.Graph()
     namespace_manager = rdflib.namespace.NamespaceManager(g)
     bind_ns(namespace_manager, NS_DICT)
     g.add((person.uri, self.predicate, self.value))
     return g
Exemplo n.º 2
0
    def to_triple(self, person):
        global g
        g = rdflib.Graph()
        namespace_manager = rdflib.namespace.NamespaceManager(g)
        bind_ns(namespace_manager, NS_DICT)

        if self != None:
            for name in self.names:
                g.add((person.uri,
                       NS_DICT["cwrc"].hasInterpersonalRelationshipWith,
                       createPerson(name)))
            # listProperties = {}
            # listProperties["subjectName"] = getStandardUri(person.name)
            # listProperties["unchangedName"]= person.name
            # listProperties["descType"] = NS_DICT["cwrc"].selfsAndAssociatesContext
            # spList = []
            # for name in self.names:
            #     dictEntry = {}
            #     dictEntry["p"]  = "cwrc.hasInterpersonalRelationshipWith"
            #     dictEntry["o"]     = name
            #     dictEntry["prsn"]   = True
            #     spList.append(dictEntry)
            # listProperties["subjectsObjects"] = spList
            # person.contextCounts["friendsAssociates"] = addContextsNew(person.id,"FriendsAndAssociatesContext",self.contexts,person.uri,person.contextCounts["friendsAssociates"],listProperties)

        # print(g.serialize(format='turtle').decode())
        return g
Exemplo n.º 3
0
    def to_triple(self):
        global g
        spList = []
        g = rdflib.Graph()
        namespace_manager = rdflib.namespace.NamespaceManager(g)
        bind_ns(namespace_manager, NS_DICT)
        if self.birthDate != "":
            g.add((self.uri, NS_DICT["cwrc"].hasBirthDate,
                   format_date(self.birthDate)))
            spList.append(
                addDict("cwrc.hasBirthDate", format_date(self.birthDate),
                        False))

        for birthPosition in self.birthPositions:
            if birthPosition == "ONLY":
                positionObj = NS_DICT["cwrc"].onlyChild
            elif birthPosition == "ELDEST":
                positionObj = NS_DICT["cwrc"].eldestChild
            elif birthPosition == "YOUNGEST":
                positionObj = NS_DICT["cwrc"].youngestChild
            elif birthPosition == "MIDDLE:":
                positionObj = NS_DICT["cwrc"].middleChild
            g.add((self.uri, NS_DICT["cwrc"].hasBirthPosition, positionObj))
            spList.append(
                addDict("cwrc.hasBirthPosition",
                        longFormtoShort(Literal(positionObj)), False))

        if self.birthplace:
            g.add((self.uri, NS_DICT["cwrc"].hasBirthPlace, self.birthplace))
            spList.append(addDict("cwrc.hasBirthPlace", self.birthplace,
                                  False))

        # if self.birthContexts != None and len(self.birthContexts) > 0:
        #     listProperties = {}
        #     listProperties["subjectName"] = getStandardUri(self.name)
        #     listProperties["unchangedName"] = self.name
        #     listProperties["descType"] = NS_DICT["cwrc"].FriendsAndAssociatesContext
        #     listProperties["subjectsObjects"] = spList
        #
        #     for context in self.birthContexts:
        #         addContextsNew(self.id,"birthContext",context,self.uri,1,listProperties)
        return g
Exemplo n.º 4
0
    def to_triple(self, person):
        global g
        g = rdflib.Graph()
        namespace_manager = rdflib.namespace.NamespaceManager(g)
        bind_ns(namespace_manager, NS_DICT)
        g.add((person.uri, self.predicate, self.value))
        # spList = []

        # for relationship in intmtRelationships.Persons:

        # listProperties = {}
        # listProperties["subjectName"] = getStandardUri(person.name)
        # listProperties["unchangedName"]= person.name
        # listProperties["descType"] = NS_DICT["cwrc"].IntimateRelationshipsContext
        # listProperties["subjectsObjects"] = spList
        #
        # person.contextCounts["intimateRelationship"] = addContextsNew(person.id, "hasIntimateRelationshipsContext", self.Context,
        #                                     person.uri, person.contextCounts["intimateRelationship"], listProperties)

        return g
Exemplo n.º 5
0
    def to_triples(self):
        global g
        spList = []
        g = rdflib.Graph()
        namespace_manager = rdflib.namespace.NamespaceManager(g)
        bind_ns(namespace_manager, NS_DICT)
        if self is not None:
            # if dateValidate(self.deathInfo.deathDate):
            if self.deathDate != "":
                g.add((self.uri, NS_DICT["cwrc"].hasDeathDate,
                       format_date(self.deathDate)))
                spList.append(
                    addDict("cwrc.hasDeathDate", Literal(self.deathDate),
                            False))

            if self.deathplace:
                g.add(
                    (self.uri, NS_DICT["cwrc"].hasDeathPlace, self.deathplace))
                spList.append(
                    addDict("cwrc.hasDeathPlace", self.deathplace, False))

            if self.burialplace:
                g.add((self.uri, NS_DICT["cwrc"].hasBurialPlace,
                       self.burialplace))
                spList.append(
                    addDict("cwrc.hasBurialPlace", self.burialplace, False))

            # if self.deathContexts != None and len(self.deathContexts) > 0:
            #     listProperties = {}
            #     listProperties["subjectName"] = getStandardUri(self.name)
            #     listProperties["unchangedName"] = self.name
            #     listProperties["descType"] = NS_DICT["cwrc"].FriendsAndAssociatesContext
            #     listProperties["subjectsObjects"] = spList
            #     for context in self.deathContexts:
            #         addContextsNew(self.id, "deathContext", context, self.uri, 1, listProperties)
            #
            #     # addContexts(fileName,"hasDeathContext",self.deathContexts,sou
        return g
Exemplo n.º 6
0
    def to_triple(self, person):
        global g
        g = rdflib.Graph()
        namespace_manager = rdflib.namespace.NamespaceManager(g)
        bind_ns(namespace_manager, NS_DICT)
        sourceName = getStandardUri(person.name)
        memberName = self.memberName
        print("=======", memberName, "=========")
        # FIXME : name rearranement removed to match alliyya's code
        # if ',' in memberName:
        #     splitName = memberName.split(",")
        #     memberName = splitName[1].strip() + " " + splitName[0].strip()
        # memberName = getStandardUri(memberName)
        memberSource = URIRef(
            str(NS_DICT["data"]) + getStandardUri(memberName))
        if self.isNoName:
            if self.noNameLetter == "":
                # print(sourceName, memberName)
                # if self.memberRelation == "UNCLE":
                #     if (source, URIRef(str(NS_DICT["cwrc"]) + "hasUncle"),None) in g:
                #         print("multipleUncles")
                #     print(self.memberRelation)
                memberSource = URIRef(
                    str(NS_DICT["data"]) + sourceName.replace(" ", "_") + "_" +
                    self.memberRelation.lower().title())

            else:
                memberSource = URIRef(
                    str(NS_DICT["data"]) + sourceName.replace(" ", "_") + "_" +
                    self.memberRelation.lower().title() + "_" +
                    self.noNameLetter)

        else:
            g.add((memberSource, NS_DICT["foaf"].name, Literal(memberName)))

        g.add((memberSource, RDF.type, NS_DICT["cwrc"].NaturalPerson))

        for jobs in self.memberJobs:
            if jobs.job == "":
                continue
            if jobs.predicate == "familyOccupation":
                predicate = NS_DICT["cwrc"].hasFamilyBasedOccupation
            else:
                predicate = NS_DICT["cwrc"].hasPaidOccupation

            # FIXME : change jobs to jogs.job in order to make the thing work. right now, it is not functional.

            # if jobs in occupations:
            #     g.add((memberSource, predicate, Literal(occupations[jobs.job].title())))
            # else:
            g.add((memberSource, predicate, Literal(jobs.job.strip().title())))
            # print("added job ", jobs)

        for sigActs in self.memberSigActs:
            if sigActs.job == "":
                continue
            if sigActs.predicate == "volunteerOccupation":
                predicate = NS_DICT["cwrc"].hasVolunteerOccupation
            else:
                predicate = NS_DICT["cwrc"].hasOccupation

            g.add((memberSource, predicate,
                   Literal(sigActs.job.strip().title())))
            # print("added significant ", sigActs)

        cwrcTag = getCwrcTag(self.memberRelation)

        predicate = URIRef(str(NS_DICT["cwrc"]) + cwrcTag)
        # g.add((source,predicate,Literal(memberName)))
        g.add((person.uri, predicate, memberSource))
        return g