scitex_scholar.formatting
Citation formatting for plain paper dicts.
Provides BibTeX, RIS, EndNote, CSV, and text-style (APA, MLA, Chicago, Vancouver) formatters. Every function accepts a standard paper dict — no ORM or framework dependencies.
Standard paper dict keys:
title, authors_str, journal, year, doi, pmid, arxiv_id, url,
abstract, document_type, citation_count, impact_factor,
is_open_access, source, volume, number, pages, cite_key
- scitex_scholar.formatting.clean_text(text)[source]
Remove characters that break citation formats and normalise whitespace.
- Return type:
- scitex_scholar.formatting.generate_cite_key(paper)[source]
Generate a BibTeX citation key from a paper dict.
- Return type:
- scitex_scholar.formatting.paper_normalize(data)[source]
Normalise a raw dict (e.g. API search result) to a standard paper dict.
- Return type:
- scitex_scholar.formatting.paper_from_search_result(result)[source]
Normalize a raw search-API result dict to the standard paper format.
Handles field aliases from different search engines (externalUrl, snippet, etc.) and fills missing fields with safe defaults.
- Return type:
- scitex_scholar.formatting.make_citation_key(last_name, year=None)[source]
Generate a citation key from author last name and year.
- scitex_scholar.formatting.sanitize_filename(filename, max_length=50)[source]
Sanitize a string for use as a download filename.
Replaces shell-unsafe characters with underscores, collapses whitespace, and truncates to max_length characters.
- Return type:
- scitex_scholar.formatting.to_bibtex(paper)[source]
Format a standard paper dict as a BibTeX entry.
- Return type:
- scitex_scholar.formatting.to_ris(paper)[source]
Format a standard paper dict as a RIS entry.
- Return type:
- scitex_scholar.formatting.to_endnote(paper)[source]
Format a standard paper dict as an EndNote entry.
- Return type:
- scitex_scholar.formatting.to_csv_row(paper)[source]
Format a standard paper dict as a CSV row dict.
- Return type:
- scitex_scholar.formatting.to_text_citation(paper, style='apa', doc_type='article')[source]
Format a paper dict as a text citation in the given style.