View Single Post
Old 07-11-2025, 06:10 PM   #32
frustratedhacker
Junior Member
frustratedhacker began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Oct 2019
Device: KT3
Quote:
Originally Posted by davidjoseph1 View Post
I would love to see your code. I haven't been able to wrap my head around ETREE and make that extraction work, and there are a bunch of different LC codes that contain alternate LCSH and Subject headings.
I spoke too soon about the LCSH extractor. It wasn't as complete as I thought. Now, after lots of testing, I think it's working pretty good, although I've made other changes which maybe you're not comfortable with. I still have to make a few changes and tests and I'll post it this weekend, most likely.

Quote:
Originally Posted by davidjoseph1 View Post
That's interesting. I haven't seen that, and the underlying SRU query language doesn't mention character limits
That's right, but at the moment of posting that, that query wasn't returning anything, not even an error. When I was doing tests, days after that, it worked fine. Maybe it was a server problem.

Quote:
Originally Posted by davidjoseph1 View Post
Basically restoring the VIAF and LC Subject and Name Authorities lookup. There's a lot of extended value in those cross-references for further research and curiosity.
The VIAF thing I've seen it in the code. It's just getting the author's VIAF id, right? I'm a bit lost with the LC Subject and Name Authorities lookup you mention. Can you specify where in the code is it?

For the VIAF, I discovered the viapy python library (https://github.com/Princeton-CDH/viapy), but you I saw in the code you can get a json response by changing the header in the request (https://github.com/Princeton-CDH/via...apy/api.py#L45). You can try this in the REPL:

Code:
import requests

def get_viaf_id_auto(name):
    resp = requests.get(
        "http://viaf.org/viaf/AutoSuggest",
        params={"query": name},
        headers={"accept": "application/json"}
    )
    data = resp.json()
    res = data.get("result", [])
    if not res:
        return None
    first_result = res[0]
    first_result_viafid = res[0]["viafid"]
    return first_result, first_result_viafid

first_result, first_result_viafid = get_viaf_id_auto("Jane Austen")

print("First result:", first_result, "\n")
print("First result's VIAF id:", first_result_viafid)
frustratedhacker is offline   Reply With Quote