[pypy-svn] r35164 - pypy/dist/pypy/lib/pyontology
ale at codespeak.net
ale at codespeak.net
Thu Nov 30 15:28:06 CET 2006
Author: ale
Date: Thu Nov 30 15:28:05 2006
New Revision: 35164
Modified:
pypy/dist/pypy/lib/pyontology/pyontology.py
Log:
Intermediate checin
Modified: pypy/dist/pypy/lib/pyontology/pyontology.py
==============================================================================
--- pypy/dist/pypy/lib/pyontology/pyontology.py (original)
+++ pypy/dist/pypy/lib/pyontology/pyontology.py Thu Nov 30 15:28:05 2006
@@ -233,11 +233,11 @@
if hasattr(other,'uri'):
if self.uri == other.uri:
return True
- elif not hasattr(other,'uri'):
- if self.uri == other:
- return True
elif other in self.sameas:
return True
+ else:
+ if self.uri == other:
+ return True
if not other or other in self.differentfrom:
return False
else:
@@ -296,6 +296,7 @@
self._dict[key].append(val)
def setValues(self, values):
+ self._dict= {}
for key, val in values:
self.addValue(key, val)
@@ -454,8 +455,9 @@
getUriref('rdf', 'Literal') : Literal,
# getUriref('rdf', 'type') : Property,
}
-
XMLTypes = ['string', 'float', 'integer', 'date']
+#XMLTypes = {'string': str, 'float': float, 'integer': int,
+# 'date': lambda x: datetime.date(*[int(v) for v in x.split('-')])}
for typ in XMLTypes:
uri = getUriref('xmlschema', typ)
@@ -476,7 +478,7 @@
self.seen = {}
self.var2ns ={}
self.nr_of_triples = 0
- self.time = time.time()
+# self.time = time.time()
# for pr in builtin_voc:
# name = self.mangle_name(pr)
# Instantiate ClassDomains to record instances of the types
@@ -526,7 +528,6 @@
def _sparql(self, query):
qe = SP.Query.parseString(query)
-
prefixes = qe.Prefix[0]
resvars = []
@@ -629,9 +630,6 @@
p_vals = self.variables[prop].getValuesPrKey(indi)
var = self.make_var(Thing, trip[2])
self.variables[var].setValues((p_vals))
- if [dom for dom in self.variables.values() if isinstance(dom, Individual)]:
- import pdb
- pdb.set_trace()
elif case == 4:
# for all p's return p[0] if p[1]==o
@@ -652,8 +650,6 @@
query_constr.append(PropertyConstrain2(prop_name, sub_name, obj))
elif case == 5:
# return the values of p
- #import pdb
- ##pdb.set_trace()
prop = self.make_var(Property, URIRef(trip[1]))
query_dom[prop] = self.variables[prop]
p_vals = list(self.variables[prop].getValues())
@@ -721,9 +717,9 @@
return
self.nr_of_triples += 1
log("Doing triple nr %i: %r" % (self.nr_of_triples,(s, p, o)))
- tim = time.time()
- log.considerTriple("Triples per second %f" %(1./(tim-self.time)))
- self.time = tim
+# tim = time.time()
+# log.considerTriple("Triples per second %f" %(1./(tim-self.time)))
+# self.time = tim
self.seen[(s, p, o)] = True
if p.find('#') != -1:
ns, func = p.split('#')
@@ -747,7 +743,10 @@
else:
val = Individual(obj, o)
elif type(o) == rdflib_literal:
- self.variables.setdefault('owl_Literal', ClassDomain('owl_Literal',u''))
+ print "Literal type", repr(o.datatype)
+ if o.datatype in builtin_voc:
+ print "XML datatype"
+ o = XMLTypes[o.datatype.split('#')[-1]](o)
self.variables['owl_Literal'].addValue(o)
val = o
else:
More information about the Pypy-commit
mailing list