Skip to content

Refactoring east_in_by_statement() import logic - #14220

Merged
hornc merged 5 commits into
internetarchive:masterfrom
hornc:refactor_east_in_by_statement
Nov 4, 2026
Merged

hornc merged 5 commits into
internetarchive:masterfrom
hornc:refactor_east_in_by_statement

Conversation

@hornc

@hornc hornc commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Following on from the investigation / TODO prompted by #14217 where this east_in_by_statement() had a similar use pattern of being unlikely to fire, just before saving records.

This PR removes the old east_in_by_statement() check that is used inconsistently, and only on record save, not matching. It can only ever fire if an import record happens to have a by_statement which seems more likely on MARC records, which have other mechanisms for determining correct name forms.

The end result seems to be Author records with commas, since the result is only ever used to skip a do_flip() just before saving a record.

If we import

"name": "Toyama, Keiichirō"
that happens to have a by_statement containing "Toyama Keiichirō" OL will create a record "Toyama, Keiichirō"

If the "by_statement" is missing (which it will most likely be from most import paths), it will create "Keiichirō Toyama"

In matching, "Keiichirō Toyama" will be considered, but not "Toyama, Keiichirō"

There is one existing use of load_author_import_records() for works which also ignores eastern name order, and is another source of inconsistency.

Bottom line:

  • the check hardly ever fires
  • has no tests for the path when it does
  • is used inconsistently when it does
  • and when it does have an effect it creates oddly formatted Author entries with commas that are not the preferred OL form, and leaves no indication that the name is ordered in a particular way.

(there's a legacy eastern_order field on Authors that is currently never set or used)

With the improved 'alternate script' handling, original names in original script can be imported from MARC records.
For real world use cases, alternate_names will suffice.

It seems either

  • Murakami Haruki
    or
  • Haruki Murakami

are preferrable to:

  • Murakami, Haruki

as both occur naturally in differnt contexts, and both can be mapped using alternate_names

"Murakami, Haruki" as the record title is a false compromise that deosn't help anyone, and is excluded from the normal matching lookups.

Technical

Testing

Screenshot

Stakeholders

hornc added 5 commits October 30, 2026 11:16
it's unclear the advantage of sometimes leaving commas in created
records on save. It likely interferes with record matching and
risks adding duplicates.
@hornc
hornc marked this pull request as ready for review October 29, 2026 23:54
@tfmorris

Copy link
Copy Markdown
Contributor

I totally support cleaning this up, but can you elaborate on what the data shows as far as the prevalence of this? Removing and then re-adding normalization support is one approach, but it seems fraught with the risk of it getting dropped altogether. Also, it's not just "Eastern" names that follow different orders. Wikidata/Wikipedia uses culturally appropriate Last First (as opposed to First Last) for some European cultures (Hungarian?).

It looks like the cataloging standards have changed recently in this area and Preferred Name Variant might be something to keep an eye on: https://www.loc.gov/marc/authority/adx00.html

One thing I definitely agree with is not changing name forms at the last minute before saving rather than normalizing them for matching first and trying to figure out what the best default display form.

@github-actions github-actions Bot added the Needs: Response Issues which require feedback from lead label Oct 30, 2026
@hornc

hornc commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator Author
zgrep -c '"eastern_order":' ol_dump_authors_2026-10-31.txt.gz
0

Shows there are no authors with the field I'm removing.

I wouldn't characterise the code I'm removing as "normalization support". It seems to detect whether a name is in 'eastern order' if it's name order doesn't match how it appears in the "by statement", and skips the normalization process altogether is so, leaving an unexplained "database order" name with commas.

I'm not sure what the legacy 'feature' is. It seems to have survived because it hardly ever fires. Using a commafied version of an incoming author name is the one least likely to find an existing match because it is in no version of a natural name order.

I suggest names are imported ideally the way they are intended to appear in records.

Records will come in 'database' or 'natural' order, and should find existing records in either format (which alternate_names accomplish). 'natural' name order seems often depend on where an individual happens to be, or doing business, and can have multiple forms, equally correct.

@tfmorris tfmorris left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. This is a vestigial "feature" which was never fully implemented.

Culture specific name part ordering needs to be done based on the locale of the reader, so isn't something that can be done as part of import.

@hornc
hornc merged commit 87de1b4 into internetarchive:master Nov 4, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs: Response Issues which require feedback from lead

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants