A collection of Python wrappers for the French National Library Gallica API.
Project description
gallicaGetter
This tool wraps a few endpoints from the Gallica API.
Current functionality:
- context for term occurrence and page numbers
- for a term, all the volumes the term appears in
- for a term, the number of volumes with >= 1 occurrence over a range (per year, per month)
- full text for a volume on Gallica
- paper titles and publishing range data
- years published for a paper (used internally in papers)
I developed this tool into a graphing app similar to Google's n-gram viewer for books. There is much more metadata in the Gallica API response I don't currently parse. Happy to add more; pull requests are also welcome!
For an exact number of occurrences over a period, normalized by total words in that period, use Pyllicagram.
Installation
pip install gallicaGetter
Production Example
Here's a snippet of code from my API that makes use of the volume and context wrappers.
from gallicaGetter import wrapperFactory as wF
# fetch the volumes in which terms appear
volume_Gallica_wrapper = wF.WrapperFactory.volume()
gallica_records = volume_Gallica_wrapper.get(
terms=terms,
start_date=make_date_from_year_mon_day(year, month, day),
codes=codes,
source=source,
link=link,
num_results=limit,
start_index=cursor,
sort=sort,
on_get_total_records=set_total_records,
)
# fetch the context for those terms
content_wrapper = wF.WrapperFactory.context()
keyed_records = {record.url.split("/")[-1]: record for record in gallica_records}
context = content_wrapper.get(
[
(record.url.split("/")[-1], record.term)
for _, record in keyed_records.items()
]
)
# combine the two
records_with_context: List[GallicaRecord] = []
for record in context:
corresponding_record = keyed_records[record.ark]
records_with_context.append(
(
corresponding_record.paper_title,
corresponding_record.paper_code,
corresponding_record.term,
str(corresponding_record.date),
corresponding_record.url,
record,
)
)
print(records_with_contex)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file gallicagetter-1.0.0.tar.gz
.
File metadata
- Download URL: gallicagetter-1.0.0.tar.gz
- Upload date:
- Size: 24.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f681c25f97ee1a12fdc19aed3d00a36e06dc9c2851c6a630ed2fcb9c1acc282f |
|
MD5 | cc70d4ed6c46954a21b77904e249d385 |
|
BLAKE2b-256 | 56f15fbad1c6ec28e9a4ff7c97a9838983707864ab2daf0a033c12ea34c9a07f |
File details
Details for the file gallicagetter-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: gallicagetter-1.0.0-py3-none-any.whl
- Upload date:
- Size: 38.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e49606b6ed1c02b1bcd2e544217a966a20ae976022fdb7ecb9be489d4d21ae9 |
|
MD5 | 43c91f79179c8e3c8df8037de46a42ae |
|
BLAKE2b-256 | bc1616a2c3f730269467c41775aecf631ac231c400f15be9d4b1c57d8858c028 |