<commit_before>import json

ASP_BaseURL = 'http://www.arxiv-sanity.com/'


def build_message(text='Default Text', markdown=True, parts=None):
    """ Combine individual parts of a message into one formatted json message body. """
    if markdown:
        message = {}
        message['text'] = text
        message['mrkdwn'] = markdown
        json_str = json.dumps(message) # validate json. TODO should catch failure
        return json_str
    return text


def make_pdf_link(paper_id):
    """ Build the URL to link to a paper's PDF. """
    return ASP_BaseURL + 'pdf/' + str(paper_id) + '.pdf'


def paper_snippet( paper, number ):
    snippet = {}
    entry = ""
    # Make title line with link to article
    entry += '<{}|{}>\n'.format( paper['link'],
                                 str(number) + '. ' + paper['title'].replace('\n',' '))
    # make authors and date line
    entry += '{} - {}\n'.format(', '.join(paper['authors']).encode('utf-8'),
                                paper['originally_published_time']) # authors are in bold
    # make PDF link line
    entry += '<{}|PDF>\n'.format(make_pdf_link(paper['pid']))
    snippet['text'] = entry
    snippet['fallback'] = paper['title']
    return snippet<commit_msg>add option for abstract in paper snippet<commit_after>import json

ASP_BaseURL = 'http://www.arxiv-sanity.com/'


def build_message(text='Default Text', markdown=True, parts=None):
    """ Combine individual parts of a message into one formatted json message body. """
    if markdown:
        message = {}
        message['text'] = text
        message['mrkdwn'] = markdown
        json_str = json.dumps(message) # validate json. TODO should catch failure
        return json_str
    return text


def make_pdf_link(paper_id):
    """ Build the URL to link to a paper's PDF. """
    return ASP_BaseURL + 'pdf/' + str(paper_id) + '.pdf'


def paper_snippet( paper, number, include_abstract=False ):
    snippet = {}
    entry = ""
    # Make title line with link to article
    entry += '<{}|{}>\n'.format( paper['link'],
                                 str(number) + '. ' + paper['title'].replace('\n',' '))
    # make authors and date line
    entry += '{} - {}\n'.format(', '.join(paper['authors']).encode('utf-8'),
                                paper['originally_published_time']) # authors are in bold

    if include_abstract:
        entry += '-----------------------------\n'
        entry += paper['abstract'] + '\n'
        entry += '-----------------------------\n'
    # make PDF link line
    entry += '<{}|PDF>\n'.format(make_pdf_link(paper['pid']))
    snippet['text'] = entry
    snippet['fallback'] = paper['title']
    return snippet
{'fraction_non_alphanumeric': 0.17379977670264235, 'fraction_numerical': 0.000744324525493115, 'mean_word_length': 2.4505776636713734, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '866627', 'n_tokens_mistral': 794, 'n_tokens_neox': 767, 'n_words': 213}