Esempio n. 1
0
 def __init__(self, sesameURL, repository):
     c=connection(sesameURL)
     c.use_repository(repository)
     for ele in namespaces.namespace_dict.keys():
         #print ele, str(namespaces.namespace_dict[ele])
         c.addnamespace(ele, str(namespaces.namespace_dict[ele]))
     #tsc is triple store connection. we need to first write this, then translate to a driver architecture
     self.tsc=c
from rdflib.Graph import ConjunctiveGraph
from rdflib import Namespace, BNode, Literal, RDF, URIRef
from pysesame import connection
import urllib
from simplejson import loads
from csv import reader

JB = Namespace("http://semprog.com/schemas/jobboard#")
DC = Namespace("http://purl.org/dc/elements/1.1/")
FOAF = Namespace("http://xmlns.com/foaf/0.1/")
COMPANY = Namespace("http://purl.org/rss/1.0/modules/company/")

# Connecion to Sesame
con=connection('http://freerisk.org:8280/openrdf-sesame/')
con.use_repository('joblistings')
con.addnamespace('company',str(COMPANY))

cg=ConjunctiveGraph()
cg.bind('dc',DC)
cg.bind('jobboard',JB)

# Find companies with ticker symbols
res=con.query('select ?id ?ticker where {?id company:symbol ?ticker .}')

# Loop over the results
for row in res:
    company=URIRef(row['id']['value'])
    ticker=row['ticker']['value']
    
    url='http://ichart.finance.yahoo.com/table.csv?s=%s&a=00&b=28&c=2008&d=00&e=28&f=2009&g=m&ignore=.csv' % ticker
    
Esempio n. 3
0
#c.use_repository('testads4')
#context=None
testcodeuristart='<http://ads.harvard.edu/sem/context#'
#DATA="../mast_hut-rdf"

if len(sys.argv)==2:
    execfile("./default.conf")
    execfile("./mast/default.conf")
elif len(sys.argv)==3:
    execfile(sys.argv[2])
else:
    print "Usage: python loadfiles-hut-pub.py obsvpubmatchpattern [conffile]"
    sys.exit(-1)
#c.addnamespace('fb','http://rdf.freebase.com/ns/')
#c.addnamespace('dc','http://purl.org/dc/elements/1.1/')
c=connection(SESAME)
c.use_repository(REPOSITORY)

identifier=str(uuid.uuid4())+"-"+__file__+"-"+__version__

context=quote_plus(testcodeuristart+identifier+">")
filename=DATA+"/"+sys.argv[1]+".rdf"
if not os.path.exists(filename):
    print "Path not found: "+filename
    sys.exit(-1)


if os.path.isfile(filename):
    print filename
    c.postfile(filename, context)
else:
Esempio n. 4
0
#c.use_repository('testads4')
#context=None
testcodeuristart = '<http://ads.harvard.edu/sem/context#'
#DATA="../chandra-rdf"

if len(sys.argv) == 3:
    execfile("./default.conf")
    execfile("./chandra/default.conf")
elif len(sys.argv) == 4:
    execfile(sys.argv[3])
else:
    print "Usage: python loadfiles-pub.py bibfile pubrdfdir [conffile]"
    sys.exit(-1)
#c.addnamespace('fb','http://rdf.freebase.com/ns/')
#c.addnamespace('dc','http://purl.org/dc/elements/1.1/')
c = connection(SESAME)
c.use_repository(REPOSITORY)

identifier = str(uuid.uuid4()) + "-" + __file__ + "-" + __version__

context = quote_plus(testcodeuristart + identifier + ">")
bibcodes = [quote_plus(ele.strip()) for ele in open(sys.argv[1]).readlines()]
print bibcodes
if not os.path.exists(DATA + sys.argv[2]):
    print "Path not found"
    sys.exit(-1)
for ele in bibcodes:
    filename = DATA + sys.argv[2] + "/" + ele + ".xml.rdf"
    if os.path.isfile(filename):
        print filename
        c.postfile(filename, context)
from rdflib.Graph import ConjunctiveGraph
from rdflib import Namespace, BNode, Literal, RDF, URIRef
import csv
import pysesame

JB = Namespace("http://semprog.com/schemas/jobboard#")
GEO = Namespace('http://www.w3.org/2003/01/geo/wgs84_pos#')

lg=ConjunctiveGraph()
lg.bind('geo',GEO)

for city,lat,long in csv.reader(file('city_locations.csv','U')):
    lg.add((JB[city],GEO['lat'],Literal(float(lat))))
    lg.add((JB[city],GEO['long'],Literal(float(long))))
    
data=lg.serialize(format='xml')
print data
c=pysesame.connection('http://semprog.com:8280/openrdf-sesame/')
c.use_repository('joblistings')
print c.postdata(data)


    
from rdflib.Graph import ConjunctiveGraph
from rdflib import Namespace, BNode, Literal, RDF, URIRef
from pysesame import connection
import urllib
from simplejson import loads
from csv import reader

JB = Namespace("http://semprog.com/schemas/jobboard#")
DC = Namespace("http://purl.org/dc/elements/1.1/")
FOAF = Namespace("http://xmlns.com/foaf/0.1/")
COMPANY = Namespace("http://purl.org/rss/1.0/modules/company/")

# Connecion to Sesame
con = connection('http://freerisk.org:8280/openrdf-sesame/')
con.use_repository('joblistings')
con.addnamespace('company', str(COMPANY))

cg = ConjunctiveGraph()
cg.bind('dc', DC)
cg.bind('jobboard', JB)

# Find companies with ticker symbols
res = con.query('select ?id ?ticker where {?id company:symbol ?ticker .}')

# Loop over the results
for row in res:
    company = URIRef(row['id']['value'])
    ticker = row['ticker']['value']

    url = 'http://ichart.finance.yahoo.com/table.csv?s=%s&a=00&b=28&c=2008&d=00&e=28&f=2009&g=m&ignore=.csv' % ticker