<commit_before>
from .parsers import HTMLParser, MarkdownParser
from .renderers import COMRenderer
from .exceptions import InsertError
import inspect

parsers = {
    "html": HTMLParser,
    "markdown": MarkdownParser
}

renderers = {
    "com": COMRenderer
}


def parse(text, parser=None, **kwargs):
    """
    Parse some given input into a list of operations to perform
    :param text: Text input
    :param parser: Either 'html' or 'markdown', or a class that inherits from BaseParser
    :return: A list of operations
    """
    if isinstance(parser, str) and parser not in parsers:
        raise RuntimeError("Format {0} not recognized".format(format))

    # If we have been given a string instead of a parsers class then lookup the class from the parsers dictionary
    if not inspect.isclass(parser):
        parser = parsers[parser]

    parser = parser()

    return parser.parse(text, **kwargs)
<commit_msg>Add CombinedConstants back to the __init__ imports<commit_after>
from .parsers import HTMLParser, MarkdownParser
from .renderers import COMRenderer
from .utils import CombinedConstants
from .exceptions import InsertError
import inspect

parsers = {
    "html": HTMLParser,
    "markdown": MarkdownParser
}

renderers = {
    "com": COMRenderer
}


def parse(text, parser=None, **kwargs):
    """
    Parse some given input into a list of operations to perform
    :param text: Text input
    :param parser: Either 'html' or 'markdown', or a class that inherits from BaseParser
    :return: A list of operations
    """
    if isinstance(parser, str) and parser not in parsers:
        raise RuntimeError("Format {0} not recognized".format(format))

    # If we have been given a string instead of a parsers class then lookup the class from the parsers dictionary
    if not inspect.isclass(parser):
        parser = parsers[parser]

    parser = parser()

    return parser.parse(text, **kwargs)

{'fraction_non_alphanumeric': 0.08185610010427528, 'fraction_numerical': 0.0010427528675703858, 'mean_word_length': 3.657766990291262, 'pattern_counts': {'":': 6, '<': 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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4117902', 'n_tokens_mistral': 535, 'n_tokens_neox': 512, 'n_words': 218}