<commit_before>﻿namespace Mappy.Services
{
    using System.IO;

    using Mappy.Collections;
    using Mappy.Data;
    using Mappy.IO;
    using Mappy.Models;

    using TAUtil.Hpi;
    using TAUtil.Sct;
    using TAUtil.Tdf;
    using TAUtil.Tnt;

    public class MapLoadingService
    {
        private readonly SectionFactory sectionFactory = new SectionFactory();

        private readonly MapModelFactory mapModelFactory = new MapModelFactory();

        public UndoableMapModel CreateMap(int width, int height)
        {
            var map = new MapModel(width, height);
            GridMethods.Fill(map.Tile.TileGrid, Globals.DefaultTile);
            return new UndoableMapModel(map, null, false);
        }

        public UndoableMapModel CreateFromSct(string filename)
        {
            MapTile t;
            using (var s = new SctReader(filename))
            {
                t = this.sectionFactory.TileFromSct(s);
            }

            return new UndoableMapModel(new MapModel(t), filename, true);
        }

        public UndoableMapModel CreateFromTnt(string filename)
        {
            MapModel m;

            var otaFileName = filename.Substring(0, filename.Length - 4) + ".ota";
            if (File.Exists(otaFileName))
            {
                TdfNode attrs;
                using (var ota = File.OpenRead(otaFileName))
                {
                    attrs = TdfNode.LoadTdf(ota);
                }

                using (var s = new TntReader(filename))
                {
                    m = this.mapModelFactory.FromTntAndOta(s, attrs);
                }
            }
            else
            {
                using (var s = new TntReader(filename))
                {
                    m = this.mapModelFactory.FromTnt(s);
                }
            }

            return new UndoableMapModel(m, filename, false);
        }

        public UndoableMapModel CreateFromHpi(string hpipath, string mappath, bool readOnly = false)
        {
            MapModel m;

            using (HpiReader hpi = new HpiReader(hpipath))
            {
                string otaPath = HpiPath.ChangeExtension(mappath, ".ota");

                TdfNode n;

                using (var ota = hpi.ReadTextFile(otaPath))
                {
                    n = TdfNode.LoadTdf(ota);
                }

                using (var s = new TntReader(hpi.ReadFile(mappath)))
                {
                    m = this.mapModelFactory.FromTntAndOta(s, n);
                }
            }

            return new UndoableMapModel(m, hpipath, readOnly);
        }
    }
}
<commit_msg>Replace default arguments with overload<commit_after>﻿namespace Mappy.Services
{
    using System.IO;

    using Mappy.Collections;
    using Mappy.Data;
    using Mappy.IO;
    using Mappy.Models;

    using TAUtil.Hpi;
    using TAUtil.Sct;
    using TAUtil.Tdf;
    using TAUtil.Tnt;

    public class MapLoadingService
    {
        private readonly SectionFactory sectionFactory = new SectionFactory();

        private readonly MapModelFactory mapModelFactory = new MapModelFactory();

        public UndoableMapModel CreateMap(int width, int height)
        {
            var map = new MapModel(width, height);
            GridMethods.Fill(map.Tile.TileGrid, Globals.DefaultTile);
            return new UndoableMapModel(map, null, false);
        }

        public UndoableMapModel CreateFromSct(string filename)
        {
            MapTile t;
            using (var s = new SctReader(filename))
            {
                t = this.sectionFactory.TileFromSct(s);
            }

            return new UndoableMapModel(new MapModel(t), filename, true);
        }

        public UndoableMapModel CreateFromTnt(string filename)
        {
            MapModel m;

            var otaFileName = filename.Substring(0, filename.Length - 4) + ".ota";
            if (File.Exists(otaFileName))
            {
                TdfNode attrs;
                using (var ota = File.OpenRead(otaFileName))
                {
                    attrs = TdfNode.LoadTdf(ota);
                }

                using (var s = new TntReader(filename))
                {
                    m = this.mapModelFactory.FromTntAndOta(s, attrs);
                }
            }
            else
            {
                using (var s = new TntReader(filename))
                {
                    m = this.mapModelFactory.FromTnt(s);
                }
            }

            return new UndoableMapModel(m, filename, false);
        }

        public UndoableMapModel CreateFromHpi(string hpipath, string mappath)
        {
            return this.CreateFromHpi(hpipath, mappath, false);
        }

        public UndoableMapModel CreateFromHpi(string hpipath, string mappath, bool readOnly)
        {
            MapModel m;

            using (HpiReader hpi = new HpiReader(hpipath))
            {
                string otaPath = HpiPath.ChangeExtension(mappath, ".ota");

                TdfNode n;

                using (var ota = hpi.ReadTextFile(otaPath))
                {
                    n = TdfNode.LoadTdf(ota);
                }

                using (var s = new TntReader(hpi.ReadFile(mappath)))
                {
                    m = this.mapModelFactory.FromTntAndOta(s, n);
                }
            }

            return new UndoableMapModel(m, hpipath, readOnly);
        }
    }
}

{'fraction_non_alphanumeric': 0.07809726659566915, 'fraction_numerical': 0.0007099751508697196, 'mean_word_length': 1.3342999171499585, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7468052', 'n_tokens_mistral': 1608, 'n_tokens_neox': 1474, 'n_words': 325}