Skip to content
Snippets Groups Projects
Select Git revision
  • e783d5940c99597160cda3c2092e11e63bd924c1
  • consistent_config default protected
2 results

run_ens.jet.sh

Blame
  • validate.py 954 B
    #!/usr/bin/env python3
    # -*- coding: utf-8 -*-
    """
    Created on Thu Dec  2 23:31:39 2021
    
    @author: Cornelia Michlits
    """
    import rdflib
    g = rdflib.Graph()
    g.namespace_manager.bind('om', 'http://www.ontology-of-units-of-measure.org/resource/om-2/')
    g.parse('ontologies/om-2.ttl', format='turtle')
    
    om = rdflib.Namespace('http://www.ontology-of-units-of-measure.org/resource/om-2/')
    _exhausted = object()
    def validator(value):
        #input str
        tmp = str(om)+value
        t_uri = rdflib.term.URIRef(tmp)
        if next(g.triples((t_uri,None,om.Unit)), _exhausted) is _exhausted and next(g.triples((t_uri,None,om.PrefixedUnit)),_exhausted) is _exhausted and next(g.triples((t_uri,None,None)),_exhausted) is _exhausted:
            return False
        else:
            return True
    
    def stringmapper(thisstring):
        if ' ' in thisstring: 
            return thisstring.split(" ",1)[0].lower()+thisstring.split(" ",1)[1].title().replace(" ","")
        else: 
            return thisstring