<commit_before>import requests
try:
    from urllib.parse import urljoin
except ImportError:
    from urlparse import urljoin

DEFAULT_CLIENT_HEADERS = {
    'Accept': 'application/vnd.api+json',
    'Content-Type': 'application/json'
}


def relationship_data(data):
    return [m.to_relationship() for m in data] \
        if isinstance(data, list) else data.to_relationship()


class ApiError(Exception):
    def __init__(self, resp):
        self.status_code = resp.status_code
        self.body = resp.data
        try:
            self.json = resp.json()
        except:
            self.json = None


class Relationship(object):
    def __init__(self, rel, client, rel_data):
        self.client = client
        self.rel = rel
        self.self_href = rel_data.get('links', {}).get('self', '')
        self.related_href = rel_data.get('links', {}).get('related', '')
        self.data = rel_data.get('data', {})

    def get(self):
        return self.client.get_url(self.related_href)

    def add(self, data):
        data = data if isinstance(data, list) else [data]
        rel_form = relationship_data(data)
        self.data.append(rel_form)
        self.client.post_url(self.self_href, dict(data=rel_form))<commit_msg>Actually fix body -> text<commit_after>import requests
try:
    from urllib.parse import urljoin
except ImportError:
    from urlparse import urljoin

DEFAULT_CLIENT_HEADERS = {
    'Accept': 'application/vnd.api+json',
    'Content-Type': 'application/json'
}


def relationship_data(data):
    return [m.to_relationship() for m in data] \
        if isinstance(data, list) else data.to_relationship()


class ApiError(Exception):
    def __init__(self, resp):
        self.status_code = resp.status_code
        self.body = resp.text
        try:
            self.json = resp.json()
        except:
            self.json = None


class Relationship(object):
    def __init__(self, rel, client, rel_data):
        self.client = client
        self.rel = rel
        self.self_href = rel_data.get('links', {}).get('self', '')
        self.related_href = rel_data.get('links', {}).get('related', '')
        self.data = rel_data.get('data', {})

    def get(self):
        return self.client.get_url(self.related_href)

    def add(self, data):
        data = data if isinstance(data, list) else [data]
        rel_form = relationship_data(data)
        self.data.append(rel_form)
        self.client.post_url(self.self_href, dict(data=rel_form))
{'fraction_non_alphanumeric': 0.12590799031476999, 'fraction_numerical': 0.0, 'mean_word_length': 2.8021472392638036, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2441895', 'n_tokens_mistral': 776, 'n_tokens_neox': 762, 'n_words': 170}