<commit_before>﻿using System;
using System.Globalization;
using System.Text;
using Common.Logging;

namespace ToolKit.Xml
{
    /// <summary>
    /// This class contains two static methods to encode and decode text to be compatible with being
    /// put into an XML document
    /// </summary>
    public class XmlEncoder
    {
        private static ILog _log = LogManager.GetLogger<XmlEncoder>();

        /// <summary>
        /// Decodes a string to remove XML entity markups
        /// </summary>
        /// <param name="inputText">Input text containing entity markups</param>
        /// <returns>an decoded string</returns>
        public static string Decode(string inputText)
        {
            if (String.IsNullOrEmpty(inputText))
            {
                throw new ArgumentNullException(nameof(inputText));
            }

            // If the string doesn't have a & character, it doesn't have any entities.
            if (inputText.IndexOf('&') < 0)
            {
                return inputText;
            }

            // If the string contains a & but not a ;, it doesn't have any entities.
            if ((inputText.IndexOf('&') > -1) && (inputText.IndexOf(';') < 0))
            {
                return inputText;
            }

            var sb = new StringBuilder();

            for (var i = 0; i < inputText.Length; i++)
            {
                var ch = inputText[i];
                if (ch != '&')
                {
                    sb.AppendFormat("{0}", ch);
                    continue;
                }

                var endOfEntity = inputText.IndexOfAny(new char[] { ';', '&' }, i + 1);

                // If the end marker is not ; then ignore this "entity" and continue on
                if ((endOfEntity > 0) && (inputText[endOfEntity] == '&'))
                {
                    sb.AppendFormat("{0}", ch);<commit_msg>missed a nameOf in the XmlEncoder class<commit_after>﻿using System;
using System.Globalization;
using System.Text;
using Common.Logging;

namespace ToolKit.Xml
{
    /// <summary>
    /// This class contains two static methods to encode and decode text to be compatible with being
    /// put into an XML document
    /// </summary>
    public class XmlEncoder
    {
        private static ILog _log = LogManager.GetLogger<XmlEncoder>();

        /// <summary>
        /// Decodes a string to remove XML entity markups
        /// </summary>
        /// <param name="inputText">Input text containing entity markups</param>
        /// <returns>an decoded string</returns>
        public static string Decode(string inputText)
        {
            if (String.IsNullOrEmpty(inputText))
            {
                throw new ArgumentNullException("inputText");
            }

            // If the string doesn't have a & character, it doesn't have any entities.
            if (inputText.IndexOf('&') < 0)
            {
                return inputText;
            }

            // If the string contains a & but not a ;, it doesn't have any entities.
            if ((inputText.IndexOf('&') > -1) && (inputText.IndexOf(';') < 0))
            {
                return inputText;
            }

            var sb = new StringBuilder();

            for (var i = 0; i < inputText.Length; i++)
            {
                var ch = inputText[i];
                if (ch != '&')
                {
                    sb.AppendFormat("{0}", ch);
                    continue;
                }

                var endOfEntity = inputText.IndexOfAny(new char[] { ';', '&' }, i + 1);

                // If the end marker is not ; then ignore this "entity" and continue on
                if ((endOfEntity > 0) && (inputText[endOfEntity] == '&'))
                {
                    sb.AppendFormat("{0}", ch);
{'fraction_non_alphanumeric': 0.11789473684210526, 'fraction_numerical': 0.004210526315789474, 'mean_word_length': 1.5122273628552545, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 25, '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': '3187144', 'n_tokens_mistral': 1022, 'n_tokens_neox': 960, 'n_words': 307}