Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add further tests for sn, sl, nd abbreviations #7767

Merged
merged 4 commits into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions openlibrary/catalog/marc/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
DNB_AGENCY_CODE = 'DE-101'
max_number_of_pages = 50000 # no monograph should be longer than 50,000 pages
re_bad_char = re.compile('\ufffd')
re_date = re.compile(r'^[0-9]+u*$')
re_question = re.compile(r'^\?+$')
re_lccn = re.compile(r'([ \dA-Za-z\-]{3}[\d/-]+).*')
re_oclc = re.compile(r'^\(OCoLC\).*?0*(\d+)')
Expand Down Expand Up @@ -327,7 +328,7 @@ def read_languages(rec: MarcBase, lang_008: Optional[str] = None) -> list[str]:
def read_pub_date(rec: MarcBase) -> str | None:
def publish_date(s: str) -> str:
date = s.strip('[]')
if date == 'n.d.': # No date
if date.lower() == 'n.d.': # No date
date = '[n.d.]'
return remove_trailing_number_dot(date)

Expand All @@ -337,14 +338,14 @@ def publish_date(s: str) -> str:

def read_publisher(rec: MarcBase) -> dict[str, Any] | None:
def publisher_name(s: str) -> str:
name = s.strip(' /,;:[')
if name == 's.n.': # Sine nomine
name = s.strip(' /,;:[]')
if name.lower().startswith('s.n'): # Sine nomine
name = '[s.n.]'
return name

def publish_place(s: str) -> str:
place = s.strip(' /.,;:[')
if place == 's.l.': # Sine loco
if place.lower().startswith('s.l'): # Sine loco
place = '[s.l.]'
return place

Expand Down Expand Up @@ -664,7 +665,7 @@ def read_edition(rec: MarcBase) -> dict[str, Any]:
raise BadMARC("'008' field must not be blank")
publish_date = f[7:11]

if publish_date.isdigit() and publish_date != '0000':
if re_date.match(publish_date) and publish_date != '0000':
edition["publish_date"] = publish_date
if f[6] == 't':
edition["copyright_date"] = f[11:15]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"publish_country": "is",
"languages": [
"heb"
],
"title": "Sefer taharat Yosef",
"subtitle": "al hakalhot taharat ha-mish pahah: Rabi \u02bbOvadyah Yosef ...",
"authors": [
{
"name": "Yosef, Ovadia",
"entity_type": "person",
"personal_name": "Yosef, Ovadia"
}
],
"publishers": [
"[s.n.]"
],
"publish_places": [
"[s.l.]"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"publish_country": "xx",
"languages": [
"eng"
],
"title": "Indirect results of missionary labor in northern Turkey",
"by_statement": "by E.E. Bliss, D.D., of Constantinople",
"authors": [
{
"name": "Bliss, E. E.",
"entity_type": "person",
"personal_name": "Bliss, E. E."
}
],
"oclc_numbers": [
"61406084"
],
"lc_classifications": [
"BV3170 .B65 1900"
],
"notes": "Caption title.",
"subject_places": [
"Turkey"
],
"subjects": [
"Missions"
],
"publish_date": "190u",
"publishers": [
"[s.n.]"
],
"publish_places": [
"[s.l.]"
],
"pagination": "7 pages"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00315cam a2200109 a 4500001000800000005001700008008004100025245008500066260002700151700001900178852000800197527654020050406103838.0050406m is b 000 0 heb d10aSefer taharat Yosefbal hakalhot taharat ha-mish pahah: Rabi ʻOvadyah Yosef ... a[s.l]:b[s.n],c[n.d.]1 aYosef, Ovadia.0 bglx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00764cam a2200241Ia 4500001000800000005001700008008004100025035002300066035001700089035001200106040001300118043001200131050002200143100001700165245010300182260004700285300002100332336002600353337002800379500001900407650007500426852002100501541517320221110033004.0050902s190u xx 000 0 eng d a(OCoLC)ocm61406084 a(NNC)5415173 a5415173 aZCUcZCU aa-tu--- 4aBV3170b.B65 19001 aBliss, E. E.10aIndirect results of missionary labor in northern Turkey /cby E.E. Bliss, D.D., of Constantinople. a[s.l.] :b[S.n.],c[between 1900 and 1909] a7 pages ;c24 cm atextbtxt2rdacontent aunmediatedbn2rdamedia aCaption title. 0aMissionszTurkey.0http://id.loc.gov/authorities/subjects/sh201010216980buts,mrlxxph1884
2 changes: 2 additions & 0 deletions openlibrary/catalog/marc/tests/test_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
'880_Nihon_no_chasho.mrc',
'880_publisher_unlinked.mrc',
'880_arabic_french_many_linkages.mrc',
'test-publish-sn-sl.mrc',
'test-publish-sn-sl-nd.mrc',
]

test_data = "%s/test_data" % os.path.dirname(__file__)
Expand Down