<commit_before>using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using Ical.Net.DataTypes;
using Ical.Net.ExtensionMethods;
using Ical.Net.General.Proxies;
using Ical.Net.Interfaces.Components;
using Ical.Net.Interfaces.DataTypes;
using Ical.Net.Interfaces.Evaluation;
using Ical.Net.Interfaces.General;
using Ical.Net.Interfaces.Serialization;
using Ical.Net.Serialization.iCalendar.Serializers;
using Ical.Net.Utility;

namespace Ical.Net
{
    public class Calendar : CalendarComponent, IGetOccurrencesTyped, IGetFreeBusy, IMergeable
    {
        public static CalendarCollection Load(string iCalendarString)
        {
            using (var reader = new StringReader(iCalendarString))
            {
                return LoadFromStream(reader);
            }
        }

        /// <summary>
        /// Loads an <see cref="Calendar"/> from an open stream.
        /// </summary>
        /// <param name="s">The stream from which to load the <see cref="Calendar"/> object</param>
        /// <returns>An <see cref="Calendar"/> object</returns>
        public new static CalendarCollection LoadFromStream(Stream s) => LoadFromStream(s, Encoding.UTF8, new CalendarSerializer());

        public static CalendarCollection LoadFromStream<T>(Stream s) where T : Calendar => LoadFromStream(typeof (T), s);

        public static CalendarCollection LoadFromStream(Type iCalendarType, Stream s)
        {
            ISerializer serializer = new CalendarSerializer();
            serializer.GetService<ISerializationSettings>().CalendarType = iCalendarType;
            return LoadFromStream(s, Encoding.UTF8, serializer);
        }

        public static CalendarCollection LoadFromStream(Type iCalendarType, Stream s, Encoding encoding)
        {
            ISerializer serializer = new CalendarSerializer();
            serializer.GetService<ISerializationSettings>().CalendarType = iCalendarType;
            return LoadFromStream(s, encoding, serializer);
        }

        public new static CalendarCollection LoadFromStream(Stream s, Encoding e, ISerializer serializer) => serializer.Deserialize(s, e) as CalendarCollection;

        public static CalendarCollection LoadFromStream(TextReader tr) => LoadFromStream(tr, new CalendarSerializer());

        public static CalendarCollection LoadFromStream<T>(TextReader tr) where T : Calendar => LoadFromStream(typeof (T), tr);

        public static CalendarCollection LoadFromStream(Type iCalendarType, TextReader tr)
        {
            ISerializer serializer = new CalendarSerializer();
            serializer.GetService<ISerializationSettings>().CalendarType = iCalendarType;
            return LoadFromStream(tr, serializer);
        }

        public static CalendarCollection LoadFromStream(TextReader tr, ISerializer serializer)
        {
            var text = tr.ReadToEnd();
            var ms = new MemoryStream(Encoding.UTF8.GetBytes(text));
            return LoadFromStream(ms, Encoding.UTF8, serializer);
        }<commit_msg>IN PROGRESS CHANGE REBASE LATER<commit_after>using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using Ical.Net.DataTypes;
using Ical.Net.ExtensionMethods;
using Ical.Net.General.Proxies;
using Ical.Net.Interfaces.Components;
using Ical.Net.Interfaces.DataTypes;
using Ical.Net.Interfaces.Evaluation;
using Ical.Net.Interfaces.General;
using Ical.Net.Interfaces.Serialization;
using Ical.Net.Serialization;
using Ical.Net.Serialization.iCalendar.Serializers;
using Ical.Net.Utility;

namespace Ical.Net
{
    public class Calendar : CalendarComponent, IGetOccurrencesTyped, IGetFreeBusy, IMergeable
    {
        public static CalendarCollection Load(string iCalendarString)
            => SimpleDeserializer.Default.Deserialize(new StringReader(iCalendarString)).Cast<CalendarCollection>().FirstOrDefault();

        /// <summary>
        /// Loads an <see cref="Calendar"/> from an open stream.
        /// </summary>
        /// <param name="s">The stream from which to load the <see cref="Calendar"/> object</param>
        /// <returns>An <see cref="Calendar"/> object</returns>
        public new static CalendarCollection LoadFromStream(Stream s)
            => SimpleDeserializer.Default.Deserialize(new StreamReader(s)).Cast<CalendarCollection>().FirstOrDefault();

        public static CalendarCollection LoadFromStream<T>(Stream s) where T : Calendar => LoadFromStream(typeof (T), s);

        public static CalendarCollection LoadFromStream(Type iCalendarType, Stream s)
            => SimpleDeserializer.Default.Deserialize(new StreamReader(s)).Cast<CalendarCollection>().FirstOrDefault();

        public static CalendarCollection LoadFromStream(Type iCalendarType, Stream s, Encoding encoding)
            => SimpleDeserializer.Default.Deserialize(new StreamReader(s, encoding)).Cast<CalendarCollection>().FirstOrDefault();

        public new static CalendarCollection LoadFromStream(Stream s, Encoding e, ISerializer serializer)
        {
            var foo = new StreamReader(s, e);
            return SimpleDeserializer.Default.Deserialize(foo).Cast<CalendarCollection>().FirstOrDefault();
            //return serializer.Deserialize(s, e) as CalendarCollection;
        }

        public static CalendarCollection LoadFromStream(TextReader tr) => LoadFromStream(tr, new CalendarSerializer());

        public static CalendarCollection LoadFromStream<T>(TextReader tr) where T : Calendar => LoadFromStream(typeof (T), tr);

        public static CalendarCollection LoadFromStream(Type iCalendarType, TextReader tr)
            => SimpleDeserializer.Default.Deserialize(tr).Cast<CalendarCollection>().FirstOrDefault();

        public static CalendarCollection LoadFromStream(TextReader tr, ISerializer serializer)
        {
            var deserialized = SimpleDeserializer.Default.Deserialize(tr);
            return SimpleDeserializer.Default.Deserialize(tr).Cast<CalendarCollection>().FirstOrDefault();
            //var text = tr.ReadToEnd();
            //var ms = new MemoryStream(Encoding.UTF8.GetBytes(text));
            return LoadFromStream(ms, Encoding.UTF8, serializer);
        }
{'fraction_non_alphanumeric': 0.09619971378597551, 'fraction_numerical': 0.0009540467482906663, 'mean_word_length': 3.604685212298682, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 48, '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': '3504438', 'n_tokens_mistral': 1639, 'n_tokens_neox': 1596, 'n_words': 393}