citations = run_sql("SELECT id_bibrec,value FROM bib%sx,bibrec_bib%sx WHERE tag='%s' AND id_bibxxx=id" % (citation_tag[0:2], citation_tag[0:2], citation_tag))
else:
fromDB(starset)
if opts_dict["modified"] == "last_updated":
opts_dict["modified"] = starset.getLastUpdated()
if opts_dict["verbose"] >= 9:
write_message("Updating records modified after: %s" % opts_dict["modified"])
mod_data = run_sql("SELECT id FROM bibrec WHERE modification_date >=%s", (opts_dict["modified"]),)
for id in mod_data:
citation = run_sql("SELECT id_bibrec,value FROM bib%sx,bibrec_bib%sx WHERE tag='%s' AND id_bibxxx=id and id_bibrec=%s" % (citation_tag[0:2], citation_tag[0:2], citation_tag, id))
for id,value in citation:
citations.append((id,value))
for key,value in citations:
data = run_sql("SELECT id_bibrec FROM bib%sx,bibrec_bib%sx WHERE tag='%s' AND id_bibxxx=id AND value='%s'" % (curr_repnr_tag[0:2], curr_repnr_tag[0:2], curr_repnr_tag, value))
data = run_sql("SELECT id_bibrec FROM bib%sx,bibrec_bib%sx WHERE tag='%s' AND id_bibxxx=id AND value='%s'" % (old_repnr_tag[0:2], old_repnr_tag[0:2], old_repnr_tag, value))
if not opts_dict["modified"]:
starset.setUnsorted(tempdoc)
sort(starset)
else:
merge_two_sets(tempdoc, starset)
#intoDB(starset)
showtime((time.time() - startCreate))
def single_tag_rank(starset, config):
"""Connect the given tag with the data from the kb file given"""
if not opts_dict["modified"] or config.get("single_tag_rank", "enable_modified") == "no":
records = run_sql("SELECT id_bibrec,value FROM bib%sx,bibrec_bib%sx WHERE tag='%s' AND id_bibxxx=id" % (tag[0:2], tag[0:2], tag))
valid = HitSet(Numeric.ones(cfg_max_recID + 1))
for key in tags:
newset = HitSet()
newset.addlist(run_sql("SELECT id_bibrec FROM bib%sx,bibrec_bib%sx WHERE id_bibxxx=id AND tag='%s'" % (tag[0:2], tag[0:2], key)))
valid.intersect(newset)
if tags:
records = filter(lambda x: valid.contains(x[0]), records)
else:
mod_data = run_sql("SELECT id FROM bibrec WHERE modification_date >= %s", (opts_dict["modified"],))
for id in mod_data:
found = "1"
for key in tags:
if not run_sql("SELECT id_bibrec FROM bib%sx,bibrec_bib%sx WHERE id_bibxxx=id AND tag='%s' AND id_bibrec='%s'" % (tag[0:2], tag[0:2], key, id[0])):
found = ""
break
if found:
record = run_sql("SELECT id_bibrec,value FROM bib%sx,bibrec_bib%sx WHERE tag='%s' AND id_bibxxx=id AND id_bibrec='%s'" % (tag[0:2], tag[0:2], tag, id[0]))
for id_bibrec, value in record:
records.append((id_bibrec, value))
documents = {}
for key,value in records:
if kb_data.has_key(value):
if not documents.has_key(key):
documents[key] = (value, float(kb_data[value]))
else:
if journals.has_key(documents[key]) and float(kb_data[value]) > float((documents[key])[1]):
documents[key] = (value, float(kb_data[value]))
else:
documents[key] = (value, - 1.0)
return documents
def accessimpact(methname, starsets, config):
"""Generating rankset based on number of downloads per document"""
data = run_sql("SELECT value,id_bibrec FROM bib%sx,bibrec_bib%sx WHERE tag='%s' AND id_bibxxx=id AND value=%s" % sysno_tag[0:2], sysno_tag[0:2], sysno_tag, sysno)
data = run_sql("SELECT id_bibrec FROM bib%sx,bibrec_bib%sx WHERE tag='%s' AND id_bibxxx=id AND value=%s" % (curr_repnr_tag[0:2], curr_repnr_tag[0:2], curr_repnr_tag, value))
if len(data) == 0:
data = run_sql("SELECT id_bibrec FROM bib%sx,bibrec_bib%sx WHERE tag='%s' AND id_bibxxx=id AND value=%s" % (old_repnr_tag[0:2], old_repnr_tag[0:2], old_repnr_tag, value))
sql_src.append("SELECT id_bibrec,value FROM bib%sx,bibrec_bib%sx WHERE tag='%s' AND id_bibxxx=id" % (p_author_tag[0:2], p_author_tag[0:2], p_author_tag))
sql_src.append("SELECT id_bibrec,value FROM bib%sx,bibrec_bib%sx WHERE tag='%s' AND id_bibxxx=id" % (s_author_tag[0:2], s_author_tag[0:2], s_author_tag))
write_message("Getting records from collections enabled for rank method.")
res = run_sql("SELECT collection.name FROM collection,collection_rnkMETHOD,rnkMETHOD WHERE collection.id=id_collection and id_rnkMETHOD=rnkMETHOD.id and rnkMETHOD.name='%s'" % key)
l_of_colls = ""
for coll in res:
l_of_colls += coll[0] + ","
recIDs = perform_request_search(c=l_of_colls)
opts_dict["validset"] = HitSet()
opts_dict["validset"].addlist(recIDs)
file = etcdir + "/bibrank/" + key + ".cfg"
if opts_dict["verbose"] >=9:
write_message("Getting configuration from file: %s" % file)