<commit_before>#!/usr/bin/env php
<?php

include("xmlstr_to_array.php");

function prettyPrint($title, $thing)
{
  echo "\n-- $title: ---------------------------------------------\n";
  print_r($thing);
  echo "\n";
}

$xmlstr = <<<EOD
  <tv>
    <show name="Family Guy">
      <dog>Brian</dog>
      <kid>Chris</kid>
      <kid>Meg</kid>
      <kid><![CDATA[<em>Stewie</em>]]></kid>
    </show>
    <show name="Edge Cases" zero="0" empty="">
      <empty></empty>
      <foo empty=""></foo>
      <zero>0</zero>
    </show>
  </tv>
EOD;

$expected = array(
  "show" => array(

    array(
      "dog" => "Brian",
      "kid" => array(
        "Chris",
        "Meg",
        "<em>Stewie</em>"
      ),
      "@attributes" => array( "name" => "Family Guy" )
    ),

    array(
      "empty" => array(),
      "foo" => array(
        "@attributes" => array( 
          "empty" => ""
        )
      ),
      "zero" => "0",
      "@attributes" => array( 
        "name" => "Edge Cases",
        "empty" => "",
        "zero" => "0"
      )
    )

  )
);

$result = xmlstr_to_array($xmlstr);


prettyPrint("Input", $xmlstr);
prettyPrint("Expected", $expected);
prettyPrint("Output", $result);
prettyPrint("Result", $result == $expected ? "SUCCESS :-)" : "FAILURE :-(");
<commit_msg>Updated test.sh to show the expected output after the code change.<commit_after>#!/usr/bin/env php
<?php

include("xmlstr_to_array.php");

function prettyPrint($title, $thing)
{
  echo "\n-- $title: ---------------------------------------------\n";
  print_r($thing);
  echo "\n";
}

$xmlstr = <<<EOD
  <tv>
    <show name="Family Guy">
      <dog type="beagle">Brian</dog>
      <kid>Chris</kid>
      <kid>Meg</kid>
      <kid><![CDATA[<em>Stewie</em>]]></kid>
    </show>
    <show name="Edge Cases" zero="0" empty="">
      <empty></empty>
      <foo empty=""></foo>
      <zero>0</zero>
    </show>
  </tv>
EOD;

$expected = array(
  "show" => array(

    array(
      "dog" => array(
      	array(
				"dog"=>"Brian",
				"@attributes" => array(
					"type"=>"beagle"
				)
			)
	  ),
      "kid" => array(
        "Chris",
        "Meg",
        "<em>Stewie</em>"
      ),
      "@attributes" => array( "name" => "Family Guy" )
    ),

    array(
      "empty" => array(),
      "foo" => array(
        "@attributes" => array( 
          "empty" => ""
        )
      ),
      "zero" => "0",
      "@attributes" => array( 
        "name" => "Edge Cases",
        "empty" => "",
        "zero" => "0"
      )
    )

  )
);

$result = xmlstr_to_array($xmlstr);


prettyPrint("Input", $xmlstr);
prettyPrint("Expected", $expected);
prettyPrint("Output", $result);
prettyPrint("Result", $result == $expected ? "SUCCESS :-)" : "FAILURE :-(");
{'fraction_non_alphanumeric': 0.2554208011760382, 'fraction_numerical': 0.002940095553105476, 'mean_word_length': 2.0379464285714284, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 84, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, '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': '6373309', 'n_tokens_mistral': 1021, 'n_tokens_neox': 962, 'n_words': 186}