<commit_before>'''
Created on Nov 10, 2014

@author: ayan
'''


def get_publication_type(json_content):
    """
    THIS FUNCTION IS DEPRECATED
    
    Parse JSON content to get the publication
    type for display with recent publications.
    
    :param dict json_content: JSON data as a Python dictionary
    :return: publication type, possibly with page number
    :rtype: str 
    """
    try:
        pub_type = json_content['largerWorkSubtype']['text'] # try to get the publication type from largerWorkSubtype
    except KeyError:
        pub_type = json_content['publicationSubtype']['text'] # failing that, try to get it from publicationSubtype
    except KeyError:
        pub_type = json_content['seriesTitle']['text'] # failing that, try to get it from the seriesTitle
    if pub_type != 'Journal Article':
        pub_year = json_content['publicationYear']
        display_pub_type = '{publication_type}: {publication_year}'.format(publication_type=pub_type, publication_year=pub_year)
    else:
        display_pub_type = pub_type
    return display_pub_type


def display_publication_info(json_content):
    publication_year = json_content['publicationYear']
    series_title_text = json_content['seriesTitle']['text']
    if json_content.get('seriesTitle', None) and json_content.get('seriesNumber', None):
        series_number = json_content['seriesNumber']
        chapter = json_content.get('chapter', None)
        subchapter = json_content.get('subChapter', None)
        if chapter and subchapter:
            pub_info = '{publication_year}, {title} {series_number} {chapter} {subchapter}'.format(publication_year=publication_year,
                                                                                                   title=series_title_text,
                                                                                                   series_number=series_number,
                                                                                                   chapter=chapter,
                                                                                                   subchapter=subchapter
                                                                                                   )
        elif chapter and not subchapter:
            pub_info = '{publication_year}, {title} {series_number} {chapter}'.format(publication_year=publication_year,
                                                                                      title=series_title_text,
                                                                                      series_number=series_number,
                                                                                      chapter=chapter
                                                                                      )
        else:
            pub_info = '{publication_year}, {title} {series_number}'.format(publication_year=publication_year,
                                                                            title=series_title_text,
                                                                            series_number=series_number
                                                                            )
        full_pub_info = pub_info           
    elif json_content.get('seriesTitle', None) and json_content.get('publicationType', None).get('text', None) == 'Article':
        start_page = json_content.get('startPage', None)
        end_page = json_content.get('endPage', None)
        try:
            volume = json_content['volume']
            pub_info = '{publication_year}, {title} ({volume}) {start_page}'.format(publication_year=publication_year,
                                                                                    title=series_title_text,
                                                                                    volume=volume,
                                                                                    start_page=start_page
                                                                                    )
        except KeyError:
            volume = None
            pub_info = '{publication_year}, {title} {start_page}'.format(publication_year=publication_year,
                                                                         title=series_title_text,
                                                                         start_page=start_page
                                                                         )
        if end_page:
            full_pub_info = '{pub_info}-{end_page}'.format(pub_info=pub_info, end_page=end_page)
        else:
            full_pub_info = pub_info
    else:
        pass
    return full_pub_info
        <commit_msg>removed deprecated custome filter<commit_after>'''
Created on Nov 10, 2014

@author: ayan
'''


def display_publication_info(json_content):
    publication_year = json_content['publicationYear']
    series_title_text = json_content['seriesTitle']['text']
    if json_content.get('seriesTitle', None) and json_content.get('seriesNumber', None):
        series_number = json_content['seriesNumber']
        chapter = json_content.get('chapter', None)
        subchapter = json_content.get('subChapter', None)
        if chapter and subchapter:
            pub_info = '{publication_year}, {title} {series_number} {chapter} {subchapter}'.format(publication_year=publication_year,
                                                                                                   title=series_title_text,
                                                                                                   series_number=series_number,
                                                                                                   chapter=chapter,
                                                                                                   subchapter=subchapter
                                                                                                   )
        elif chapter and not subchapter:
            pub_info = '{publication_year}, {title} {series_number} {chapter}'.format(publication_year=publication_year,
                                                                                      title=series_title_text,
                                                                                      series_number=series_number,
                                                                                      chapter=chapter
                                                                                      )
        else:
            pub_info = '{publication_year}, {title} {series_number}'.format(publication_year=publication_year,
                                                                            title=series_title_text,
                                                                            series_number=series_number
                                                                            )
        full_pub_info = pub_info           
    elif json_content.get('seriesTitle', None) and json_content.get('publicationType', None).get('text', None) == 'Article':
        start_page = json_content.get('startPage', None)
        end_page = json_content.get('endPage', None)
        try:
            volume = json_content['volume']
            pub_info = '{publication_year}, {title} ({volume}) {start_page}'.format(publication_year=publication_year,
                                                                                    title=series_title_text,
                                                                                    volume=volume,
                                                                                    start_page=start_page
                                                                                    )
        except KeyError:
            volume = None
            pub_info = '{publication_year}, {title} {start_page}'.format(publication_year=publication_year,
                                                                         title=series_title_text,
                                                                         start_page=start_page
                                                                         )
        if end_page:
            full_pub_info = '{pub_info}-{end_page}'.format(pub_info=pub_info, end_page=end_page)
        else:
            full_pub_info = pub_info
    else:
        pass
    return full_pub_info
        
{'fraction_non_alphanumeric': 0.06359851988899168, 'fraction_numerical': 0.0013876040703052729, 'mean_word_length': 0.9488508337088779, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 130, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5868526', 'n_tokens_mistral': 1663, 'n_tokens_neox': 1566, 'n_words': 313}