nextml / caption-contest-data-api

An API to access data from The New Yorker Caption Contest
https://nextml.github.io/caption-contest-data-api/
Other
60 stars 15 forks source link

Change base url to caption-contest-data-api #46

Closed park-jihoo closed 1 year ago

park-jihoo commented 1 year ago

in _api.py, there is a function named metadata

def metadata(contest: Union[int, str]) -> Dict[str, Union[str, int]]:
    """
    Parameters
    ----------
    contest : int, str
        Argument to :py:func:`summary`. See :py:func:`summary_ids`.

    Returns
    -------
    info : dict
        Dictionary with keys

        * ``comic``: A URL to the comi
        * ``num_responses``, ``num_captions``: an integer with the number of
          responses and captions respectively
        * ``funniest_caption``: the funniest caption, as rated by users.
        * ``example_query``: an example query. For certain contest
          (519, 550, 587 and 588) this key is not present.

    """
    c = contest if isinstance(contest, int) else int(contest.split("_")[0])
    df = summary(contest)
    base = "https://github.com/nextml/caption-contest-data/raw/master/contests/info"
    top = df["rank"].idxmin()

    d = {
        "comic": base + f"/{c}/{c}.jpg",
        "num_responses": df["count"].sum(),
        "num_captions": len(df["caption"]),
        "funniest_caption": df.loc[top, "caption"],
    }
    if c not in {519, 550, 587, 588}:
        d.update({"example_query": base + f"/{c}/example_query.png"})
    return d

base url should change to caption-contest-data-api and I think num_responses should also change

stsievert commented 1 year ago

Thanks for the catch @park-jihoo! I'd suggest looking at nextml.github.io/caption-contest-data ; it's newer and easier to use too.