<commit_before><?php
$translations = array(
    'A fast and open replacement for Windows and OS X' => 'Un remplaçant rapide et ouvert pour Windows et OS X',
    'Download Freya Beta' => 'Télécharger Freya Beta'
);

function translate_html($input) {
    global $translations;

    $output = '';

    $inTagContents = false;
    $tagContents = '';
    for ($i = 0; $i < strlen($input); $i++) {
        $char = $input[$i];

        if (!$inTagContents && $char == '>') {
            $inTagContents = true;
            $tagContents = '';
        }
        if ($inTagContents && $char == '<') {
            $inTagContents = false;

            if (isset($translations[$tagContents])) {
                $tagContents = $translations[$tagContents];
            }
            $output .= $tagContents;

            $tagContents = '';
        }

        if (!$inTagContents || $char == '>') {
            $output .= $char;
        } else {
            $tagContents .= $char;
        }
    }

    return $output;
}<commit_msg>Adds tag name support, first step to support attributes<commit_after><?php
$translations = array(
    'A fast and open replacement for Windows and OS X' => 'Un remplaçant rapide et ouvert pour Windows et OS X',
    'Download Freya Beta' => 'Télécharger Freya Beta'
);

function translate_html($input) {
    global $translations;

    $output = '';

    $inTag = false;
    $tagContents = '';
    $inTagName = false;
    $tagName = '';
    for ($i = 0; $i < strlen($input); $i++) {
        $char = $input[$i];

        if ($inTag && $char == '>') {
            $inTag = false;
            $inTagName = false;
            $tagContents = '';
        }
        if (!$inTag && $char == '<') {
            $inTag = true;
            $inTagName = true;
            $tagName = '';

            if (isset($translations[$tagContents])) {
                $tagContents = $translations[$tagContents];
            }
            $output .= $tagContents;

            $tagContents = '';
        }
        if ($inTagName && $char == ' ') {
            $inTagName = false;
        }

        if ($inTagName && $char != '<') {
            $tagName .= $char;
        }
        if ($inTag || $char == '>') {
            $output .= $char;
        } else {
            $tagContents .= $char;
        }
    }

    return $output.implode(', ', $tags);
}
{'fraction_non_alphanumeric': 0.161400512382579, 'fraction_numerical': 0.0008539709649871904, 'mean_word_length': 1.7403508771929825, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '874552', 'n_tokens_mistral': 714, 'n_tokens_neox': 701, 'n_words': 173}