当前位置: 首页>>代码示例>>Python>>正文


Python RDFS.label方法代码示例

本文整理汇总了Python中rdflib.RDFS.label方法的典型用法代码示例。如果您正苦于以下问题:Python RDFS.label方法的具体用法?Python RDFS.label怎么用?Python RDFS.label使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rdflib.RDFS的用法示例。


在下文中一共展示了RDFS.label方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_create_graph

# 需要导入模块: from rdflib import RDFS [as 别名]
# 或者: from rdflib.RDFS import label [as 别名]
def test_create_graph():
    """Create new graphFactory Object"""
    from sc import graphManager

    PROV = Namespace("http://www.w3.org/ns/prov#")
    tstregistry = graphManager.VocabularyRegistry()

    vocab1 = Vocabulary1()
    tstregistry.register(vocab1)
    vocab2 = Vocabulary2()
    tstregistry.register(vocab2)

    tstregistry.build_graph()
    print tstregistry.get_turtle()
    # Check assertions in global graph store
    assert (URIRef("http://orcid.org/000-0003-4901-6059"),
            RDF.type, PROV.Person) in tstregistry.global_graph
    assert (URIRef(uuidurn),
            RDFS.label,  Literal(
                "Docker: https://www.docker.com/")) in tstregistry.global_graph
    # Check Serialization
    jsongraph = json.loads(tstregistry.get_json_ld())
    assert '@context' in jsongraph 
开发者ID:crcresearch,项目名称:smartcontainers,代码行数:25,代码来源:test_graphregistry.py

示例2: add_vcard

# 需要导入模块: from rdflib import RDFS [as 别名]
# 或者: from rdflib.RDFS import label [as 别名]
def add_vcard(self, position, name):
        """
        :param position: number in author order
        :param name: name as string - last, first, middle
        :return: rdflib.Graph
        """
        g = Graph()

        # vcard individual
        vci_uri = D['vcard-individual-' + position + '-' + self.localid]
        g.add((vci_uri, RDF.type, VCARD.Individual))

        # vcard name
        vcn_uri = D['vcard-name-' + position + '-' + self.localid]
        g.add((vcn_uri, RDF.type, VCARD.Name))
        g.add((vcn_uri, RDFS.label, Literal(name)))
        # Parse name into first, last, middle
        name = HumanName(name)
        g.add((vcn_uri, VCARD.givenName, Literal(name.first)))
        g.add((vcn_uri, VCARD.familyName, Literal(name.last)))
        if name.middle != "":
            g.add((vcn_uri, VIVO.middleName, Literal(name.middle)))
        # Relate vcard individual to vcard name
        g.add((vci_uri, VCARD.hasName, vcn_uri))
        return vci_uri, g 
开发者ID:Clarivate-SAR,项目名称:wos2vivo,代码行数:27,代码来源:record.py

示例3: org_total_counts

# 需要导入模块: from rdflib import RDFS [as 别名]
# 或者: from rdflib.RDFS import label [as 别名]
def org_total_counts(orgs):
    #pcounts = incites_api.get_total_pubs(name)
    g = Graph()
    for org_name in orgs:
        org_uri = waan_uri(org_name)
        ln = local_name(org_uri)
        pcounts = load_incites_json_file(org_name, 'total')
        for item in pcounts:
            curi = D['pubcount-' + ln + '-' + str(item['year'])]
            g.add((curi, RDF.type, WOS.InCitesPubPerYear))
            g.add((curi, RDFS.label, Literal("{} - {}".format(item['year'], item['count']))))
            g.add((curi, WOS.number, Literal(item['count'])))
            g.add((curi, WOS.year, Literal(item['year'])))
            g.add((org_uri, VIVO.relates, curi))
    ng = "http://localhost/data/incites-pub-year-counts"
    backend.sync_updates(ng, g)
    return True 
开发者ID:RAP-research-output-impact,项目名称:rap-etl,代码行数:19,代码来源:map_metrics.py

