<commit_before>"""All valid bib(la)tex entry types.

As of the Biblatex package documentation version 3.2 (27/12/2015)

"""

import collections


base_entry_types = frozenset(
    ['article',
     'book',
     'booklet',
     'inbook',
     'incollection',
     'inproceedings',
     'manual',
     'misc',
     'proceedings',
     'unpublished']
)

##################################################################
# Bibtex
##################################################################
bibtex_entry_types = frozenset(
    ['conference',
     'masterthesis',
     'phdthesis',
     'techreport']
)

##################################################################
# Biblatex
##################################################################
# The set of all valid Biblatex entry types
biblatex_entry_types = frozenset(
    ['bookinbook',
     'booklet',
     'collection',
     'inference',
     'mvbook',
     'mvcollection',
     'mvproceedings',
     'mvreference',
     'online',
     'patent',
     'periodical',
     'reference',
     'report',
     'set',
     'suppbook',
     'suppcollection',
     'suppperiodical',
     'thesis',
     'xdata']
)

# Unsupported entry types
biblatex_unsupported_entry_types = frozenset(
    ['artwork',
     'audio',
     'bibnote',
     'commentary',
     'image',
     'juristiction',
     'legislation',
     'legal',
     'letter',
     'movie',
     'music',
     'performance',
     'review',
     'software',
     'standard',
     'video']
)

# Type aliases for all Biblatex entry types
biblatex_entry_type_aliases = {
    'inproceedings': ['conference'],
    'online':        ['electronic', 'www'],
    'report':        ['techreport'],
    'thesis':        ['masterthesis', 'phdthesis']
}

bibtex = base_entry_types | bibtex_entry_types
biblatex = base_entry_types | biblatex_entry_types |\
    biblatex_unsupported_entry_types |\
    frozenset([v for l in biblatex_entry_type_aliases.values() for v in l])

all = biblatex | bibtex


def aliases(entry_type, format):
    """Return the aliases of the given entry type and format."""
    # There are no aliases in bibtex
    if format != 'biblatex':
        return []

    return biblatex_entry_type_aliases.get(entry_type, [])


# Light-weight container object for parsed entries
Entries = collections.namedtuple('Entries', ['entries', 'strings', 'preambles',
                                             'comment_entries', 'comments'])<commit_msg>Extend Entries class with 'all' property<commit_after>"""All valid bib(la)tex entry types.

As of the Biblatex package documentation version 3.2 (27/12/2015)

"""

import collections


base_entry_types = frozenset(
    ['article',
     'book',
     'booklet',
     'inbook',
     'incollection',
     'inproceedings',
     'manual',
     'misc',
     'proceedings',
     'unpublished']
)

##################################################################
# Bibtex
##################################################################
bibtex_entry_types = frozenset(
    ['conference',
     'masterthesis',
     'phdthesis',
     'techreport']
)

##################################################################
# Biblatex
##################################################################
# The set of all valid Biblatex entry types
biblatex_entry_types = frozenset(
    ['bookinbook',
     'booklet',
     'collection',
     'inference',
     'mvbook',
     'mvcollection',
     'mvproceedings',
     'mvreference',
     'online',
     'patent',
     'periodical',
     'reference',
     'report',
     'set',
     'suppbook',
     'suppcollection',
     'suppperiodical',
     'thesis',
     'xdata']
)

# Unsupported entry types
biblatex_unsupported_entry_types = frozenset(
    ['artwork',
     'audio',
     'bibnote',
     'commentary',
     'image',
     'juristiction',
     'legislation',
     'legal',
     'letter',
     'movie',
     'music',
     'performance',
     'review',
     'software',
     'standard',
     'video']
)

# Type aliases for all Biblatex entry types
biblatex_entry_type_aliases = {
    'inproceedings': ['conference'],
    'online':        ['electronic', 'www'],
    'report':        ['techreport'],
    'thesis':        ['masterthesis', 'phdthesis']
}

bibtex = base_entry_types | bibtex_entry_types
biblatex = base_entry_types | biblatex_entry_types |\
    biblatex_unsupported_entry_types |\
    frozenset([v for l in biblatex_entry_type_aliases.values() for v in l])

all = biblatex | bibtex


def aliases(entry_type, format):
    """Return the aliases of the given entry type and format."""
    # There are no aliases in bibtex
    if format != 'biblatex':
        return []

    return biblatex_entry_type_aliases.get(entry_type, [])


# Private named tuple used as a base class for the real Entries class
_Entries = collections.namedtuple('Entries',
                                  ['entries', 'strings', 'preambles',
                                   'comment_entries', 'comments'])


class Entries(_Entries):
    """Light-weight container object for parsed entries."""

    __slots__ = ()

    @property
    def all(self):
        """Return all entries (excluding comments) as a list."""
        return self.entries + self.strings + self.preambles +\
            self.comment_entries
{'fraction_non_alphanumeric': 0.21713637223378096, 'fraction_numerical': 0.0037828636277662192, 'mean_word_length': 3.1442006269592477, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6563970', 'n_tokens_mistral': 1646, 'n_tokens_neox': 1561, 'n_words': 358}