Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F61837088
bibrank_citation_searcher.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, May 9, 06:57
Size
3 KB
Mime Type
text/x-c
Expires
Sat, May 11, 06:57 (2 d)
Engine
blob
Format
Raw Data
Handle
17565021
Attached To
R3600 invenio-infoscience
bibrank_citation_searcher.py
View Options
##document impact hit parade
## This file is part of the CERN Document Server Software (CDSware).
## Copyright (C) 2002 CERN.
##
## The CDSware is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 2 of the
## License, or (at your option) any later version.
##
## The CDSware is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with CDSware; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
## read config variables: koli doosto ashena dandrn ke kheili doost daradn
#include "config.wml"
#include "configbis.wml"
#include "cdswmllib.wml"
## start Python:
<
protect
>
#!</protect><PYTHON>
<
protect
>
# -*- coding: utf-8 -*-</protect>
<
protect
>
## $Id$</protect>
<
protect
>
## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDSware WML SOURCES.</protect>
__version__
=
"<: print generate_pretty_version_string('$Id$'); :>"
from
marshal
import
loads
from
zlib
import
decompress
from
dbquery
import
run_sql
def
get_citing_recidrelevance
(
rank_method_code
,
citing_recids
):
"""return a tuple of list ([recid,citation_weight],...) for all the record in citing_recids list
"""
result
=
[]
query
=
"select relevance_data from rnkMETHODDATA, rnkMETHOD WHERE rnkMETHOD.id = rnkMETHODDATA.id_rnkMETHOD and rnkMETHOD.name = '
%s
'"
%
rank_method_code
compressed_citation_weight_dic
=
run_sql
(
query
)
if
compressed_citation_weight_dic
and
compressed_citation_weight_dic
[
0
]:
citation_dic
=
loads
(
decompress
(
compressed_citation_weight_dic
[
0
][
0
]))
for
id
in
citing_recids
:
tmp
=
[
id
,
citation_dic
[
id
]]
result
.
append
(
tmp
)
return
result
def
init_cited_by_dictionary
():
"""return citation list dictionary from rnkCITATIONDATA
"""
query
=
"select citation_data from rnkCITATIONDATA"
compressed_citation_dic
=
run_sql
(
query
)
citation_dic
=
None
if
compressed_citation_dic
and
compressed_citation_dic
[
0
]:
citation_dic
=
loads
(
decompress
(
compressed_citation_dic
[
0
][
0
]))
return
citation_dic
def
init_reference_list_dictionary
():
"""return reference list dictionary from rnkCITATIONDATA
"""
query
=
"select citation_data_reversed from rnkCITATIONDATA"
compressed_ref_dic
=
run_sql
(
query
)
ref_dic
=
None
if
compressed_ref_dic
and
compressed_ref_dic
[
0
]:
ref_dic
=
loads
(
decompress
(
compressed_ref_dic
[
0
][
0
]))
return
ref_dic
cbd
=
init_cited_by_dictionary
()
rld
=
init_reference_list_dictionary
()
def
get_cited_by_dictionary
():
"""return citation list dictionary from rnkCITATIONDATA
"""
global
cbd
return
cbd
def
get_reference_list_dictionary
():
"""return reference list dictionary from rnkCITATIONDATA
"""
global
rld
return
rld
def
get_cited_by_list
(
record_id
):
"""return citation list dictionary of record_id
"""
citation_list
=
None
try
:
citation_list
=
get_cited_by_dictionary
()[
record_id
]
except
TypeError
:
pass
return
citation_list
def
get_co_cited_with_list
(
record_id
):
"""return a tuple of list([id,co-cited weitht],[...,....]) for record_id"""
result
=
[]
result_intermediate
=
{}
citation_list
=
get_cited_by_dictionary
()[
record_id
]
for
cit_id
in
citation_list
:
reference_list
=
get_reference_list_dictionary
()[
cit_id
]
for
ref_id
in
reference_list
:
if
not
result_intermediate
.
has_key
(
ref_id
):
result_intermediate
[
ref_id
]
=
1
else
:
result_intermediate
[
ref_id
]
+=
1
for
key
,
value
in
result_intermediate
.
iteritems
():
if
not
(
key
==
record_id
):
result
.
append
([
key
,
value
])
return
result
Event Timeline
Log In to Comment