<commit_before><?php
/**
 *  Base include file for SimpleTest.
 *  @package    SimpleTest
 *  @subpackage WebTester
 *  @version    $Id$
 */

/**#@+
 * include SimpleTest files
 */
require_once(dirname(__FILE__) . '/page.php');
require_once(dirname(__FILE__) . '/encoding.php');
/**#@-*/

/**
 *    Creates tags and widgets given HTML tag
 *    attributes.
 *    @package SimpleTest
 *    @subpackage WebTester
 */
class SimpleTagBuilder {

    /**
     *    Factory for the tag objects. Creates the
     *    appropriate tag object for the incoming tag name
     *    and attributes.
     *    @param string $name        HTML tag name.
     *    @param hash $attributes    Element attributes.
     *    @return SimpleTag          Tag object.
     *    @access public
     */
    function createTag($name, $attributes) {
        static $map = array(
                'a' => 'SimpleAnchorTag',
                'title' => 'SimpleTitleTag',
                'base' => 'SimpleBaseTag',
                'button' => 'SimpleButtonTag',
                'textarea' => 'SimpleTextAreaTag',
                'option' => 'SimpleOptionTag',
                'label' => 'SimpleLabelTag',
                'form' => 'SimpleFormTag',
                'frame' => 'SimpleFrameTag');
        $attributes = $this->keysToLowerCase($attributes);
        if (array_key_exists($name, $map)) {
            $tag_class = $map[$name];
            return new $tag_class($attributes);
        } elseif ($name == 'select') {
            return $this->createSelectionTag($attributes);
        } elseif ($name == 'input') {
            return $this->createInputTag($attributes);
        }
        return new SimpleTag($name, $attributes);
    }

    /**
     *    Factory for selection fields.
     *    @param hash $attributes    Element attributes.
     *    @return SimpleTag          Tag object.
     *    @access protected
     */
    protected function createSelectionTag($attributes) {
        if (isset($attributes['multiple'])) {
            return new MultipleSelectionTag($attributes);
        }
        return new SimpleSelectionTag($attributes);
    }

    /**
     *    Factory for input tags.
     *    @param hash $attributes    Element attributes.
     *    @return SimpleTag          Tag object.
     *    @access protected
     */
    protected function createInputTag($attributes) {
        if (! isset($attributes['type'])) {
            return new SimpleTextTag($attributes);
        }
        $type = strtolower(trim($attributes['type']));
        $map = array(
            'submit'         => 'SimpleSubmitTag',
            'image'          => 'SimpleImageSubmitTag',
            'checkbox'       => 'SimpleCheckboxTag',
            'radio'          => 'SimpleRadioButtonTag',
            'text'           => 'SimpleTextTag',
            'hidden'         => 'SimpleTextTag',
            'password'       => '<PASSWORD>',
            'file'           => 'SimpleUploadTag',
            // HTML 5 new input types
            'color'          => 'SimpleTextTag',
            'date'           => 'SimpleTextTag',
            'datetime'       => 'SimpleTextTag',
            'datetime-local' => 'SimpleTextTag',
            'email'          => 'SimpleTextTag',
            'month'          => 'SimpleTextTag',
            'number'         => 'SimpleTextTag',
            'ranje'          => 'SimpleTextTag',
            'search'         => 'SimpleTextTag',
            'tel'            => 'SimpleTextTag',
            'time'           => 'SimpleTextTag',
            'url'            => 'SimpleTextTag',
            'weel'           => 'SimpleTextTag'
        );

        if (array_key_exists($type, $map)) {
            $tag_class = $map[$type];
            return new $tag_class($attributes);
        }
        return false;
    }

    /**
     *    Make the keys lower case for case insensitive look-ups.
     *    @param hash $map   Hash to convert.
     *    @return hash       Unchanged values, but keys lower case.
     *    @access private
     */
    protected function keysToLowerCase($map) {
        $lower = array();
        foreach ($map as $key => $value) {
            $lower[strtolower($key)] = $value;
        }
        return $lower;
    }
}

/**
 *    HTML or XML tag.
 *    @package SimpleTest
 *    @subpackage WebTester
 */
