Beispiel #1
0
def main():
    """
    Generate the enums for positions
    """
    print datetime.now(), "Start"
    parms = get_parms()

    #   person via Orcid

    query = """
    SELECT (MIN (?xshort) AS ?short) ?vivo
    WHERE
    {
          ?vivo vivo:orcidId ?xshort .
    }
    GROUP BY ?vivo
    ORDER BY ?short
    """

    create_enum("orcid_enum.txt", query, parms)

    #   department via label

    query = """
    SELECT (MIN (?xlabel) AS ?short) ?vivo
    WHERE
    {
          {?vivo a vivo:Department . } UNION {?vivo a vivo:Institute . } UNION {?vivo a vivo:School . }
          UNION {?vivo a vivo:Center .} UNION {?vivo a vivo:College . }
          ?vivo rdfs:label ?xlabel .
    }
    GROUP BY ?vivo
    ORDER BY ?short
    """

    create_enum("dept_enum.txt", query, parms)

    #   dates via datetime

    query = """
    SELECT ?short ?vivo
    WHERE
    {
          ?vivo a vivo:DateTimeValue .
#          ?vivo vivo:dateTimePrecision vivo:yearMonthDayPrecision .
          ?vivo vivo:dateTime ?short .
    }
    ORDER BY ?short
    """

    create_enum("date_enum.txt", query, parms, trim=10)

    print datetime.now(), "End"
Beispiel #2
0
def main():
    """
    Generate the enums for positions
    """
    print datetime.now(), "Start"
    parms = get_parms()

    #   person via Orcid

    query = """
    SELECT (MIN (?xshort) AS ?short) ?vivo
    WHERE
    {
          ?vivo vivo:orcidId ?xshort .
    }
    GROUP BY ?vivo
    ORDER BY ?short
    """

    create_enum("orcid_enum.txt", query, parms)

    #   department via label

    query = """
    SELECT (MIN (?xlabel) AS ?short) ?vivo
    WHERE
    {
          {?vivo a vivo:Department . } UNION {?vivo a vivo:Institute . } UNION {?vivo a vivo:School . }
          UNION {?vivo a vivo:Center .} UNION {?vivo a vivo:College . }
          ?vivo rdfs:label ?xlabel .
    }
    GROUP BY ?vivo
    ORDER BY ?short
    """

    create_enum("dept_enum.txt", query, parms)

    #   dates via datetime

    query = """
    SELECT ?short ?vivo
    WHERE
    {
          ?vivo a vivo:DateTimeValue .
#          ?vivo vivo:dateTimePrecision vivo:yearMonthDayPrecision .
          ?vivo vivo:dateTime ?short .
    }
    ORDER BY ?short
    """

    create_enum("date_enum.txt", query, parms, trim=10)

    print datetime.now(), "End"
Beispiel #3
0
def main():
    """
    Generate the enums for positions
    """
    print datetime.now(), "Start"
    parms = get_parms()

    #   person via Orcid

    query = """
    SELECT (MIN (?xshort) AS ?short) ?vivo
    WHERE
    {
          ?vivo vivo:orcidId ?xshort .
    }
    GROUP BY ?vivo
    ORDER BY ?short
    """

    create_enum("orcid_enum.txt", query, parms)

    #   journals via issn

    query = """
    SELECT (MIN (?xlabel) AS ?short) ?vivo
    WHERE
    {
          ?vivo a bibo:Journal .
          ?vivo rdfs:label ?xlabel .
    }
    GROUP BY ?vivo
    ORDER BY ?short
    """

    create_enum("journal_enum.txt", query, parms)

    #   dates via datetime

    query = """
    SELECT ?short ?vivo
    WHERE
    {
          ?vivo a vivo:DateTimeValue .
#          ?vivo vivo:dateTimePrecision vivo:yearMonthDayPrecision .
          ?vivo vivo:dateTime ?short .
    }
    ORDER BY ?short
    """

    create_enum("date_enum.txt", query, parms, trim=10)

    print datetime.now(), "End"
