Exemple #1
0
 def serialize(self, file):
     RDFSerializable.serialize(self,file)
     file.write("<rdfs:label xml:lang=\"en\">has "+self.nutrient.getLabel().lower()+"</rdfs:label>\n")
     file.write("<rdfs:subPropertyOf rdf:resource=\""+NamespaceResolver.getURI("sd")+"hasMeasurement\"/>\n")
     file.write("<rdfs:range>\n")
     file.indent()
     file.write("<owl:Class>\n")
     file.indent()
     file.write("<rdfs:subClassOf rdf:resource=\""+NamespaceResolver.getURI("nndsr")+"Measurement\"/>\n")
     file.write("<rdfs:subClassOf>\n")
     file.indent()
     file.write("<owl:Restriction>\n")
     file.indent()
     file.write("<owl:onProperty rdf:resource=\""+NamespaceResolver.getURI("nndsr")+"hasUnit\"/>\n")
     file.write("<owl:hasValue rdf:resource=\""+self.nutrient.getUnit().per100g()+"\"/>\n")
     file.unindent()
     file.write("</owl:Restriction>\n")
     file.unindent()
     file.write("</rdfs:subClassOf>\n")
     file.write("<rdfs:subClassOf>\n")
     file.indent()
     file.write("<owl:Restriction>\n")
     file.indent()
     file.write("<owl:onProperty rdf:resource=\""+NamespaceResolver.getURI("nndsr")+"measureOf\"/>\n")
     file.write("<owl:hasValue rdf:resource=\""+self.nutrient.getID()+"\"/>\n")
     file.unindent()
     file.write("</owl:Restriction>\n")
     file.unindent()
     file.write("</rdfs:subClassOf>\n")
     file.unindent()
     file.write("</owl:Class>\n")
     file.unindent()
     file.write("</rdfs:range>\n")
Exemple #2
0
 def serialize(self,file):
     RDFSerializable.serialize(self,file)
     file.write("<units:derivedFromUnit rdf:resource=\""+NamespaceResolver.getURI("units")+"gram\"/>")
     file.write("<units:hasPrefix rdf:parseType=\"Resource\">")
     file.indent()
     file.write("<units:hasValue rdf:datatype=\""+NamespaceResolver.getURI("xsd")+"double\">"+self.grams+"</units:hasValue>")
     file.write("<rdf:type rdf:resource=\""+NamespaceResolver.getURI("units")+"Prefix\"/>")
     file.unindent()
     file.write("</units:hasPrefix>")
     file.write("<nndsr:measureOf rdf:resource=\""+self.food.getID()+"\"/>")
     file.write("<nndsr:multiplier rdf:datatype=\""+NamespaceResolver.getURI("xsd")+"double\">"+self.amount+"</nndsr:multiplier>")
Exemple #3
0
 def __init__(self):
     RDFSerializable.__init__(self)
     self.label = ""
     self.food = None
     self.amount = ""
     self.grams = ""
     self.order = ""
     self.addType(NamespaceResolver.getURI("units")+"UnitDerivedByScaling")
Exemple #4
0
    def serialize(self, file):
        '''
Food.serialize(file,indent):
    Serializes this food into RDF/XML specified by file
'''
        file.write("<rdf:type rdf:resource=\""+self.food_group.getID()+"\"/>")
        RDFSerializable.serialize(self, file)
        file.write("<nndsr:hasPercentRefuse rdf:datatype=\""+NamespaceResolver.getURI("xsd")+"double\">"+self.percentRefuse+"</nndsr:hasPercentRefuse>")
        file.write("<nndsr:hasNitrogenFactor rdf:datatype=\""+NamespaceResolver.getURI("xsd")+"double\">"+self.nfactor+"</nndsr:hasNitrogenFactor>")
        file.write("<nndsr:hasProteinFactor rdf:datatype=\""+NamespaceResolver.getURI("xsd")+"double\">"+self.percentRefuse+"</nndsr:hasProteinFactor>")
        file.write("<nndsr:hasFatFactor rdf:datatype=\""+NamespaceResolver.getURI("xsd")+"double\">"+self.percentRefuse+"</nndsr:hasFatFactor>")
        file.write("<nndsr:hasCarbohydrateFactor rdf:datatype=\""+NamespaceResolver.getURI("xsd")+"double\">"+self.percentRefuse+"</nndsr:hasCarbohydrateFactor>")
        if self.maker != "":
            file.write("<foaf:maker rdf:resource=\""+self.maker.getID()+"\"/>")
        for measure in self.nutrients:
            file.write("<sd:hasMeasurement>")
            file.visit(measure)
            file.write("</sd:hasMeasurement>")
Exemple #5
0
 def begin(self):
     global NamespaceResolver
     self.write("<?xml version=\"1.0\" encoding=\""+self.__encoding+"\"?>\n")
     self.write("<rdf:RDF")
     for k,v in NamespaceResolver.getNamespaces():
         self.write(" xmlns:"+k+"=\""+v+"\"")
     self.write(">\n")
     self.__indent += 2
     return self.__indent
Exemple #6
0
 def per100g(self):
     return NamespaceResolver.getURI("sd")+"kcal_per100g"
Exemple #7
0
 def getURI(self):
     return NamespaceResolver.getURI("sd")+"kilocalorie"
Exemple #8
0
 def getURI(self):
     return NamespaceResolver.getURI("sd")+"gram"
Exemple #9
0
 def getURI(self):
     return NamespaceResolver.getURI("sd")+"InternationalUnit"
Exemple #10
0
 def per100g(self):
     return NamespaceResolver.getURI("sd")+"microgram_per100g"
Exemple #11
0
 def getURI(self):
     return NamespaceResolver.getURI("sd")+"per100g"
Exemple #12
0
 def getURI(self):
     return NamespaceResolver.getURI("sd")+"kilojoule"
Exemple #13
0
 def serialize(self, file):
     RDFSerializable.serialize(self, file)
     file.write("<nndsr:hasUnit rdf:resource=\""+self.nutrient.unit.per100g()+"\"/>")
     file.write("<nndsr:measureOf rdf:resource=\""+self.nutrient.getID()+"\"/>")
     file.write("<nndsr:measuredValue rdf:datatype=\""+NamespaceResolver.getURI("xsd")+"double\">"+self.amount+"</nndsr:measuredValue>")
Exemple #14
0
 def getID(self):
     return NamespaceResolver.getURI("nndsr")+"has"+compressString(self.nutrient.label)
Exemple #15
0
 def __init__(self):
     RDFSerializable.__init__(self)
     self.id = ""
     self.label = ""
     self.addType(NamespaceResolver.getURI("owl")+"Class")
Exemple #16
0
 def getID(self):
     return NamespaceResolver.getURI("nndsr")+"food-groups/"+self.id