g.add((
    debian, DOAP.description,
    Literal(
        'Debian is a free operating system ' +
        '(OS) for your computer. An operating system is the set of basic programs '
        +
        'and utilities that make your computer run. Debian provides more than a '
        +
        'pure OS: it comes with over 37500 packages, precompiled software bundled '
        + 'up in a nice format for easy installation on your machine.',
        lang="en")))
g.add((debian, DOAP.homepage, URIRef('http://www.debian.org/')))

## Generate all release triples

releases = [x[0] for x in udd.query("SELECT DISTINCT release FROM sources")]

for release in releases:
    if "-" in release:
        parent = RELEASE[release.split("-")[0]]
        g.add((parent, ADMSSW.includedAsset, RELEASE[release]))
        g.add((RELEASE[release], DCTERMS.isPartOf, parent))
        g.add((RELEASE[release], ADMSSW.project, debian))
    else:
        g.add((debian, DOAP.release, RELEASE[release]))
        g.add((RELEASE[release], ADMSSW.project, debian))
    g.add((RELEASE[release], RDF.type, ADMSSW.SoftwareRelease))
    g.add((RELEASE[release], DOAP.name, Literal("Debian " + release)))

## Generate all project triples
示例#2
0
from debian import deb822
import re

from rdflib import Graph, Literal, Namespace
from semantic_debian.namespaces import DCTERMS, PROJECT

from semantic_debian.udd import udd

CPANURI = Namespace("http://ontologi.es/cpan-data/dist/")

g = Graph()

print "I: Mapping binary packages to source packages"

res = udd.query("SELECT package, source FROM packages")

sources = {}
for r in res:
    sources[r[0]] = r[1]

def lookup_source(pkg):
    if pkg in sources.keys():
        return sources[pkg]
    else:
        return None

print "I: Mapping Perl modules to CPAN distributions"

with open("/tmp/02packages.details.txt") as f:
    pkg_det = f.readlines()
# TODO: There should be translations for the description here.

debian = URIRef('http://rdf.debian.net/debian')
g.add( (debian, RDF.type, ADMSSW.SoftwareProject) )
g.add( (debian, DOAP.name, Literal('The Debian Project')) )
g.add( (debian, DOAP.description, Literal('Debian is a free operating system ' +
   '(OS) for your computer. An operating system is the set of basic programs ' +
   'and utilities that make your computer run. Debian provides more than a ' +
   'pure OS: it comes with over 37500 packages, precompiled software bundled ' +
   'up in a nice format for easy installation on your machine.', lang="en")) )
g.add( (debian, DOAP.homepage, URIRef('http://www.debian.org/')) )

## Generate all release triples

releases = [x[0] for x in udd.query("SELECT DISTINCT release FROM sources")]

for release in releases:
    if "-" in release:
        parent = RELEASE[release.split("-")[0]]
        g.add( (parent, ADMSSW.includedAsset, RELEASE[release]) )
        g.add( (RELEASE[release], DCTERMS.isPartOf, parent) )
        g.add( (RELEASE[release], ADMSSW.project, debian) )
    else:
        g.add( (debian, DOAP.release, RELEASE[release]) )
        g.add( (RELEASE[release], ADMSSW.project, debian) )
    g.add( (RELEASE[release], RDF.type, ADMSSW.SoftwareRelease) )
    g.add( (RELEASE[release], DOAP.name, Literal("Debian " + release)) )

## Generate all project triples