<commit_before>﻿//-----------------------------------------------------------------------
// <copyright file="StringExtensions.cs" company="Rollins, Inc.">
//     Copyright © Rollins, Inc. 
// </copyright>
//-----------------------------------------------------------------------
namespace Rolcore.IO
{
    using System;
    using System.Diagnostics.Contracts;
    using System.IO;

    /// <summary>
    /// Extension methods for <see cref="string"/>.
    /// </summary>
    public static class StringExtensions
    {
        /// <summary>
        /// Converts the specified string to a <see cref="TextReader"/>.
        /// </summary>
        /// <param name="s">Specifies the string to convert.</param>
        /// <returns>A <see cref="TextReader"/> that reads the specified string.</returns>
        public static TextReader ToTextReader(this string s)
        {
            return new StringReader(s);
        }

        public static Stream ToStream(this string s)
        {
            Contract.Requires<ArgumentNullException>(s != null, "s is null");

            var result = new MemoryStream();
            var writer = new StreamWriter(result);

            writer.Write(s);
            writer.Flush();

            result.Position = 0;
            
            return result;
        }
    }
}<commit_msg>Comment<commit_after>﻿//-----------------------------------------------------------------------
// <copyright file="StringExtensions.cs" company="Rollins, Inc.">
//     Copyright © Rollins, Inc. 
// </copyright>
//-----------------------------------------------------------------------
namespace Rolcore.IO
{
    using System;
    using System.Diagnostics.Contracts;
    using System.IO;

    /// <summary>
    /// Extension methods for <see cref="string"/>.
    /// </summary>
    public static class StringExtensions
    {
        /// <summary>
        /// Converts the specified string to a <see cref="TextReader"/>.
        /// </summary>
        /// <param name="s">Specifies the string to convert.</param>
        /// <returns>A <see cref="TextReader"/> that reads the specified string.</returns>
        public static TextReader ToTextReader(this string s)
        {
            return new StringReader(s);
        }

        public static Stream ToStream(this string s)
        {
            Contract.Requires<ArgumentNullException>(s != null, "s is null");

            var result = new MemoryStream();
            var writer = new StreamWriter(result);

            writer.Write(s);
            writer.Flush();

            result.Position = 0;
            
            return result;
        } // Tested
    }
}
{'fraction_non_alphanumeric': 0.22424242424242424, 'fraction_numerical': 0.0007575757575757576, 'mean_word_length': 1.381424706943192, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, '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': '7301042', 'n_tokens_mistral': 628, 'n_tokens_neox': 616, 'n_words': 175}