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

importbot importing books that are of bad quality #6283

Merged
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
9 changes: 7 additions & 2 deletions scripts/partner_batch_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ def csv_to_ol_json_item(line):
b = Biblio(data)
return {'ia_id': b.source_id, 'data': b.json()}

def is_low_quality_book(book_item):
"""check if a book item is of low quality"""
return ("notebook" in book_item.title.casefold() and "independently published" in book_item.publisher.casefold())
Copy link
Contributor

Choose a reason for hiding this comment

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

This appears to be English-only code. Is that still allowed?

Copy link
Collaborator

Choose a reason for hiding this comment

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

The bulk of the spammy books were in English; we should add more checks here as we find more bad auto-imports. ( https://docs.google.com/spreadsheets/d/1mG8Tn-sx73fdcHNAvFCJ-2p_-ULT_5QH90y5LLMpbtY/edit#gid=0 ). Good choice of query, @jennshan !



def batch_import(path, batch, batch_size=5000):
logfile = os.path.join(path, 'import.log')
Expand All @@ -191,7 +195,9 @@ def batch_import(path, batch, batch_size=5000):
offset = 0

try:
book_items.append(csv_to_ol_json_item(line))
book_item = csv_to_ol_json_item(line)
if not is_low_quality_book(book_item["data"]):
book_items.append(book_item)
except AssertionError as e:
logger.info(f"Error: {e} from {line}")

Expand All @@ -206,7 +212,6 @@ def batch_import(path, batch, batch_size=5000):
batch.add_items(book_items)
update_state(logfile, fname, line_num)


def main(ol_config: str, batch_path: str):
load_config(ol_config)

Expand Down