Beispiel #4
0
def main():
    """
    Generate the enums for positions
    """
    print datetime.now(), "Start"
    parms = get_parms()

    #   person via Orcid

    query = """
    SELECT (MIN (?xshort) AS ?short) ?vivo
    WHERE
    {
          ?vivo vivo:orcidId ?xshort .
    }
    GROUP BY ?vivo
    ORDER BY ?short
    """

    create_enum("orcid_enum.txt", query, parms)

    #   journals via issn

    query = """
    SELECT (MIN (?xlabel) AS ?short) ?vivo
    WHERE
    {
          ?vivo a bibo:Journal .
          ?vivo rdfs:label ?xlabel .
    }
    GROUP BY ?vivo
    ORDER BY ?short
    """

    create_enum("journal_enum.txt", query, parms)

    #   dates via datetime

    query = """
    SELECT ?short ?vivo
    WHERE
    {
          ?vivo a vivo:DateTimeValue .
#          ?vivo vivo:dateTimePrecision vivo:yearMonthDayPrecision .
          ?vivo vivo:dateTime ?short .
    }
    ORDER BY ?short
    """

    create_enum("date_enum.txt", query, parms, trim=10)

    print datetime.now(), "End"
Beispiel #5
0
def main():
    """
    Generate the enums for degrees
    """
    print datetime.now(), "Start"
    parms = get_parms()

    #   person

    query = """
    SELECT (MIN (?xlabel) AS ?short) ?vivo
    WHERE
    {
          ?vivo rdf:type vivo:GeographicLocation .
          ?vivo rdfs:label ?xlabel .
    }
    GROUP BY ?vivo
    ORDER BY ?short
    """

    create_enum("location_enum.txt", query, parms)

    print datetime.now(), "End"
Beispiel #6
0
def main():
    """
    Generate the enums for concepts
    """
    print datetime.now(), "Start"
    parms = get_parms()

    #   Concept

    query = """
    SELECT (MIN (?xlabel) AS ?short) ?vivo
    WHERE
    {
          ?vivo rdf:type skos:Concept .
          ?vivo rdfs:label ?xlabel .
    }
    GROUP BY ?vivo
    ORDER BY ?short
    """

    create_enum("concept_enum.txt", query, parms)

    print datetime.now(), "End"
Beispiel #7
0
from vivopump import read_csv_fp, write_csv_fp, get_vivo_authors, get_parms
import sys


def disambiguate_author(author, vivo_authors):
    """
    Given an author dictionary with name parts, find matches in the data structure returned by get_vivo_authors
    :param author: dictionary of name parts
    :param vivo_authors: authors in VIVO, seven dictionaries with seven keys based on various types of name parts
    :return: list of uri in vivo matching the author
    """
    author_uri_list = []
    return author_uri_list


parms = get_parms()
data_in = read_csv_fp(sys.stdin)
print >> sys.stderr, len(data_in)
vivo_authors = get_vivo_authors(
    parms)  # get dictionaries of authors keyed by name parts
print >> sys.stderr, 'VIVO authors', len(vivo_authors)
print >> sys.stderr, vivo_authors
data_out = {}
row_out = 0

for row, data in data_in.items():
    if data['uf'] == 'false':  # Always put in the non-UF author as new
        row_out += 1
        data_out[row_out] = data
        data_out[row_out]['uri'] = ''
    else:
Beispiel #8
0
    1. Course in VIVO and in Source => Update VIVO from source
    1. Course in VIVO, not in source => nothing to do
    1. Course not in VIVO, is in source => Add to VIVO

    See CHANGELOG.md for history