示例4: org_total_cites

# 需要导入模块: from rdflib import RDFS [as 别名]
# 或者: from rdflib.RDFS import label [as 别名]
def org_total_cites(orgs):
    g = Graph()
    for org_name in orgs:
        org_uri = waan_uri(org_name)
        #print>>sys.stderr, "Processing", org_name, "total cites"
        ln = local_name(org_uri)
        tc = load_incites_json_file(org_name, 'cites')
        for item in tc:
            curi = D['citecount-' + ln + '-' + str(item['year'])]
            g.add((curi, RDF.type, WOS.InCitesCitesPerYear))
            g.add((curi, RDFS.label, Literal("{} - {}".format(item['year'], item['count']))))
            g.add((curi, WOS.number, Literal(item['count'])))
            g.add((curi, WOS.year, Literal(item['year'])))
            g.add((org_uri, VIVO.relates, curi))


    #print g.serialize(format="turtle")
    ng = "http://localhost/data/incites-total-cites-year-counts"
    backend.sync_updates(ng, g)
    return True 
开发者ID:RAP-research-output-impact,项目名称:rap-etl,代码行数:22,代码来源:map_metrics.py

示例5: org_top_categories

# 需要导入模块: from rdflib import RDFS [as 别名]
# 或者: from rdflib.RDFS import label [as 别名]
def org_top_categories(orgs):
    g = Graph()
    for org_name in orgs:
        #print>>sys.stderr, "Processing", org_name, "top categories"
        org_uri = waan_uri(org_name)
        ln = local_name(org_uri)
        top_cat = load_incites_json_file(org_name, 'categories')
        for item in top_cat:
            cat = item['category']
            category_uri = get_category_uri(cat)
            curi = D['topcategory-'] + ln + slugify(cat)
            g.add((curi, RDF.type, WOS.InCitesTopCategory))
            g.add((curi, RDFS.label, Literal("{} - {}".format(org_name, cat))))
            g.add((curi, WOS.number, Literal(item['count'])))
            g.add((curi, VIVO.relates, category_uri))
            g.add((curi, VIVO.relates, org_uri))
    #print g.serialize(format="turtle")
    ng = "http://localhost/data/incites-top-categories"
    backend.sync_updates(ng, g)
    return True 
开发者ID:RAP-research-output-impact,项目名称:rap-etl,代码行数:22,代码来源:map_metrics.py

示例6: build

# 需要导入模块: from rdflib import RDFS [as 别名]
# 或者: from rdflib.RDFS import label [as 别名]
def build(self):
        ds = self.graph
        self.context = {"ce":
                        "https://raw.githubusercontent.com/Vocamp/ComputationalActivity/master/pattern/ComputationalEnvironment.jsonld"}

        CE = Namespace("http://dase.cs.wright.edu/ontologies/ComputationalEnvironment#")
        CA = Namespace("http://dase.cs.wright.edu/ontologies/ComputationalActivity#")
        DOCKER = Namespace("http://w3id.org/daspos/docker#")
        info = cpuinfo.get_cpu_info()

# ISSUES: We want if the architecture URI's to be created only once on
# build or initial commit. Otherwise, we want to re-read the URI's
#  from the original graph. There are imm

        ds.bind("ce", CE)
        ceuri = URIRef(str(uuid.uuid4()))
        ds.add((ceuri, RDF.type, CE.ComputationalEnvironment))

        osUri = URIRef(str(uuid.uuid4()))
        ds.add((ceuri, CE.hasOperatingSystem, osUri))
        ds.add((osUri, RDFS.label, Literal("linux")))

        processorUri = URIRef(str(uuid.uuid4()))
        ds.add((ceuri, CE.hasHardware, processorUri))

        archUri = URIRef(str(uuid.uuid4()))
        ds.add((processorUri, CE.hasArchitecture,  archUri))
        ds.add((archUri, RDFS.label, Literal("amd64")))
        ds.add((processorUri, CE.hasNumberOfCores,
                Literal("4", datatype=XSD.nonNegativeInteger)))

        # :hasArchitecture
        # :hasNumberOfCores
        # :hasOperatingSystem
        # :hasSize Memory or HD
        # :isAvailable
        # :VirtualMACAddress 
