import json


def concept_net_triplets(input_dict):
    """
    Extracts Subject, Predicate, Object triplets from the Conceptnet response JSON.
    """
    json_response = input_dict['concept_net_json_response']
    try:
        data = json.loads(json_response)
        triplets = [[e['start'], e['rel'], e['end']] for e in data['edges']]
    except:
        raise Exception("Cannot parse this JSON string. Is it a proper Conceptnet API response JSON?")
    
    # Make a separate triplet list without conceptnet prefixes
    basename_triplets = []
    for start, rel, end in triplets:
        start = start.split('/')[-1]
        rel = rel.split('/')[-1]
        end = end.split('/')[-1]
        basename_triplets.append([start, rel, end])

    output_dict = {}
    output_dict['triplets'] = json.dumps(triplets, indent=2)
    output_dict['basename_triplets'] = json.dumps(basename_triplets, indent=2)
    return output_dict