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


Python ConjunctiveGraph.close方法代码示例

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


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

示例1: testModel

# 需要导入模块: from rdflib.Graph import ConjunctiveGraph [as 别名]
# 或者: from rdflib.Graph.ConjunctiveGraph import close [as 别名]
    def testModel(self):
        g = ConjunctiveGraph()
        g.parse(StringInputSource(input), format="n3")
        i = 0
        for s, p, o in g:
            if isinstance(s, Graph):
                i += 1
        self.assertEquals(i, 3)
        self.assertEquals(len(list(g.contexts())), 13)

        g.close()
开发者ID:AuroraSkywalker,项目名称:watchdog,代码行数:13,代码来源:n3.py

示例2: load_store

# 需要导入模块: from rdflib.Graph import ConjunctiveGraph [as 别名]
# 或者: from rdflib.Graph.ConjunctiveGraph import close [as 别名]
 def load_store(files):
     """
    Takes a directory of RDf files and loads them into the store.
    """
     try:
         store = plugin.get("MySQL", Store)("rdflib_db")
         store.open(config["rdflib.config"])
         graph = ConjunctiveGraph(store)
         # iterate through files and load them into the graph
         for fpath in fl:
             graph.parse(fpath, format=get_format(fpath), publicID=context_uri(fpath))
             print fpath + " loaded."
         # save triples to store
         graph.commit()
         graph.close()
     except:
         print "=== error opening RDF store ==="
         exit
开发者ID:bdarcus,项目名称:mysite,代码行数:20,代码来源:rdf_store.py

示例3: Namespace

# 需要导入模块: from rdflib.Graph import ConjunctiveGraph [as 别名]
# 或者: from rdflib.Graph.ConjunctiveGraph import close [as 别名]
from __future__ import division
import sys, time
sys.path.append('pytc-0.7/build/lib.linux-x86_64-2.5')
sys.path.insert(0, 'rdflib/build/lib.linux-x86_64-2.5')

from rdflib.Graph import ConjunctiveGraph
from rdflib import Namespace, Literal

EX = Namespace("http://example.com/")
graph = ConjunctiveGraph('TokyoCabinet')
graph.open("tcgraph", create=True)
graph.add((EX['hello'], EX['world'], Literal("lit")))
print list(graph.triples((None, None, None)))
graph.close()

开发者ID:drewp,项目名称:tokyo,代码行数:16,代码来源:storetest.py

示例4: createMediaGraphs

# 需要导入模块: from rdflib.Graph import ConjunctiveGraph [as 别名]
# 或者: from rdflib.Graph.ConjunctiveGraph import close [as 别名]
def createMediaGraphs(rows):
	albums = {}

	artists = {
		'Madonna': mb_artist['79239441-bfd5-4981-a70c-55c3f15c1287'], 
		'John Coltrane': mb_artist['b625448e-bf4a-41c3-a421-72ad46cdb831'], 
		'Miles Davis' : mb_artist['561d854a-6a28-4aa7-8c99-323e6ce46c2a']}

	counter = 1
	for row in rows:
		graph = Graph(identifier = URIRef(graph_uri))
		# Create all the relevant nodes (with the correct IDs)

		work = getNewNode('work')
		composition = getNewNode('composition')
		track = getNewNode('track')
		record = getNewNode('record')
		performance = getNewNode('performance')
		signal = Namespace(graph_uri+"/"+row['uid'])

		# If we don't have an artist url, make a foaf Agent instead.
		if row['artist']:
			try:
				artist = artists[row['artist']]
			except KeyError:
				artist = getNewNode('artist')
				graph.add((artist, RDF.type, foaf['Agent']))
				graph.add((artist, foaf['name'], Literal(row['artist'].strip())))
				artists[row['artist']] = artist;	

		if row['composer']:
			try:
				composer = artists[row['composer']]
			except KeyError:
				composer = getNewNode('artist')
				graph.add((composer, RDF.type, foaf['Agent']))
				graph.add((composer, foaf['name'], Literal(row['composer'].strip())))
				artists[row['composer']] = composer;	
		else:
			composer = artist


		# Work
		graph.add((work, RDF.type, mo['MusicalWork']))
		
		# Composition
		graph.add((composition, RDF.type, mo['Composition']))
		if composer:
			graph.add((composition, mo['composer'], composer)) 
		graph.add((composition, mo['produced_work'], work))

		# Track
		graph.add((track, RDF.type, mo['Track']))
		if row['artist']:
			graph.add((track, foaf['maker'], artist))
		if row['tracknum']:
			graph.add((track, mo['track_number'], Literal(row['tracknum'])))

		if row['album']:
			# Album
			try:
				album = albums[row['album']]
			except KeyError:
				album = getNewNode('album')
				graph.add((album, RDF.type, mo['Record']))
				graph.add((album, dc['title'], Literal(row['album'].strip())))
				graph.add((album, mo['release_type'], mo['album']))
				albums[row['album']] = album
			graph.add((album, mo['track'], track))

		# Signal
		graph.add((signal, RDF.type, mo['Signal']))
		graph.add((signal, mo['published_as'], record))
		
		if row['track']:
			graph.add((signal, dc['title'], Literal(row['track'].strip())))
		if row['isrc']:
			graph.add((signal, mo['isrc'], Literal(row['isrc'].strip())))

		# Add to the various databases
		dbs = databases[catalogueID]
		for db in dbs:
			graph.add((db, audiodb["has-signal"], signal))

		# Record
		graph.add((record, RDF.type, mo['Record']))
		graph.add((record, mo['publication_of'], signal))
		graph.add((record, mo['track'], track))

		# Performance
		graph.add((performance, RDF.type, mo['Performance']))
		graph.add((performance, mo['performance_of'], work))
		if row['artist']:
			graph.add((performance, mo['performer'], artist))
		graph.add((performance, mo['recorded_as'], signal))
		
		graph.close()
		graph.serialize(format='xml',destination="output/"+catalogueID.lower()+"/media_"+str(counter)+".rdf")
		counter += 1
开发者ID:bregmanstudio,项目名称:AVA,代码行数:101,代码来源:cat2rdf.py


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