/usr/share/doc/python-rdflib-doc/html/merging.html is in python-rdflib-doc 4.1.2-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Merging graphs — rdflib 4.1.2 documentation</title>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>
<link rel="stylesheet" href="_static/rtd.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '4.1.2',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/searchtools.js"></script>
<link rel="top" title="rdflib 4.1.2 documentation" href="index.html" />
<link rel="next" title="Upgrading from RDFLib version 3.X to 4.X" href="upgrade3to4.html" />
<link rel="prev" title="Persistence" href="persistence.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="upgrade3to4.html" title="Upgrading from RDFLib version 3.X to 4.X"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="persistence.html" title="Persistence"
accesskey="P">previous</a> |</li>
<li><a href="index.html">rdflib 4.1.2 documentation</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="merging-graphs">
<span id="id1"></span><h1>Merging graphs<a class="headerlink" href="#merging-graphs" title="Permalink to this headline">ΒΆ</a></h1>
<blockquote>
<div><p>A merge of a set of RDF graphs is defined as follows. If the graphs in
the set have no blank nodes in common, then the union of the graphs is
a merge; if they do share blank nodes, then it is the union of a set
of graphs that is obtained by replacing the graphs in the set by
equivalent graphs that share no blank nodes. This is often described
by saying that the blank nodes have been ‘standardized apart’. It is
easy to see that any two merges are equivalent, so we will refer to
the merge, following the convention on equivalent graphs. Using the
convention on equivalent graphs and identity, any graph in the
original set is considered to be a subgraph of the merge.</p>
<p>One does not, in general, obtain the merge of a set of graphs by
concatenating their corresponding N-Triples documents and constructing
the graph described by the merged document. If some of the documents
use the same node identifiers, the merged document will describe a
graph in which some of the blank nodes have been ‘accidentally’
identified. To merge N-Triples documents it is necessary to check if
the same nodeID is used in two or more documents, and to replace it
with a distinct nodeID in each of them, before merging the
documents. Similar cautions apply to merging graphs described by
RDF/XML documents which contain nodeIDs</p>
</div></blockquote>
<p><em>(copied directly from http://www.w3.org/TR/rdf-mt/#graphdefs)</em></p>
<p>In RDFLib, blank nodes are given unique IDs when parsing, so graph merging can be done by simply reading several files into the same graph:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">rdflib</span> <span class="kn">import</span> <span class="n">Graph</span>
<span class="n">graph</span> <span class="o">=</span> <span class="n">Graph</span><span class="p">()</span>
<span class="n">graph</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="n">input1</span><span class="p">)</span>
<span class="n">graph</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="n">input2</span><span class="p">)</span>
</pre></div>
</div>
<p><tt class="docutils literal"><span class="pre">graph</span></tt> now contains the merged graph of <tt class="docutils literal"><span class="pre">input1</span></tt> and <tt class="docutils literal"><span class="pre">input2</span></tt>.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p>However, the set-theoretic graph operations in RDFLib are assumed to be performed in sub-graphs of some larger data-base (for instance, in the context of a <a class="reference internal" href="apidocs/rdflib.html#rdflib.graph.ConjunctiveGraph" title="rdflib.graph.ConjunctiveGraph"><tt class="xref py py-class docutils literal"><span class="pre">ConjunctiveGraph</span></tt></a>) and assume shared blank node IDs, and therefore do NOT do <em>correct</em> merging, i.e.:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">rdflib</span> <span class="kn">import</span> <span class="n">Graph</span>
<span class="n">g1</span> <span class="o">=</span> <span class="n">Graph</span><span class="p">()</span>
<span class="n">g1</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="n">input1</span><span class="p">)</span>
<span class="n">g2</span> <span class="o">=</span> <span class="n">Graph</span><span class="p">()</span>
<span class="n">g2</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span><span class="n">input2</span><span class="p">)</span>
<span class="n">graph</span> <span class="o">=</span> <span class="n">g1</span> <span class="o">+</span> <span class="n">g2</span>
</pre></div>
</div>
<p class="last">May cause unwanted collisions of blank-nodes in
<tt class="docutils literal"><span class="pre">graph</span></tt>.</p>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="index.html">
<img class="logo" src="_static/logo.svg" alt="Logo"/>
</a></p>
<h4>Previous topic</h4>
<p class="topless"><a href="persistence.html"
title="previous chapter">Persistence</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="upgrade3to4.html"
title="next chapter">Upgrading from RDFLib version 3.X to 4.X</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/merging.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="upgrade3to4.html" title="Upgrading from RDFLib version 3.X to 4.X"
>next</a> |</li>
<li class="right" >
<a href="persistence.html" title="Persistence"
>previous</a> |</li>
<li><a href="index.html">rdflib 4.1.2 documentation</a> »</li>
</ul>
</div>
<div class="footer">
© Copyright 2009 - 2013, RDFLib Team.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.2.2.
<br />Theme based on <a href="http://readthedocs.org/">Read The Docs</a>
</div>
</body>
</html>
|