Example #1
0
    def type(column_metadata):
        if 'datatype' not in column_metadata:
            return None
        datatype = column_metadata['datatype']
        if type(datatype) is dict:
            if '@id' in datatype:
                datatype = datatype['@id']
                return URIRef(datatype)
            datatype = datatype['base']
        if datatype in OntologyUtils._omitted_types:
            return None

        datatype = OntologyUtils._name_mappings.get(datatype, datatype)
        return OntologyUtils._type_mappings.get(datatype, XSD.term(datatype))
Example #2
0
    def parse_binary_content(self, key, values):
        """Binary content is transformed into a Literal with base64 encoding"""
        for value in values:
            base64_bytes = b64encode(str_to_binary(value)).decode('ascii')

            # @LAP: assume this is handy in the UI?
            base64_url = "data:image/jpeg;base64," + base64_bytes
            self._add((self.entry_iri, LDAP.term(key + "IRI"),
                       Literal(base64_url, datatype=XSD.anyURI)))

            # NB: Can't use rdflib.Literal with the correct datatype xsd:base64Binary,
            # as it messes with the value (decodes it), using a placeholder xsd:base64BinaryString
            # which gets replaced in the output stream, see _substitute_iris
            self._add((self.entry_iri, LDAP.term(key),
                       Literal(base64_bytes,
                               datatype=XSD.term('base64BinaryString'))))
from rdflib import Graph
from rdflib import Literal
from rdflib import OWL
from rdflib import RDF
from rdflib import RDFS
from rdflib import URIRef
from rdflib import XSD

from utils import write_graph

a = RDF.term('type')
rdfs_domain = RDFS.term('domain')
rdfs_range = RDFS.term('range')
rdfs_subClassOf = RDFS.term('subClassOf')
xsd_double = XSD.term('double')
owl_Class = OWL.term('Class')
owl_DatatypeProperty = OWL.term('DatatypeProperty')
owl_FunctionalProperty = OWL.term('FunctionalProperty')


class Iris2RDFConverter(object):
    """
    Attribute Information:

    1. sepal length in cm
    2. sepal width in cm
    3. petal length in cm
    4. petal width in cm
    5. class:
    -- Iris Setosa
    -- Iris Versicolour
from rdflib import Graph
from rdflib import Literal
from rdflib import OWL
from rdflib import URIRef
from rdflib import RDF
from rdflib import RDFS
from rdflib import XSD

from utils import write_graph

a = RDF.type
xsd_double = XSD.term('double')
xsd_int = XSD.term('integer')


class Wine2RDFConverter(object):
    """
    The attributes are (dontated by Riccardo Leardi, riclea '@' anchem.unige.it)
    1) Alcohol
    2) Malic acid
    3) Ash
    4) Alcalinity of ash
    5) Magnesium
    6) Total phenols
    7) Flavanoids
    8) Nonflavanoid phenols
    9) Proanthocyanins
    10)Color intensity
    11)Hue
    12)OD280/OD315 of diluted wines
    13)Proline