Updated for altered column names
Browse files
eol_realign/scripts/match_owners.py
CHANGED
|
@@ -7,8 +7,8 @@ import sys
|
|
| 7 |
# This file can be used on predicted-catalog or rarespecies-catalog by changing the CATALOG_PATH.
|
| 8 |
# It is intended to just add the extra licensing information to the combined manifest
|
| 9 |
# Owner fix file: https://huggingface.co/datasets/imageomics/eol/blob/main/owners_info_fix/media_manifest_missing_licenses_jul26_owners.csv
|
| 10 |
-
MANIFEST_PATH = "
|
| 11 |
-
OWNER_PATH = "
|
| 12 |
|
| 13 |
|
| 14 |
def get_owners_titles(manifest, owners):
|
|
@@ -29,27 +29,27 @@ def get_owners_titles(manifest, owners):
|
|
| 29 |
missing_owners = [
|
| 30 |
comb_id
|
| 31 |
for comb_id in list(
|
| 32 |
-
manifest.loc[manifest["
|
| 33 |
)
|
| 34 |
]
|
| 35 |
|
| 36 |
for comb_id in tqdm(missing_owners):
|
| 37 |
temp = owners.loc[owners.combined_id_owner == comb_id]
|
| 38 |
-
copyright_owner = temp["Copyright Owner"].values
|
| 39 |
-
title = temp.title.values
|
| 40 |
-
manifest.loc[manifest["combined_id_full_manifest"] == comb_id, "
|
| 41 |
manifest.loc[manifest["combined_id_full_manifest"] == comb_id, "title"] = title
|
| 42 |
|
| 43 |
# Print counts of licenses for which owner info was not resolved
|
| 44 |
print(
|
| 45 |
"Licenses still missing Copyright Owners: \n",
|
| 46 |
manifest.loc[
|
| 47 |
-
manifest["
|
| 48 |
].value_counts(),
|
| 49 |
)
|
| 50 |
|
| 51 |
-
# Fill null "
|
| 52 |
-
manifest["
|
| 53 |
manifest["title"].fillna("not provided", inplace=True)
|
| 54 |
|
| 55 |
return manifest
|
|
@@ -67,7 +67,7 @@ def update_owners(manifest, owners, filepath):
|
|
| 67 |
"""
|
| 68 |
# Need combined IDs for the owner match file
|
| 69 |
# EOL content & page IDs read in as int64
|
| 70 |
-
owners["combined_id_owner"] = owners["
|
| 71 |
|
| 72 |
updated_manifest = get_owners_titles(manifest, owners)
|
| 73 |
|
|
|
|
| 7 |
# This file can be used on predicted-catalog or rarespecies-catalog by changing the CATALOG_PATH.
|
| 8 |
# It is intended to just add the extra licensing information to the combined manifest
|
| 9 |
# Owner fix file: https://huggingface.co/datasets/imageomics/eol/blob/main/owners_info_fix/media_manifest_missing_licenses_jul26_owners.csv
|
| 10 |
+
MANIFEST_PATH = "data/combined_manifest_with_checksums.csv"
|
| 11 |
+
OWNER_PATH = "data/media_manifest_missing_licenses_jul26_owners.csv"
|
| 12 |
|
| 13 |
|
| 14 |
def get_owners_titles(manifest, owners):
|
|
|
|
| 29 |
missing_owners = [
|
| 30 |
comb_id
|
| 31 |
for comb_id in list(
|
| 32 |
+
manifest.loc[manifest["copyright_owner"].isna(), "combined_id_full_manifest"]
|
| 33 |
)
|
| 34 |
]
|
| 35 |
|
| 36 |
for comb_id in tqdm(missing_owners):
|
| 37 |
temp = owners.loc[owners.combined_id_owner == comb_id]
|
| 38 |
+
copyright_owner = str(temp["Copyright Owner"].values)
|
| 39 |
+
title = str(temp.title.values)
|
| 40 |
+
manifest.loc[manifest["combined_id_full_manifest"] == comb_id, "copyright_owner"] = copyright_owner
|
| 41 |
manifest.loc[manifest["combined_id_full_manifest"] == comb_id, "title"] = title
|
| 42 |
|
| 43 |
# Print counts of licenses for which owner info was not resolved
|
| 44 |
print(
|
| 45 |
"Licenses still missing Copyright Owners: \n",
|
| 46 |
manifest.loc[
|
| 47 |
+
manifest["copyright_owner"].isna(), "License Name"
|
| 48 |
].value_counts(),
|
| 49 |
)
|
| 50 |
|
| 51 |
+
# Fill null "copyright_owner" and "Title" values with "not provided"
|
| 52 |
+
manifest["copyright_owner"].fillna("not provided", inplace=True)
|
| 53 |
manifest["title"].fillna("not provided", inplace=True)
|
| 54 |
|
| 55 |
return manifest
|
|
|
|
| 67 |
"""
|
| 68 |
# Need combined IDs for the owner match file
|
| 69 |
# EOL content & page IDs read in as int64
|
| 70 |
+
owners["combined_id_owner"] = owners["EOL content ID"].astype(str) + "_" + owners["EOL page ID"].astype(str)
|
| 71 |
|
| 72 |
updated_manifest = get_owners_titles(manifest, owners)
|
| 73 |
|