mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-28 04:21:07 +00:00
prefer English language sources for ISNI titles
This commit is contained in:
parent
fd3ed7fb8c
commit
09c5a3861b
2 changed files with 22 additions and 20 deletions
|
@ -66,7 +66,7 @@
|
||||||
{% if book_title %}
|
{% if book_title %}
|
||||||
<a href="{{ match.local_path }}" target="_blank">{% trans "Author of " %}<em>{{ book_title }}</em></a>
|
<a href="{{ match.local_path }}" target="_blank">{% trans "Author of " %}<em>{{ book_title }}</em></a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="{{ match.id }}" target="_blank">{% trans "Author of " %}<em>{{ alt_title }}</em></a>
|
<a href="{{ match.id }}" target="_blank">{% if alt_title %}{% trans "Author of " %}<em>{{ alt_title }}</em>{% else %} {% trans "Find more information at isni.org" %}{% endif %}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -92,32 +92,34 @@ def find_authors_by_name(name_string, description=False):
|
||||||
# build list of possible authors
|
# build list of possible authors
|
||||||
possible_authors = []
|
possible_authors = []
|
||||||
for element in root.iter("responseRecord"):
|
for element in root.iter("responseRecord"):
|
||||||
|
|
||||||
personal_name = element.find(".//forename/..")
|
personal_name = element.find(".//forename/..")
|
||||||
bio = element.find(".//nameTitle")
|
|
||||||
|
|
||||||
if not personal_name:
|
if not personal_name:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
author = get_author_from_isni(element.find(".//isniUnformatted").text)
|
author = get_author_from_isni(element.find(".//isniUnformatted").text)
|
||||||
|
|
||||||
if bool(description):
|
if bool(description):
|
||||||
titles = element.findall(".//title")
|
|
||||||
if titles:
|
titles = []
|
||||||
# some of the "titles" in ISNI are a little ...iffy
|
# prefer title records from LoC+ coop, Australia, Ireland, or Singapore
|
||||||
title_element = [e for e in titles if not e.text.replace('@', '').isnumeric()][0]
|
# in that order
|
||||||
title = (
|
for source in ["LCNACO", "NLA", "N6I", "NLB"]:
|
||||||
title_element.text.replace('@', '')
|
for parent in element.findall(f'.//titleOfWork/[@source="{source}"]'):
|
||||||
if titles is not None
|
titles.append(parent.find(".//title"))
|
||||||
and title_element is not None
|
for parent in element.findall(f'.//titleOfWork[@subsource="{source}"]'):
|
||||||
and len(title_element.text) > 4
|
titles.append(parent.find(".//title"))
|
||||||
else None
|
# otherwise just grab the first title listing
|
||||||
)
|
titles.append(element.find(".//title"))
|
||||||
author.bio = (
|
|
||||||
title if title is not None
|
if titles is not None:
|
||||||
else bio.text if bio is not None
|
# some of the "titles" in ISNI are a little ...iffy
|
||||||
else "More information at isni.org"
|
# '@' is used by ISNI/OCLC to index the starting point ignoring stop words
|
||||||
)
|
# (e.g. "The @Government of no one")
|
||||||
|
title_elements = [e for e in titles if not e.text.replace('@', '').isnumeric()]
|
||||||
|
if len(title_elements):
|
||||||
|
author.bio = title_elements[0].text.replace('@', '')
|
||||||
|
else:
|
||||||
|
author.bio = None
|
||||||
|
|
||||||
possible_authors.append(author)
|
possible_authors.append(author)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue