Exemplo n.º 1
0
def find_citations(rank_method_code, recID, hitset, verbose):
    """Rank by the amount of citations."""
    #calculate the cited-by values for all the members of the hitset
    #returns: ((recordid,weight),prefix,postfix,message)

    global voutput
    voutput = ""

    #If the recID is numeric, return only stuff that cites it. Otherwise return
    #stuff that cites hitset

    #try to convert to int
    recisint = True
    recidint = 0
    try:
        recidint = int(recID)
    except:
        recisint = False
    ret = []
    if recisint:
        myrecords = get_cited_by(recidint) #this is a simple list
        ret = get_cited_by_weight(myrecords)
    else:
        ret = get_cited_by_weight(hitset)
    ret.sort(lambda x,y:cmp(x[1],y[1]))      #ascending by the second member of the tuples

    if verbose > 0:
        voutput = voutput+"\nrecID "+str(recID)+" is int: "+str(recisint)+" hitset "+str(hitset)+"\n"+"find_citations retlist "+str(ret)

    #voutput = voutput + str(ret)

    if ret:
        return (ret,"(", ")", "")
    else:
        return ((),"", "", "")
def find_citations(rank_method_code, recID, hitset, verbose):
    """Rank by the amount of citations."""
    #calculate the cited-by values for all the members of the hitset
    #returns: ((recordid,weight),prefix,postfix,message)

    global voutput
    voutput = ""

    #If the recID is numeric, return only stuff that cites it. Otherwise return
    #stuff that cites hitset

    #try to convert to int
    recisint = True
    recidint = 0
    try:
        recidint = int(recID)
    except:
        recisint = False
    ret = []
    if recisint:
        myrecords = get_cited_by(recidint) #this is a simple list
        ret = get_cited_by_weight(myrecords)
    else:
        ret = get_cited_by_weight(hitset)
    ret.sort(lambda x,y:cmp(x[1],y[1]))      #ascending by the second member of the tuples

    if verbose > 0:
        voutput = voutput+"\nrecID "+str(recID)+" is int: "+str(recisint)+" hitset "+str(hitset)+"\n"+"find_citations retlist "+str(ret)

    #voutput = voutput + str(ret)

    if ret:
        return (ret,"(", ")", "")
    else:
        return ((),"", "", "")
Exemplo n.º 3
0
def rank_by_citations(hitset, verbose):
    """Rank by the amount of citations.

    Calculate the cited-by values for all the members of the hitset
    Rreturns: ((recordid,weight),prefix,postfix,message)
    """
    voutput = ""

    if len(hitset) > CFG_WEBSEARCH_CITESUMMARY_SCAN_THRESHOLD:
        cites_counts = get_citation_dict("citations_counts")
        ret = [(recid, weight) for recid, weight in cites_counts if recid in hitset]
        recids_without_cites = hitset - get_citation_dict("citations_keys")
        ret.extend([(recid, 0) for recid in recids_without_cites])
        ret = list(reversed(ret))
    else:
        ret = get_cited_by_weight(hitset)
        ret.sort(key=itemgetter(1))

    if verbose > 0:
        voutput += "\nhitset %s\nrank_by_citations ret %s" % (hitset, ret)

    if ret:
        return ret, "(", ")", voutput
    else:
        return [], "", "", voutput
Exemplo n.º 4
0
def rank_by_citations(hitset, verbose):
    """Rank by the amount of citations.

    Calculate the cited-by values for all the members of the hitset
    Returns: ((recordid,weight),prefix,postfix,message)
    """
    voutput = ""

    if len(hitset) > CFG_WEBSEARCH_CITESUMMARY_SCAN_THRESHOLD:
        cites_counts = get_citation_dict('citations_counts')
        citedhitset = hitset & get_citation_dict('citations_keys')
        ret = [
            recweight for recweight in cites_counts
            if recweight[0] in citedhitset
        ]
        hitset_without_cites = hitset - citedhitset
        ret.extend([(recid, 0) for recid in hitset_without_cites])
        ret = list(reversed(ret))
    else:
        ret = get_cited_by_weight(hitset)
        ret.sort(key=itemgetter(1))

    if verbose > 0:
        voutput += "\nhitset %s\nrank_by_citations ret %s" % (hitset, ret)

    if ret:
        return ret, "(", ")", voutput
    else:
        return [], "", "", voutput