class SimpleTag {<commit_msg>fix typos in the names of the new HTML5 input types<commit_after><?php
/**
 *  Base include file for SimpleTest.
 *  @package    SimpleTest
 *  @subpackage WebTester
 *  @version    $Id$
 */

/**#@+
 * include SimpleTest files
 */
require_once(dirname(__FILE__) . '/page.php');
require_once(dirname(__FILE__) . '/encoding.php');
/**#@-*/

/**
 *    Creates tags and widgets given HTML tag
 *    attributes.
 *    @package SimpleTest
 *    @subpackage WebTester
 */
class SimpleTagBuilder {

    /**
     *    Factory for the tag objects. Creates the
     *    appropriate tag object for the incoming tag name
     *    and attributes.
     *    @param string $name        HTML tag name.
     *    @param hash $attributes    Element attributes.
     *    @return SimpleTag          Tag object.
     *    @access public
     */
    function createTag($name, $attributes) {
        static $map = array(
                'a' => 'SimpleAnchorTag',
                'title' => 'SimpleTitleTag',
                'base' => 'SimpleBaseTag',
                'button' => 'SimpleButtonTag',
                'textarea' => 'SimpleTextAreaTag',
                'option' => 'SimpleOptionTag',
                'label' => 'SimpleLabelTag',
                'form' => 'SimpleFormTag',
                'frame' => 'SimpleFrameTag');
        $attributes = $this->keysToLowerCase($attributes);
        if (array_key_exists($name, $map)) {
            $tag_class = $map[$name];
            return new $tag_class($attributes);
        } elseif ($name == 'select') {
            return $this->createSelectionTag($attributes);
        } elseif ($name == 'input') {
            return $this->createInputTag($attributes);
        }
        return new SimpleTag($name, $attributes);
    }

    /**
     *    Factory for selection fields.
     *    @param hash $attributes    Element attributes.
     *    @return SimpleTag          Tag object.
     *    @access protected
     */
    protected function createSelectionTag($attributes) {
        if (isset($attributes['multiple'])) {
            return new MultipleSelectionTag($attributes);
        }
        return new SimpleSelectionTag($attributes);
    }

    /**
     *    Factory for input tags.
     *    @param hash $attributes    Element attributes.
     *    @return SimpleTag          Tag object.
     *    @access protected
     */
    protected function createInputTag($attributes) {
        if (! isset($attributes['type'])) {
            return new SimpleTextTag($attributes);
        }
        $type = strtolower(trim($attributes['type']));
        $map = array(
            'submit'         => 'SimpleSubmitTag',
            'image'          => 'SimpleImageSubmitTag',
            'checkbox'       => 'SimpleCheckboxTag',
            'radio'          => 'SimpleRadioButtonTag',
            'text'           => 'SimpleTextTag',
            'hidden'         => 'SimpleTextTag',
            'password'       => '<PASSWORD>',
            'file'           => 'SimpleUploadTag',
            // HTML 5 new input types
            'color'          => 'SimpleTextTag',
            'date'           => 'SimpleTextTag',
            'datetime'       => 'SimpleTextTag',
            'datetime-local' => 'SimpleTextTag',
            'email'          => 'SimpleTextTag',
            'month'          => 'SimpleTextTag',
            'number'         => 'SimpleTextTag',
            'range'          => 'SimpleTextTag',
            'search'         => 'SimpleTextTag',
            'tel'            => 'SimpleTextTag',
            'time'           => 'SimpleTextTag',
            'url'            => 'SimpleTextTag',
            'week'           => 'SimpleTextTag'
        );

        if (array_key_exists($type, $map)) {
            $tag_class = $map[$type];
            return new $tag_class($attributes);
        }
        return false;
    }

    /**
     *    Make the keys lower case for case insensitive look-ups.
     *    @param hash $map   Hash to convert.
     *    @return hash       Unchanged values, but keys lower case.
     *    @access private
     */
    protected function keysToLowerCase($map) {
        $lower = array();
        foreach ($map as $key => $value) {
            $lower[strtolower($key)] = $value;
        }
        return $lower;
    }
}

/**
 *    HTML or XML tag.
 *    @package SimpleTest
 *    @subpackage WebTester
 */
class SimpleTag {
{'fraction_non_alphanumeric': 0.1287445689458038, 'fraction_numerical': 0.0003430139492339355, 'mean_word_length': 1.665955501371533, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 73, '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': '542464', 'n_tokens_mistral': 2317, 'n_tokens_neox': 2304, 'n_words': 558}