"""

__author__ = "Michael Conlon"
__copyright__ = "Copyright 2015 (c) Michael Conlon"
__license__ = "New BSD License"
__version__ = "0.02"

from vivopump import read_csv_fp, write_csv_fp, get_vivo_ccn, get_parms
import sys

parms = get_parms()
data_in = read_csv_fp(sys.stdin)
print >>sys.stderr, len(data_in)
data_out = {}
vivo_courses = get_vivo_ccn(parms)  # get dictionary of course uri keyed by ccn
print >>sys.stderr, 'VIVO courses', len(vivo_courses)

for row, data in data_in.items():
    new_data = dict(data)
    if data['ccn'] in vivo_courses:  # ccn is in vivo and source
        new_data['uri'] = vivo_courses[data['ccn']]
    else:  # key is in source, not in vivo
        new_data['uri'] = ''
    data_out[row] = new_data

print >>sys.stderr, 'data out', len(data_out)
Beispiel #9
0
def main():
    """
    Generate the enums for teaching
    """
    print datetime.now(), "Start"
    parms = get_parms()

    #   person via Orcid

    query = """
    SELECT (MIN (?xshort) AS ?short) ?vivo
    WHERE
    {
          ?vivo vivo:orcidId ?xshort .
    }
    GROUP BY ?vivo
    ORDER BY ?short
    """

    create_enum("orcid_enum.txt", query, parms)

    #   Course via label

    query = """
    SELECT (MIN (?xlabel) AS ?short) ?vivo
    WHERE
    {
          ?vivo a vivo:Course .
          ?vivo rdfs:label ?xlabel .
    }
    GROUP BY ?vivo
    ORDER BY ?short
    """

    create_enum("course_enum.txt", query, parms)

    #   Concept via label

    query = """
    SELECT (MIN (?xlabel) AS ?short) ?vivo
    WHERE
    {
          ?vivo a skos:Concept .
          ?vivo rdfs:label ?xlabel .
    }
    GROUP BY ?vivo
    ORDER BY ?short
    """

    create_enum("concept_enum.txt", query, parms)

    #   dates via datetime

    query = """
    SELECT ?short ?vivo
    WHERE
    {
          ?vivo a vivo:DateTimeValue .
#          ?vivo vivo:dateTimePrecision vivo:yearMonthDayPrecision .
          ?vivo vivo:dateTime ?short .
    }
    ORDER BY ?short
    """

    create_enum("date_enum.txt", query, parms, trim=10)

    print datetime.now(), "End"
Beispiel #10
0
def main():
    """
    Generate the enums for awards
    """
    print datetime.now(), "Start"
    parms = get_parms()

    #   person

    query = """
    SELECT ?short ?vivo
    WHERE {
      ?vivo a foaf:Person .
      ?vivo rdfs:label ?short .
    }
    ORDER BY ?short
    """

    create_enum("person_enum.txt", query, parms)

    #   school

    query = """
    SELECT ?short ?vivo
    WHERE {
      ?vivo a foaf:Organization .
      ?vivo rdfs:label ?short .
    }
    ORDER BY ?short
    """

    create_enum("org_enum.txt", query, parms)

    #   date

    query = """
    SELECT ?short ?vivo
    WHERE {
      ?vivo a vivo:DateTimeValue .
      ?vivo vivo:dateTimePrecision vivo:yearPrecision .
      ?vivo vivo:dateTime ?short .
    }
    ORDER BY ?short
    """

    create_enum("date_enum.txt", query, parms, trim=4)

    #   academic degree

    query = """
    SELECT ?short ?vivo
    WHERE {
      ?vivo a vivo:Award .
      ?vivo rdfs:label ?short .
    }
    ORDER BY ?short
    """

    create_enum("award_enum.txt", query, parms)

    print datetime.now(), "End"
    return None
Beispiel #11
0
def main():
    """
    Generate the enums for awards
    """
    print datetime.now(), "Start"
    parms = get_parms()

    #   person

    query = """
    SELECT ?short ?vivo
    WHERE {
      ?vivo a foaf:Person .
      ?vivo rdfs:label ?short .
    }
    ORDER BY ?short
    """

    create_enum("person_enum.txt", query, parms)

    #   school

    query = """
    SELECT ?short ?vivo
    WHERE {
      ?vivo a foaf:Organization .
      ?vivo rdfs:label ?short .
    }
    ORDER BY ?short
    """

    create_enum("org_enum.txt", query, parms)

    #   date

    query = """
    SELECT ?short ?vivo
    WHERE {
      ?vivo a vivo:DateTimeValue .
      ?vivo vivo:dateTimePrecision vivo:yearPrecision .
      ?vivo vivo:dateTime ?short .
    }
    ORDER BY ?short
    """

    create_enum("date_enum.txt", query, parms, trim=4)

    #   academic degree

    query = """
    SELECT ?short ?vivo
    WHERE {
      ?vivo a vivo:Award .
      ?vivo rdfs:label ?short .
    }
    ORDER BY ?short
    """

    create_enum("award_enum.txt", query, parms)

    print datetime.now(), "End"
    return None
Beispiel #12
0
def main():
    """
    Generate the enums for degrees
    """
    print datetime.now(), "Start"
    parms = get_parms()

    #   person

    query = """
    SELECT (MIN (?xlabel) AS ?short) ?vivo
    WHERE
    {
          ?vivo a foaf:Person .
          ?vivo rdfs:label ?xlabel .
    }
    GROUP BY ?vivo
    ORDER BY ?short
    """

    create_enum("person_enum.txt", query, parms)

    #   degree

    query = """
    SELECT (MIN (?xlabel) AS ?short) ?vivo
    WHERE
    {
          ?vivo a vivo:AcademicDegree .
          ?vivo rdfs:label ?xlabel .
    }
    GROUP BY ?vivo
    ORDER BY ?short
    """

    create_enum("degree_enum.txt", query, parms)

    #   school

    query = """
    SELECT (MIN (?xlabel) AS ?short) ?vivo
    WHERE
    {
          ?vivo a vivo:University .
          ?vivo rdfs:label ?xlabel .
    }
    GROUP BY ?vivo
    ORDER BY ?short
    """

    create_enum("school_enum.txt", query, parms)

    #   dates

    query = """
    SELECT ?short ?vivo
    WHERE
    {
          ?vivo a vivo:DateTimeValue .
#          ?vivo vivo:dateTimePrecision vivo:yearMonthPrecision .
          ?vivo vivo:dateTime ?short .
    }
    ORDER BY ?short
    """

    create_enum("date_enum.txt", query, parms, trim=7)

    print datetime.now(), "End"
Beispiel #13
0
def main():
    """
    Generate the enums for teaching
    """
    print datetime.now(), "Start"
    parms = get_parms()

    #   person via Orcid

    query = """
    SELECT (MIN (?xshort) AS ?short) ?vivo
    WHERE
    {
          ?vivo vivo:orcidId ?xshort .
    }
    GROUP BY ?vivo
    ORDER BY ?short
    """

    create_enum("orcid_enum.txt", query, parms)

    #   Course via label

    query = """
    SELECT (MIN (?xlabel) AS ?short) ?vivo
    WHERE
    {
          ?vivo a vivo:Course .
          ?vivo rdfs:label ?xlabel .
    }
    GROUP BY ?vivo
    ORDER BY ?short
    """

    create_enum("course_enum.txt", query, parms)

    #   Concept via label

    query = """
    SELECT (MIN (?xlabel) AS ?short) ?vivo
    WHERE
    {
          ?vivo a skos:Concept .
          ?vivo rdfs:label ?xlabel .
    }
    GROUP BY ?vivo
    ORDER BY ?short
    """

    create_enum("concept_enum.txt", query, parms)

    #   dates via datetime

    query = """
    SELECT ?short ?vivo
    WHERE
    {
          ?vivo a vivo:DateTimeValue .
#          ?vivo vivo:dateTimePrecision vivo:yearMonthDayPrecision .
          ?vivo vivo:dateTime ?short .
    }
    ORDER BY ?short
    """

    create_enum("date_enum.txt", query, parms, trim=10)

    print datetime.now(), "End"
Beispiel #14
0
def main():
    """
    Generate the enums for degrees
    """
    print datetime.now(), "Start"
    parms = get_parms()

    #   person via Orcid

    query = """
    SELECT (MIN (?xshort) AS ?short) ?vivo
    WHERE
    {
          ?vivo vivo:orcidId ?xshort .
    }
    GROUP BY ?vivo
    ORDER BY ?short
    """

    create_enum("orcid_enum.txt", query, parms)

    #   degree

    query = """
    SELECT (MIN (?xlabel) AS ?short) ?vivo
    WHERE
    {
          ?vivo a vivo:AcademicDegree .
          ?vivo rdfs:label ?xlabel .
    }
    GROUP BY ?vivo
    ORDER BY ?short
    """

    create_enum("degree_enum.txt", query, parms)

    #   dates

    query = """
    SELECT ?short ?vivo
    WHERE
    {
          ?vivo a vivo:DateTimeValue .
          ?vivo vivo:dateTimePrecision vivo:yearPrecision .
          ?vivo vivo:dateTime ?short .
    }
    ORDER BY ?short
    """

    create_enum("date_enum.txt", query, parms, trim=4)

    #   Concept via label

    query = """
    SELECT (MIN (?xlabel) AS ?short) ?vivo
    WHERE
    {
          ?vivo a skos:Concept .
          ?vivo rdfs:label ?xlabel .
    }
    GROUP BY ?vivo
    ORDER BY ?short
    """

    create_enum("concept_enum.txt", query, parms)

    print datetime.now(), "End"
Beispiel #15
0
def main():
    """
    Generate the enums for degrees
    """
    print datetime.now(), "Start"
    parms = get_parms()

    #   person

    query = """
    SELECT (MIN (?xlabel) AS ?short) ?vivo
    WHERE
    {
          ?vivo a foaf:Person .
          ?vivo rdfs:label ?xlabel .
    }
    GROUP BY ?vivo
    ORDER BY ?short
    """

    create_enum("person_enum.txt", query, parms)

    #   degree

    query = """
    SELECT (MIN (?xlabel) AS ?short) ?vivo
    WHERE
    {
          ?vivo a vivo:AcademicDegree .
          ?vivo rdfs:label ?xlabel .
    }
    GROUP BY ?vivo
    ORDER BY ?short
    """

    create_enum("degree_enum.txt", query, parms)

    #   school

    query = """
    SELECT (MIN (?xlabel) AS ?short) ?vivo
    WHERE
    {
          ?vivo a vivo:University .
          ?vivo rdfs:label ?xlabel .
    }
    GROUP BY ?vivo
    ORDER BY ?short
    """

    create_enum("school_enum.txt", query, parms)

    #   dates

    query = """
    SELECT ?short ?vivo
    WHERE
    {
          ?vivo a vivo:DateTimeValue .
#          ?vivo vivo:dateTimePrecision vivo:yearMonthPrecision .
          ?vivo vivo:dateTime ?short .
    }
    ORDER BY ?short
    """

    create_enum("date_enum.txt", query, parms, trim=7)

    print datetime.now(), "End"
Beispiel #16
0
def main():
    """
    Generate the enums for degrees
    """
    print datetime.now(), "Start"
    parms = get_parms()

    #   person via Orcid

    query = """
    SELECT (MIN (?xshort) AS ?short) ?vivo
    WHERE
    {
          ?vivo vivo:orcidId ?xshort .
    }
    GROUP BY ?vivo
    ORDER BY ?short
    """

    create_enum("orcid_enum.txt", query, parms)

    #   degree

    query = """
    SELECT (MIN (?xlabel) AS ?short) ?vivo
    WHERE
    {
          ?vivo a vivo:AcademicDegree .
          ?vivo rdfs:label ?xlabel .
    }
    GROUP BY ?vivo
    ORDER BY ?short
    """

    create_enum("degree_enum.txt", query, parms)

    #   dates

    query = """
    SELECT ?short ?vivo
    WHERE
    {
          ?vivo a vivo:DateTimeValue .
          ?vivo vivo:dateTimePrecision vivo:yearPrecision .
          ?vivo vivo:dateTime ?short .
    }
    ORDER BY ?short
    """

    create_enum("date_enum.txt", query, parms, trim=4)

    #   Concept via label

    query = """
    SELECT (MIN (?xlabel) AS ?short) ?vivo
    WHERE
    {
          ?vivo a skos:Concept .
          ?vivo rdfs:label ?xlabel .
    }
    GROUP BY ?vivo
    ORDER BY ?short
    """

    create_enum("concept_enum.txt", query, parms)

    print datetime.now(), "End"