|
14 | 14 | from dotenv import find_dotenv, load_dotenv |
15 | 15 | from .author_parser import AuthorParser |
16 | 16 | from .publication_parser import PublicationParser, _SearchScholarIterator |
17 | | -from .data_types import Author, AuthorSource, Journal, Publication, PublicationSource |
| 17 | +from .data_types import Author, AuthorSource, CitesPerYear, Journal, Publication, PublicationSource |
18 | 18 |
|
19 | 19 | _AUTHSEARCH = '/citations?hl=en&view_op=search_authors&mauthors={0}' |
20 | 20 | _KEYWORDSEARCH = '/citations?hl=en&view_op=search_authors&mauthors=label:{0}' |
@@ -253,6 +253,25 @@ def bibtex(self, object: Publication)->str: |
253 | 253 | self.logger.warning("Object not supported for bibtex exportation") |
254 | 254 | return |
255 | 255 |
|
| 256 | + @staticmethod |
| 257 | + def _bin_citations_by_year(cites_per_year: CitesPerYear, year_end): |
| 258 | + years = [] |
| 259 | + y_hi, y_lo = year_end, year_end |
| 260 | + running_count = 0 |
| 261 | + for y in sorted(cites_per_year, reverse=True): |
| 262 | + if running_count + cites_per_year[y] <= 1000: |
| 263 | + running_count += cites_per_year[y] |
| 264 | + y_lo = y |
| 265 | + else: |
| 266 | + running_count = cites_per_year[y] |
| 267 | + years.append((y_hi, y_lo)) |
| 268 | + y_hi = y |
| 269 | + |
| 270 | + if running_count > 0: |
| 271 | + years.append((y_hi, y_lo)) |
| 272 | + |
| 273 | + return years |
| 274 | + |
256 | 275 | def citedby(self, object: Publication)->_SearchScholarIterator: |
257 | 276 | """Searches Google Scholar for other articles that cite this Publication |
258 | 277 | and returns a Publication generator. |
|
0 commit comments