diff --git a/output/index.html b/output/index.html index 24f33b938..1a5b695fb 100644 --- a/output/index.html +++ b/output/index.html @@ -7,26 +7,42 @@ Community notes + + - +
{% for row in site.data.notes %} - {% if forloop.first %} + {% if forloop.first %} + - {% for pair in row %} - - {% endfor %} + + + + - {% endif %} + + + {% endif %} - {% tablerow pair in row %} - {{ pair[1] }} - {% endtablerow %} + + + + + + {% endfor %} +
{{ pair[0] }}TweetClassificationReasonsSummary
{{ row['created_at'] }}{{ row['classification'] }}{{ row['reasons'] }}{{ row['summary'] }}
- + + + diff --git a/script.py b/script.py index 90e7ad158..7b8478da1 100644 --- a/script.py +++ b/script.py @@ -5,7 +5,28 @@ def to_isoformat(ms_since_epoch): - return str(datetime.utcfromtimestamp(int(ms_since_epoch) / 1000)) + return str(datetime.utcfromtimestamp(int(ms_since_epoch[:-3]))) + + +reasons = { + "misleadingOther": "Other", + "misleadingFactualError": "Factual error", + "misleadingManipulatedMedia": "Manipulated media", + "misleadingOutdatedInformation": "Outdated information", + "misleadingMissingImportantContext": "Missing important context", + "misleadingUnverifiedClaimAsFact": "Unverified claim as fact", + "misleadingSatire": "Satire", + "notMisleadingOther": "Other", + "notMisleadingFactuallyCorrect": "Factually correct", + "notMisleadingOutdatedButNotWhenWritten": "Outdated (but not when written)", + "notMisleadingClearlySatire": "Clearly satire", + "notMisleadingPersonalOpinion": "Personal opinion", +} +def get_reasons(row): + return ", ".join([ + v for k, v in reasons.items() + if bool(int(row[k])) + ]) def get_data(date): @@ -39,10 +60,20 @@ def get_generator(): with open("output/_data/notes.csv", "w") as fh: writer = None for row in get_generator(): - if "fullfact" in row["summary"].lower(): - row["createdAt"] = to_isoformat(row["createdAtMillis"]) - del row["createdAtMillis"] - if not writer: - writer = csv.DictWriter(fh, fieldnames=row.keys()) - writer.writeheader() - _ = writer.writerow(row) + if "fullfact" not in row["summary"].lower(): + # filter out non-fullfact stuff + continue + output = { + "tweet_id": row["tweetId"], + "note_id": row["noteId"], + "note_author_id": row["noteAuthorParticipantId"], + "classification": row["classification"].replace("_", " ").lower().capitalize(), + "reasons": get_reasons(row), + "summary": row["summary"], + "trustworthy_source": bool(row["trustworthySources"]), + "created_at": to_isoformat(row["createdAtMillis"]), + } + if not writer: + writer = csv.DictWriter(fh, fieldnames=output.keys()) + writer.writeheader() + _ = writer.writerow(output)