Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Smithsonian NMNH improvements related to creator and description fields #474

Merged
merged 5 commits into from Aug 14, 2020

Conversation

ChariniNana
Copy link
Contributor

@ChariniNana ChariniNana commented Jul 30, 2020

Fixes

Fixes #470 by @ChariniNana

Description

With this fix, we reduce the percentage of missing creators related to NMNH data from 100.00% to 3.34% and the percentage of missing descriptions is reduced from 99.60% to 96.96%

Technical details

The creator value is retrieved from the freetext -> name -> Collector field in the JSON response and the description is taken from the freetext -> notes -> Notes field. Furthermore, we now concatenate all creator values with the same level of preference (as specified in the CREATOR_TYPES dictionary) whereas earlier only one value among all identified as most preferred were taken. Currently, the lowest preference is given to the creator value being retrieved from the Collector field since better fields exist of images corresponding to other unit codes.

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the default branch of the repository (main or master).
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no
    visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@ChariniNana ChariniNana requested review from a team, kss682 and mathemancer and removed request for a team July 30, 2020 11:54
@kgodey kgodey added this to In Progress in Active Sprint Jul 30, 2020
@ChariniNana
Copy link
Contributor Author

As a result of this fix, the creator and description information of certain other museums seems to have improved as well. For example, the percentage of images with no creator has reduced from 75.40% to 67.74% for smithsonian_american_indian_museum(NMAI) and the percentage of images with no description has reduced from 98.18% to 0% for si_libraries (SIL)

Copy link
Contributor

@allen505 allen505 left a comment

Choose a reason for hiding this comment

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

Looks great. I found a couple of possible changes and pointed them out.

creators_list = [c['content'] for c in ordered_freetext_creator_objects
if priority == creator_types[c['label'].lower()]]

creator = '; '.join(creators_list[:-1]) + ' and ' + creators_list[-1] \
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you mean to add a comma instead of a semicolon?

Suggested change
creator = '; '.join(creators_list[:-1]) + ' and ' + creators_list[-1] \
creator = ', '.join(creators_list[:-1]) + ' and ' + creators_list[-1] \

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks heaps for the comments @allen505 ! In fact I changed the delimiter from comma to semicolon since sometimes a single creator value too contains commas within the string. Using a semicolon is not ideal, however I'm unsure how else we can make a distinction between the seperate creator values and the comma separation within a single creator string.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's interesting. Do we know why a single creator value has commas within it?
If it's because of multiple creators, then do we need to make a distinction between the separate creator values and the comma separation within a single creator string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not necessarily multiple creators. For example creators appearing for the SIL unit code may look like 'Greenawald, John L' where the value coming before the comma is the surname.

indexed_structured_creator_generator = (
i['content'] for i in _check_type(indexed_structured.get('name'), list)
if type(i) == dict
and _check_type(i.get('type'), str).lower() == 'personal_main'
and _check_type(i.get('content'), str)
)

creator = next(freetext_creator_generator, None)
if ordered_freetext_creator_objects:
c = ordered_freetext_creator_objects[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this variable here can be given a more apt name as there is another variable c on line 289 in the for loop which can cause some confusion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @allen505 ! Made the requested change

@kgodey kgodey moved this from In Progress to In Progress (Community) in Active Sprint Aug 7, 2020
Copy link
Contributor

@mathemancer mathemancer left a comment

Choose a reason for hiding this comment

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

Looks great, thank you!

@mathemancer mathemancer merged commit 4238c2f into master Aug 14, 2020
Active Sprint automation moved this from In Progress (Community) to Done Aug 14, 2020
@mathemancer mathemancer deleted the si_nmnh_improvements branch August 14, 2020 13:56
@TimidRobot TimidRobot removed this from Done in Active Sprint Jan 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

[Infrastructure] Fix Smithsonian NMNH related discrepancies
3 participants