citation-map 0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ from .citation_map import citation_map_from_google_scholar_id
2
+
3
+ __all__ = ['citation_map_from_google_scholar_id']
4
+
@@ -0,0 +1,109 @@
1
+ from scholarly import scholarly, ProxyGenerator
2
+ from geopy.geocoders import Nominatim
3
+ import folium
4
+ from tqdm import tqdm
5
+ import random
6
+
7
+
8
+ def __fetch_google_scholar_profile(scholar_id):
9
+ '''
10
+ Step 1: Fetch Google Scholar Profile using Scholar ID
11
+ '''
12
+ author = scholarly.search_author_id(scholar_id)
13
+ author = scholarly.fill(author, sections=["publications"])
14
+ return author
15
+
16
+ def __parse_profile(author):
17
+ '''
18
+ Step 2: Parse the Profile and find citing author affiliations.
19
+ Without parallel processing.
20
+ '''
21
+ citation_locations = []
22
+ for pub in tqdm(author['publications']):
23
+ pub = scholarly.fill(pub)
24
+ if 'citedby_url' in pub:
25
+ citing_paper_obj = scholarly.citedby(pub)
26
+ citing_paper_list = [item for item in citing_paper_obj]
27
+ for citing_paper in tqdm(citing_paper_list):
28
+ if 'author_id' in citing_paper:
29
+ author_id_list = citing_paper['author_id']
30
+ author_id_list = [item for item in author_id_list if item] # Filter out empty author ids.
31
+
32
+ for author_id in author_id_list:
33
+ citing_author = scholarly.search_author_id(author_id)
34
+ citing_author = scholarly.fill(citing_author)
35
+ if 'affiliation' in citing_author:
36
+ citation_locations.append(citing_author['affiliation'])
37
+ return citation_locations
38
+
39
+ def __geocode_locations(locations):
40
+ '''
41
+ Step 3: Convert locations in plain text to Geocode.
42
+ '''
43
+ geolocator = Nominatim(user_agent="citation_mapper")
44
+ coordinates = []
45
+ for location in locations:
46
+ try:
47
+ geo_location = geolocator.geocode(location)
48
+ if geo_location:
49
+ coordinates.append((geo_location.latitude, geo_location.longitude, location))
50
+ except Exception as e:
51
+ print(f"Error geocoding location {location}: {e}")
52
+ return coordinates
53
+
54
+ def __create_map(coordinates):
55
+ '''
56
+ Step 4: Create the Map.
57
+ '''
58
+ # citation_map = folium.Map(location=[20, 0], zoom_start=2)
59
+ # for lat, lon, location in coordinates:
60
+ # folium.Marker([lat, lon], popup=location).add_to(citation_map)
61
+ # return citation_map
62
+ citation_map = folium.Map(location=[20, 0], zoom_start=2)
63
+ colors = ['red', 'blue', 'green', 'purple', 'orange', 'darkred',
64
+ 'lightred', 'beige', 'darkblue', 'darkgreen', 'cadetblue',
65
+ 'darkpurple', 'white', 'pink', 'lightblue', 'lightgreen',
66
+ 'gray', 'black', 'lightgray']
67
+ for lat, lon, location in coordinates:
68
+ color = random.choice(colors)
69
+ folium.Marker([lat, lon], popup=location, icon=folium.Icon(color=color)).add_to(citation_map)
70
+ return citation_map
71
+
72
+ def citation_map_from_google_scholar_id(scholar_id: str,
73
+ use_proxy: bool = False):
74
+ '''
75
+ Google Scholar Citation World Map.
76
+
77
+ ----
78
+ scholar_id: str
79
+ Your Google Scholar ID.
80
+ use_proxy: bool
81
+ If true, we will use a scholarly proxy.
82
+ It is necessary for some environments to avoid blocks, but it usually makes things slower.
83
+
84
+ '''
85
+
86
+ if use_proxy:
87
+ pg = ProxyGenerator()
88
+ pg.FreeProxies()
89
+ scholarly.use_proxy(pg)
90
+ print('Proxy used.')
91
+
92
+ author = __fetch_google_scholar_profile(scholar_id)
93
+ print('Author profile found, with %d publications.' % len(author['publications']))
94
+
95
+ locations = __parse_profile(author)
96
+ print('A total of %d citation locations recorded.' % len(locations))
97
+
98
+ coordinates = __geocode_locations(locations)
99
+ print('Converted the locations to Geocodes.')
100
+
101
+ citation_map = __create_map(coordinates)
102
+ citation_map.save('citation_map.html')
103
+ print("Map created and saved as citation_map.html")
104
+
105
+
106
+ if __name__ == "__main__":
107
+ # Replace this with your Google Scholar ID.
108
+ scholar_id = "3rDjnykAAAAJ"
109
+ citation_map_from_google_scholar_id(scholar_id, use_proxy=False)
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Chen Liu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,63 @@
1
+ Metadata-Version: 2.1
2
+ Name: citation-map
3
+ Version: 0.1
4
+ Summary: Google Scholar Citation World Map.
5
+ Home-page: https://github.com/ChenLiu-1996/CitationMap
6
+ Author: Chen Liu
7
+ Author-email: chen.liu.cl2482@yale.edu
8
+ License: MIT
9
+ Keywords: citation map,citation world map,google scholar
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE.md
16
+ Requires-Dist: scholarly
17
+ Requires-Dist: geopy
18
+ Requires-Dist: folium
19
+ Requires-Dist: tqdm
20
+
21
+ # Google Scholar Citation World Map
22
+
23
+ Chen Liu, CS PhD Candidate at Yale University
24
+
25
+ ## Purpose
26
+ This is a simple Python tool to generate a HTML citation world map from your Google Scholar ID.
27
+
28
+ ## Warning
29
+ 1. This script is a bit slow. On my personal computer, it takes half a minute to process each citation. If you have thousands of citations, it may or may not be a good idea to use this script.
30
+ 2. I tried to use multiprocessing, but unfortunately the excessive visits get me blocked by Google Scholar.
31
+
32
+ ## Demo
33
+ <img src = "assets/citation_world_map.png" width=800>
34
+
35
+ ## Usage
36
+ 1. Install the package.
37
+ ```
38
+ pip install citation-map
39
+ ```
40
+
41
+ 2. Find your Google Scholar ID.
42
+
43
+ On your Google Scholar profile, the string `GOOGLE_SCHOLAR_ID` in the URL `https://scholar.google.com/citations?user=GOOGLE_SCHOLAR_ID` be will be your Google Scholar ID. Ignore the configuration strings such as `&hl=en` or `&view_op=list_works&sortby=pubdate`.
44
+
45
+ 3. In an empty Python script, run the following.
46
+ ```
47
+ from citation_map import citation_map_from_google_scholar_id
48
+
49
+ # This is my Google Scholar ID. Replace this with your ID.
50
+ scholar_id = "3rDjnykAAAAJ"
51
+ citation_map_from_google_scholar_id(scholar_id)
52
+ ```
53
+
54
+ ## Dependencies
55
+ ```
56
+ scholarly
57
+ geopy
58
+ folium
59
+ tqdm
60
+ ```
61
+
62
+ ## Acknowledgements
63
+ This script was written under the help of ChatGPT-4o, but of course after intense debugging.
@@ -0,0 +1,7 @@
1
+ citation_map/__init__.py,sha256=UV_aXSLrG1_Z9zkpi-33lRUD_vAYK41Xyw0-eLhGo6A,114
2
+ citation_map/citation_map.py,sha256=HPcUIbMsk4HMdImI_sR9FRcdboqHcFmcaAXZH1dHJMQ,4018
3
+ citation_map-0.1.dist-info/LICENSE.md,sha256=YGeonFrqqLD4xJdyAvTjAiKRBNdk75E9UCz84L9_3Qk,1064
4
+ citation_map-0.1.dist-info/METADATA,sha256=_z2i2-evgl-5nNaEq3j-HwmXUIQEOPGuo2nAIn9MKJE,1976
5
+ citation_map-0.1.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
6
+ citation_map-0.1.dist-info/top_level.txt,sha256=FE-lf7CtT596XdV0sWRFY8xxodQ0Bwi2UDQFRMnuFRI,13
7
+ citation_map-0.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: bdist_wheel (0.41.2)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ citation_map