开发者ID:crcresearch,项目名称:smartcontainers,代码行数:39,代码来源:envVocabulary.py

示例7: build

# 需要导入模块: from rdflib import RDFS [as 别名]
# 或者: from rdflib.RDFS import label [as 别名]
def build(self):
        self.context = {"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#"}
        UUIDNS = Namespace("urn:uuid:")
        self.graph.bind("uuidns", UUIDNS)
        self.graph.add((UUIDNS[tstuuid], RDFS.label, Literal(
            "Docker: https://www.docker.com/"))) 
开发者ID:crcresearch,项目名称:smartcontainers,代码行数:8,代码来源:test_graphregistry.py

示例8: get_ontology_file

# 需要导入模块: from rdflib import RDFS [as 别名]
# 或者: from rdflib.RDFS import label [as 别名]
def get_ontology_file(ontology):

	# if local file, file no temp file
	is_tempfile = False

	if os.path.isfile(ontology.file.name):

		filename = ontology.file.name

	elif ontology.sparql_endpoint:

		is_tempfile = True
		filename = download_rdf_from_sparql_endpoint(ontology.sparql_endpoint, ontology.sparql_query)

	elif ontology.uri.startswith('file://'):

		# filename is file URI without protocol prefix file://
		filename = ontology.uri[len('file://'):]

	else:
		# Download url to an tempfile
		is_tempfile = True
		filename, headers = urllib.urlretrieve(ontology.uri)

	return is_tempfile, filename


#
#  Tag indexed documents containing this entry or label(s) of every entry/entity in ontology or list
# 
开发者ID:opensemanticsearch,项目名称:open-semantic-search-apps,代码行数:32,代码来源:views.py

示例9: append_from_rdffile

# 需要导入模块: from rdflib import RDFS [as 别名]
# 或者: from rdflib.RDFS import label [as 别名]
def append_from_rdffile(sourcefilename, targetfilename):

	target = open(targetfilename, 'a', encoding="utf-8")

	g = Graph()
	
	#guess_format not in Ubuntus python_rdflib package yet
	#filetype = rdflib.util.guess_format(sourcefilename)

	#g.parse(sourcefilename, format = filetype)
	g.parse(sourcefilename)

	# get all RDFS labels
	for o in g.objects(None, RDFS.label):
		target.write(o + '\n')

	# SKOS labels
	skos = rdflib.Namespace('http://www.w3.org/2004/02/skos/core#')
		
	# append SKOS prefLabel
	for o in g.objects(None, skos['prefLabel']):
		target.write(o + '\n')

	# append SKOS altLabels
	for o in g.objects(None, skos['altLabel']):
		target.write(o + '\n')

	# append SKOS hiddenLabels
	for o in g.objects(None, skos['hiddenLabel']):
		target.write(o + '\n')

	target.close()


# An empty list file for a facet won't cause error opening/reading it, even if no entry exists 
开发者ID:opensemanticsearch,项目名称:open-semantic-search-apps,代码行数:37,代码来源:views.py

示例10: _identifier

# 需要导入模块: from rdflib import RDFS [as 别名]
# 或者: from rdflib.RDFS import label [as 别名]
def _identifier(self, tag):
        for item in self.root.findall('other'):
            if item.find('label').text == "Identifier.{}".format(tag):
                return item.find('value').text 
开发者ID:Clarivate-SAR,项目名称:wos2vivo,代码行数:6,代码来源:record.py

示例11: _source

# 需要导入模块: from rdflib import RDFS [as 别名]
# 或者: from rdflib.RDFS import label [as 别名]
def _source(self, label):
        for item in self.root.findall('source'):
            if item.find('label').text == label:
                return item.find('value').text 
