def all_ranks(page_num=1, page_len=100): """ Get unfiltered rankings. """ r = Ranking() print_ranks(r.rank(page_num, page_len))
def keyword_ranks(query, page_num=1, page_len=100, tsv_limit=1000): """ Get text rankings for a keyword query. Args: query (str): A free text query. """ r = Ranking() r.filter_keywords(query) print_ranks(r.rank(page_num, page_len))
def state_ranks(state, page_num=1, page_len=100): """ Get text rankings for a state. Args: state (str): The state abbreviation. """ r = Ranking() r.filter_state(state) print_ranks(r.rank(page_num, page_len))
def institution_ranks(iid, page_num=1, page_len=100): """ Get text rankings for an institution. Args: iid (int): The institution id. """ r = Ranking() r.filter_institution(iid) print_ranks(r.rank(page_num, page_len))
def rank_texts(keywords=None, state=None, institution=None): """ Pull text rankings. Args: keywords (str) state (str) institution (int) Returns: list: A ranked list of texts. """ ranking = Ranking() # Filter by keywords: if keywords: ranking.filter_keywords(keywords) # Filter by state: if state: ranking.filter_state(state) # Filter by institution: if institution: ranking.filter_institution(institution) results = ranking.rank() texts = [] for r in results['ranks']: record = r['record'] texts.append({ 'id': record.id, 'title': prettify_field(record.marc.title()), 'author': prettify_field(record.marc.author()), 'publisher': prettify_field(record.marc.publisher()), 'rank': r['rank'], 't_count': record.metadata['citation_count'], 'f_count': record.count, }) return {'count': results['count'], 'texts': texts}
def rank_texts(keywords=None, state=None, institution=None): """ Pull text rankings. Args: keywords (str) state (str) institution (int) Returns: list: A ranked list of texts. """ ranking = Ranking() # Filter by keywords: if keywords: ranking.filter_keywords(keywords) # Filter by state: if state: ranking.filter_state(state) # Filter by institution: if institution: ranking.filter_institution(institution) results = ranking.rank() texts = [] for r in results['ranks']: record = r['record'] texts.append({ 'id': record.id, 'title': prettify_field(record.marc.title()), 'author': prettify_field(record.marc.author()), 'publisher': prettify_field(record.marc.publisher()), 'rank': r['rank'], 't_count': record.metadata['citation_count'], 'f_count': record.count, }) return { 'count': results['count'], 'texts': texts }