<commit_before>__author__ = 'nicole'

from rdflib import Graph, Literal, URIRef, Namespace
from rdflib.namespace import RDF, DCTERMS, XSD, FOAF

class Dataset:

    #this will produce the metadata about a dataset
    #following the example laid out here: http://htmlpreview.github.io/?https://github.com/joejimbo/HCLSDatasetDescriptions/blob/master/Overview.html#appendix_1

    namespaces = {
        'dctypes' : 'http://purl.org/dc/dcmitype/',
        'pav' : 'http://purl.org/pav/',
        'dcat' : 'http://www.w3.org/ns/dcat#'
    }

    core_bindings = {'rdf': RDF, 'foaf': FOAF, 'xsd': XSD, 'dct': DCTERMS}

    def __init__(self,identifier, title, url, description=None):
        DCTYPES=Namespace(self.namespaces['dctypes'])
        self.identifier = URIRef(':'+identifier)
        self.graph = Graph()
        self.load_bindings()
        self.graph.add((self.identifier,RDF['type'],DCTYPES['Dataset']))
        self.graph.add((self.identifier,DCTERMS['title'], Literal(title)))
        self.graph.add((self.identifier,DCTERMS['identifier'], Literal(identifier)))
        self.graph.add((self.identifier,FOAF['page'], URIRef(url)))
        #maybe in the future add the logo here:
        #schemaorg:logo <http://www.ebi.ac.uk/rdf/sites/ebi.ac.uk.rdf/files/resize/images/rdf/chembl_service_logo-146x48.gif> .

        #TODO add the licence info
        #self.graph.add((self.identifier, DCTERMS['license'], URIRef(license_url)))
        #self.graph.add((self.identifier, DCTERMS['rights'], Literal(data_rights)))

        if (description is not None):
            self.graph.add((':'+identifier,DCTERMS['description'],description))
        return

    def load_bindings(self):
        for k in self.core_bindings:
            v=self.core_bindings[k]
            self.graph.bind(k, v)

        for k in self.namespaces.keys():
            v=self.namespaces[k]
            self.graph.bind(k, Namespace(v))

        return


    def setVersion(self,date_issued,version_id=None):
        PAV=Namespace(self.namespaces['pav'])

        #default to setting the version to the date, if no version specified
        if(version_id is None):
            version_id = date_issued
        self.version = URIRef(self.identifier+version_id)
        #todo verify date
        #date in YYYY-MM-DD format

        self.graph.add((self.identifier, DCTERMS['issued'], Literal(date_issued)))
        self.graph.add((self.version, DCTERMS['isVersionOf'], self.identifier))
        self.graph.add((self.version, PAV['version'], Literal(version_id)))
        return

    def setFileAccessUrl(self, url):
        DCAT=Namespace(self.namespaces['dcat'])
        self.graph.add((self.identifier, DCAT['accessURL'],URIRef(url)))
        return

    def getGraph(self):<commit_msg>added console feedback<commit_after>__author__ = 'nicole'

from rdflib import Graph, Literal, URIRef, Namespace
from rdflib.namespace import RDF, DCTERMS, XSD, FOAF

class Dataset:

    #this will produce the metadata about a dataset
    #following the example laid out here: http://htmlpreview.github.io/?https://github.com/joejimbo/HCLSDatasetDescriptions/blob/master/Overview.html#appendix_1

    namespaces = {
        'dctypes' : 'http://purl.org/dc/dcmitype/',
        'pav' : 'http://purl.org/pav/',
        'dcat' : 'http://www.w3.org/ns/dcat#'
    }

    core_bindings = {'rdf': RDF, 'foaf': FOAF, 'xsd': XSD, 'dct': DCTERMS}

    def __init__(self,identifier, title, url, description=None):
        DCTYPES=Namespace(self.namespaces['dctypes'])
        self.identifier = URIRef(':'+identifier)
        self.graph = Graph()
        self.load_bindings()
        self.graph.add((self.identifier,RDF['type'],DCTYPES['Dataset']))
        self.graph.add((self.identifier,DCTERMS['title'], Literal(title)))
        self.graph.add((self.identifier,DCTERMS['identifier'], Literal(identifier)))
        self.graph.add((self.identifier,FOAF['page'], URIRef(url)))
        #maybe in the future add the logo here:
        #schemaorg:logo <http://www.ebi.ac.uk/rdf/sites/ebi.ac.uk.rdf/files/resize/images/rdf/chembl_service_logo-146x48.gif> .

        #TODO add the licence info
        #self.graph.add((self.identifier, DCTERMS['license'], URIRef(license_url)))
        #self.graph.add((self.identifier, DCTERMS['rights'], Literal(data_rights)))

        if (description is not None):
            self.graph.add((':'+identifier,DCTERMS['description'],description))
        return

    def load_bindings(self):
        for k in self.core_bindings:
            v=self.core_bindings[k]
            self.graph.bind(k, v)

        for k in self.namespaces.keys():
            v=self.namespaces[k]
            self.graph.bind(k, Namespace(v))

        return


    def setVersion(self,date_issued,version_id=None):
        PAV=Namespace(self.namespaces['pav'])

        #default to setting the version to the date, if no version specified
        if(version_id is None):
            version_id = date_issued
        self.version = URIRef(self.identifier+version_id)
        #todo verify date
        #date in YYYY-MM-DD format

        self.graph.add((self.identifier, DCTERMS['issued'], Literal(date_issued)))
        self.graph.add((self.version, DCTERMS['isVersionOf'], self.identifier))
        self.graph.add((self.version, PAV['version'], Literal(version_id)))

        print("INFO: setting version to",version_id)

        return

    def setFileAccessUrl(self, url):
        DCAT=Namespace(self.namespaces['dcat'])
        self.graph.add((self.identifier, DCAT['accessURL'],URIRef(url)))
        return

    def getGraph(self):
{'fraction_non_alphanumeric': 0.14387974230493916, 'fraction_numerical': 0.0025053686471009306, 'mean_word_length': 3.0825420014609204, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7174775', 'n_tokens_mistral': 1865, 'n_tokens_neox': 1808, 'n_words': 325}