开发者ID:Clarivate-SAR,项目名称:wos2vivo,代码行数:6,代码来源:record.py

示例12: add_date

# 需要导入模块: from rdflib import RDFS [as 别名]
# 或者: from rdflib.RDFS import label [as 别名]
def add_date(self):
        """
        Add vivo:DateTimeValue for publication.
        :return: rdflib.Graph
        """
        g = Graph()
        date_uri = D['date-' + self.localid]
        de = Resource(g, date_uri)
        de.set(RDF.type, VIVO.DateTimeValue)
        year, month, month_num = self.pub_date()
        # Add year and month if possible.
        if month_num is not None:
            de.set(RDFS.label, Literal("{}, {}".format(month, year)))
            de.set(
                VIVO.dateTime,
                Literal("{}-{}".format(year, month_num), datatype=XSD.dayMonth)
            )
            de.set(VIVO.dateTimePrecision, VIVO.yearMonthPrecision)
        else:
            de.set(RDFS.label, Literal(year))
            de.set(
                VIVO.dateTime,
                Literal("{}".format(year), datatype=XSD.year)
            )
            de.set(VIVO.dateTimePrecision, VIVO.yearPrecision)

        g.add((self.pub_uri, VIVO.dateTimeValue, date_uri))
        return g 
开发者ID:Clarivate-SAR,项目名称:wos2vivo,代码行数:30,代码来源:record.py

示例13: add_venue

# 需要导入模块: from rdflib import RDFS [as 别名]
# 或者: from rdflib.RDFS import label [as 别名]
def add_venue(self):
        """
        Add publication venue.
        :return: rdflib.Graph
        """
        g = Graph()

        isbn = self.isbn()
        issn = self.issn() or self.eissn()

        if isbn is not None:
            vtype = BIBO.Book
            uri = D['venue-' + isbn]
        elif issn is not None:
            vtype = BIBO.Journal
            uri = D['venue-' + issn]
        else:
            # Place holder
            logger.info("No source/venue ISSN or ISBN found for {}.".format(self.ut()))
            vtype = BIBO.Journal
            uri = D['venue-' + self.localid]

        venue = Resource(g, uri)
        venue.set(RDF.type, vtype)
        venue.set(RDFS.label, Literal(self.venue()))
        if vtype == BIBO.Journal:
            venue.set(BIBO.issn, Literal(issn))
        else:
            venue.set(BIBO.isbn, Literal(isbn))
        g.add((self.pub_uri, VIVO.hasPublicationVenue, uri))

        return g 
开发者ID:Clarivate-SAR,项目名称:wos2vivo,代码行数:34,代码来源:record.py

示例14: get_unified_orgs

# 需要导入模块: from rdflib import RDFS [as 别名]
# 或者: from rdflib.RDFS import label [as 别名]
def get_unified_orgs():
    q = rq_prefixes + """
    select ?wosU ?org
    where {
        ?wosU a wos:UnifiedOrganization ;
            rdfs:label ?org .
    }
    """
    out = []
    for row in vstore.query(q):
        out.append((row.wosU.toPython(), row.org.toPython()))
    return out 
开发者ID:RAP-research-output-impact,项目名称:rap-etl,代码行数:14,代码来源:map_metrics.py

示例15: toProperty

# 需要导入模块: from rdflib import RDFS [as 别名]
# 或者: from rdflib.RDFS import label [as 别名]
def toProperty(label):
    """
    CamelCase + lowercase inital a string


    FIRST_NM => firstNm

    firstNm => firstNm

    """
    label = re.sub("[^\w]", " ", label)
    label = re.sub("([a-z])([A-Z])", "\\1 \\2", label)
    label = label.split(" ")
    return "".join([label[0].lower()] + [x.capitalize() for x in label[1:]]) 
开发者ID:GiovanniBalestrieri,项目名称:Meiji,代码行数:16,代码来源:csv2rdf.py


注:本文中的rdflib.RDFS.label方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。