Exemplo n.º 1
0
 def __init__(self):
     '''
     Constructor
     '''
     RDFSerializable.__init__(self)
     self.nutrient = None
     self.amount = 0
Exemplo n.º 2
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")
Exemplo n.º 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")
Exemplo n.º 4
0
 def __init__(self, label="", unit=None, number=0):
     RDFSerializable.__init__(self)
     self.label = label
     self.unit = unit
     self.number = number
     if unit is not None:
         self.property = self.getProperty()
     else:
         self.property = None
Exemplo n.º 5
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>")
Exemplo n.º 6
0
 def __init__(self):
     RDFSerializable.__init__(self)
     self.id = ""
     self.food_group = None
     self.label = ""
     self.maker = ""
     self.percentRefuse = ""
     self.nfactor = ""
     self.profactor = ""
     self.fatfactor = ""
     self.chofactor = ""
     self.nutrients = []
Exemplo n.º 7
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>")
Exemplo n.º 8
0
 def serialize(self,file):
     RDFSerializable.serialize(self, file)
Exemplo n.º 9
0
 def __init__(self, label):
     RDFSerializable.__init__(self)
     self.label = label
Exemplo n.º 10
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>")
Exemplo n.º 11
0
 def serialize(self, file):
     RDFSerializable.serialize(self, file)
     file.write("<sd:measuredIn rdf:resource=\""+self.unit.per100g()+"\"/>")
Exemplo n.º 12
0
 def __init__(self):
     RDFSerializable.__init__(self)
     self.id = ""
     self.label = ""
     self.addType(NamespaceResolver.getURI("owl")+"Class")