andycasey / ads

Python tool for ADS
MIT License
170 stars 72 forks source link

Why is the total number of filtered articles and citation_count cumulative number inconsistent with manual searches? #124

Closed oneLuckyfish closed 2 years ago

oneLuckyfish commented 2 years ago

Why is the total number of filtered articles and citation_count cumulative number inconsistent with manual searches? Thank you! 微信图片_20221116211937 微信图片_20221116211947

`import ads import os import datetime as dt import pandas as pd import matplotlib import matplotlib.pyplot as plt import numpy as np

token = '*****'

def query_counts(keywords, query, year, acknowledgements=False): if acknowledgements: query = 'ack:' + query modifiers = ' '.join([f'year:{year}']) full_query = ' '.join([f"abs:('{query}')", modifiers]) filter_query = ['database:astronomy', 'property:refereed', 'doctype:article'] papers = ads.SearchQuery(q=full_query, fq=filter_query, token=token, sort="citation_count") papers.execute() results_count = int(papers.response.numFound) citation_count_num = 0 for n in papers.articles: citation_count_num += n.citation_count print(modifiers, full_query, results_count, citation_count_num) return dict(keywords=keywords, query=query, year=year, count=results_count, citation_count_num=citation_count_num)

DATA = { 'LAMOST': ['LAMOST'], 'SDSS': ['SDSS'], 'SDSS_Official': ['"BOSS" OR "APOGEE" OR "eBOSS" OR "MARVELS" OR "MANGA" OR "SDSS" OR ("Sloan" AND "Survey")) OR ' 'title:("BOSS" OR "APOGEE" OR "eBOSS" OR "MARVELS" OR "MANGA" OR "SDSS" OR ("Sloan" AND ' '"Survey")'], 'SDSS Spectrum': ['SDSS Spectrum'], }

filename = 'ADS_results1.csv' years = [] for y in range(2022, 2023): years.append(str(y)) years.append('1994-2022') if not os.path.exists(filename): results = pd.DataFrame([query_counts(keywords, query, year) for keywords, queries in DATA.items() for query in queries for year in years]) results.to_csv(filename, index=False)`

oneLuckyfish commented 2 years ago

https://github.com/andycasey/ads/issues/104#issuecomment-1317592451 Thanks Accomazzi!