Commit a83dfef0 authored by Michel Pelletier's avatar Michel Pelletier

Added normalized score

parent 07b52648
...@@ -158,18 +158,17 @@ class Catalog(Persistent, Acquisition.Implicit): ...@@ -158,18 +158,17 @@ class Catalog(Persistent, Acquisition.Implicit):
""" Returns instances of self._v_brains, or whatever is passed """ Returns instances of self._v_brains, or whatever is passed
into self.useBrains. into self.useBrains.
""" """
## import pdb
## pdb.set_trace()
if type(index) is ttype: if type(index) is ttype:
score, key = index normalized_score, score, key = index
r=self._v_result_class(self.data[key]).__of__(self.aq_parent) r=self._v_result_class(self.data[key]).__of__(self.aq_parent)
r.data_record_score_ = score
r.data_record_id_ = key r.data_record_id_ = key
r.data_record_score_ = score
r.data_record_normalized_score_ = normalized_score
else: else:
r=self._v_result_class(self.data[index]).__of__(self.aq_parent) r=self._v_result_class(self.data[index]).__of__(self.aq_parent)
r.data_record_id_ = index r.data_record_id_ = index
r.data_record_score__ = 1 r.data_record_score__ = 1
r.data_record_normalized_score_ = 1
return r return r
def __setstate__(self, state): def __setstate__(self, state):
...@@ -193,6 +192,8 @@ class Catalog(Persistent, Acquisition.Implicit): ...@@ -193,6 +192,8 @@ class Catalog(Persistent, Acquisition.Implicit):
scopy['data_record_id_']=len(self.schema.keys()) scopy['data_record_id_']=len(self.schema.keys())
scopy['data_record_score_']=len(self.schema.keys())+1 scopy['data_record_score_']=len(self.schema.keys())+1
scopy['data_record_normalized_score_']=len(self.schema.keys())+2
mybrains.__record_schema__ = scopy mybrains.__record_schema__ = scopy
self._v_brains = brains self._v_brains = brains
...@@ -285,7 +286,6 @@ class Catalog(Persistent, Acquisition.Implicit): ...@@ -285,7 +286,6 @@ class Catalog(Persistent, Acquisition.Implicit):
def catalogObject(self, object, uid, threshold=None): def catalogObject(self, object, uid, threshold=None):
""" """
Adds an object to the Catalog by iteratively applying it Adds an object to the Catalog by iteratively applying it
all indexes. all indexes.
...@@ -294,7 +294,6 @@ class Catalog(Persistent, Acquisition.Implicit): ...@@ -294,7 +294,6 @@ class Catalog(Persistent, Acquisition.Implicit):
'uid' is the unique Catalog identifier for this object 'uid' is the unique Catalog identifier for this object
""" """
data = self.data data = self.data
if self.uids.has_key(uid): if self.uids.has_key(uid):
...@@ -322,7 +321,6 @@ class Catalog(Persistent, Acquisition.Implicit): ...@@ -322,7 +321,6 @@ class Catalog(Persistent, Acquisition.Implicit):
def uncatalogObject(self, uid): def uncatalogObject(self, uid):
""" """
Uncatalog and object from the Catalog. and 'uid' is a unique Uncatalog and object from the Catalog. and 'uid' is a unique
Catalog identifier Catalog identifier
...@@ -330,7 +328,6 @@ class Catalog(Persistent, Acquisition.Implicit): ...@@ -330,7 +328,6 @@ class Catalog(Persistent, Acquisition.Implicit):
catalogued, otherwise it will not get removed from the catalog catalogued, otherwise it will not get removed from the catalog
""" """
if uid not in self.uids.keys(): if uid not in self.uids.keys():
return return
...@@ -352,7 +349,6 @@ class Catalog(Persistent, Acquisition.Implicit): ...@@ -352,7 +349,6 @@ class Catalog(Persistent, Acquisition.Implicit):
del self.paths[rid] del self.paths[rid]
def clear(self): def clear(self):
""" clear catalog """ """ clear catalog """
self.data = BTree.BTree() self.data = BTree.BTree()
...@@ -401,6 +397,7 @@ class Catalog(Persistent, Acquisition.Implicit): ...@@ -401,6 +397,7 @@ class Catalog(Persistent, Acquisition.Implicit):
def _indexedSearch(self, args, sort_index, append, used, def _indexedSearch(self, args, sort_index, append, used,
IIBType=type(IIBucket()), intSType=type(intSet())): IIBType=type(IIBucket()), intSType=type(intSet())):
rs=None rs=None
data=self.data data=self.data
...@@ -438,7 +435,11 @@ class Catalog(Persistent, Acquisition.Implicit): ...@@ -438,7 +435,11 @@ class Catalog(Persistent, Acquisition.Implicit):
rset.append((score, key)) rset.append((score, key))
rset.sort() rset.sort()
rset.reverse() rset.reverse()
append(LazyMap(self.__getitem__, rset)) max = float(rset[0][0])
rs = []
for score, key in rset:
rs.append(( int((score/max)*100), score, key))
append(LazyMap(self.__getitem__, rs))
elif sort_index is None and type(rs) is intSType: elif sort_index is None and type(rs) is intSType:
append(LazyMap(self.__getitem__, rs)) append(LazyMap(self.__getitem__, rs))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment