def df2chunkset(df, chunktag='chunktag', guesstag='guesstag'):
    """Converts a pandas `DataFrame` into the format accepted by the `evaluate`
    method.

    :param df: input DataFrame
    :type df: pd.DataFrame
    :param chunktag: name of the original chunk tag column
    :type chunktag: str
    :param guesstag: name of the guess chunk tag column
    :type guesstag: str
    :return: gold chunkset and guess chunkset
    :rtype: tuple
    """
    go, ge = set(), set()
    if df.iloc[0][chunktag][0] not in 'BOS':
        raise ValueError('Invalid chunktag on first token.')
    if df.iloc[0][guesstag][0] not in 'BOS':
        raise ValueError('Invalid guesstag on first token.')
    chunk_go = [(0, df.iloc[0][chunktag])]
    chunk_ge = [(0, df.iloc[0][guesstag])]
    for tid, r in df.iloc[1:].iterrows():
        if r[chunktag][0] in 'BOS':
            # start new
            go.add(tuple(chunk_go))
            chunk_go = [(tid, r[chunktag])]
        else:
            # continue chunk
            chunk_go.append((tid, r[chunktag]))
        if r.guesstag[0] in 'BOS':
            # start new
            ge.add(tuple(chunk_ge))
            chunk_ge = [(tid, r[guesstag])]
        else:
            # continue chunk
            chunk_ge.append((tid, r[guesstag]))

    if chunk_ge:
        ge.add(tuple(chunk_ge))
    if chunk_go:
        go.add(tuple(chunk_go))

    return go, ge