<commit_before>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace TCC.Data
{
    public static class AbnormalityDatabase
    {
        public static Dictionary<uint, Abnormality> Abnormalities;
        public static void Load()
        {
            var f = File.OpenText(Environment.CurrentDirectory + "/resources/data/abnormalities.tsv");
            Abnormalities = new Dictionary<uint, Abnormality>();
            while (true)
            {
                var line = f.ReadLine();
                if (line == null) break;

                var s = line.Split('\t');

                var id = Convert.ToUInt32(s[0]);
                Enum.TryParse(s[1], out AbnormalityType t);
                var isShow = bool.Parse(s[2]);
                var isBuff = bool.Parse(s[3]);
                var infinity = bool.Parse(s[4]);
                var name = s[5];
                var tooltip = s[6].Replace("&#xA;", "\n");
                var iconName = s[7];

                var ab = new Abnormality(id, isShow, isBuff, infinity, t);
                ab.SetIcon(iconName);
                ab.SetInfo(name, tooltip);

                Abnormalities.Add(id, ab);
            }

        }
        public static void CheckIcons()
        {
            foreach (var abnorm in Abnormalities)
            {
                string filePath = Environment.CurrentDirectory + "/resources/images/" + abnorm.Value.IconName.Replace('.','/') + ".png";
                if (File.Exists(filePath))
                {
                    //Console.Write("\r[Icon Check] - Abnormality ID:{0} \t File name:{1} \t OK", abnorm.Value.Id, abnorm.Value.IconName);
                }
                else
                {
                    if(abnorm.Value.IconName != "" && !abnorm.Value.IconName.Contains("icon_ep"))
                    {
                        Console.WriteLine("[Icon Check] - File name:{1} \t Path:{0}", filePath, abnorm.Value.IconName);
                    }
                }
            }
        }
    }

    //public static class AbnormalityDatabaseOld
    //{
    //    public static Dictionary<uint ,Abnormality> Abnormalities;

    //    static List<XDocument> StrSheet_AbnormalityDocs;
    //    static List<XDocument> AbnormalityIconDataDocs;
    //    static List<XDocument> AbnormalityDataDocs;

    //    static void LoadFiles()
    //    {
    //        foreach (var f in Directory.EnumerateFiles(Environment.CurrentDirectory + @"/resources/database/StrSheet_Abnormality"))
    //        {
    //            var d = XDocument.Load(f);
    //            StrSheet_AbnormalityDocs.Add(d);
    //        }

    //        foreach (var f in Directory.EnumerateFiles(Environment.CurrentDirectory + @"/resources/database/AbnormalityIconData"))
    //        {
    //            var d = XDocument.Load(f);
    //            AbnormalityIconDataDocs.Add(d);
    //        }

    //        foreach (var f in Directory.EnumerateFiles(Environment.CurrentDirectory + @"/resources/database/Abnormality"))
    //        {
    //            var d = XDocument.Load(f);
    //            AbnormalityDataDocs.Add(d);
    //        }


    //    }
    //    static void ParseStrSheetAbnormalityDoc(XDocument doc)
    //    {
    //        foreach (XElement abn in doc.Descendants().Where(x => x.Name == "String"))
    //        {
    //            var id = Convert.ToUInt32(abn.Attribute("id").Value);
    //            string name = String.Empty;
    //            string toolTip = String.Empty;
    //            if(abn.Attributes().Any(x => x.Name == "name"))
    //            {
    //                name = abn.Attribute("name").Value;
    //            }
    //            if (abn.Attributes().Any(x => x.Name == "tooltip"))
    //            {
    //                toolTip = abn.Attribute("tooltip").Value;
    //            }

    //            //Abnormality ab = new Abnormality(id, name, toolTip);
    //            //Abnormalities.Add(id, ab);
    //            if (Abnormalities.TryGetValue(id, out Abnormality a))
    //            {
    //                a.SetInfo(name, toolTip);
    //            }

    //        }
    //    }
    //    static void ParseAbnormalityIconDoc(XDocument doc)
    //    {
    //        foreach (var s in doc.Descendants().Where(x => x.Name == "Icon"))
    //        {
    //            var id = Convert.ToUInt32(s.Attribute("abnormalityId").Value);
    //            string iconName = string.Empty;
    //            if(s.Attributes().Any(x => x.Name == "iconName"))
    //            {
    //                iconName = s.Attribute("iconName").Value;
    //            }

    //            if (Abnormalities.TryGetValue(id, out Abnormality a))
    //            {
    //                a.SetIcon(iconName);
    //            }
    //        }
    //    }
    //    static void ParseAbnormalityDataDoc(XDocument doc)
    //    {
    //        foreach (var a in doc.Descendants().Where(x => x.Name == "Abnormal"))
    //        {
    //            uint id = Convert.ToUInt32(a.Attribute("id").Value);
    //            bool isBuff = false;
    //            if(a.Attribute("isBuff").Value == "True")
    //            {
    //                isBuff = true;
    //            }
    //            bool isShow = true;
    //            if (a.Attribute("isShow").Value == "False")
    //            {
    //                isShow = false;
    //            }
    //            bool infinity = false;
    //            if (a.Attribute("infinity").Value == "True")
    //            {
    //                infinity = true;
    //            }
    //            int prop = Convert.ToInt32(a.Attribute("property").Value);

    //            Abnormality ab = new Abnormality(id, isBuff, isShow, infinity, prop);
    //            Abnormalities.Add(ab.Id, ab);



    //        }
    //    }
    //    public static void Populate()
    //    {
    //        Abnormalities = new Dictionary<uint, Abnormality>();
    //        StrSheet_AbnormalityDocs = new List<XDocument>();
    //        AbnormalityIconDataDocs = new List<XDocument>();
    //        AbnormalityDataDocs = new List<XDocument>();

    //        LoadFiles();

    //        foreach (var doc in AbnormalityDataDocs)
    //        {
    //            ParseAbnormalityDataDoc(doc);
    //        }
    //        foreach (var  doc in StrSheet_AbnormalityDocs)
    //        {
    //            ParseStrSheetAbnormalityDoc(doc);
    //        }
    //        foreach (var doc in AbnormalityIconDataDocs)
    //        {
    //            ParseAbnormalityIconDoc(doc);
    //        }

    //        StrSheet_AbnormalityDocs.Clear();
    //        AbnormalityIconDataDocs.Clear();
    //        AbnormalityDataDocs.Clear();
    //        var toBeRemovedList = new List<Abnormality>();
    //        foreach (var item in Abnormalities)
    //        {
    //            if(item.Value.Name == null)
    //            {
    //                toBeRemovedList.Add(item.Value);
    //            }
    //        }
    //        foreach (var item in toBeRemovedList)
    //        {
    //            Abnormalities.Remove(item.Id);
    //        }
    //    }

    //}
}
<commit_msg>added manual fix for Lakan's Soul World debuff<commit_after>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace TCC.Data
{
    public static class AbnormalityDatabase
    {
        public static Dictionary<uint, Abnormality> Abnormalities;
        public static void Load()
        {
            var f = File.OpenText(Environment.CurrentDirectory + "/resources/data/abnormalities.tsv");
            Abnormalities = new Dictionary<uint, Abnormality>();
            while (true)
            {
                var line = f.ReadLine();
                if (line == null) break;

                var s = line.Split('\t');

                var id = Convert.ToUInt32(s[0]);
                Enum.TryParse(s[1], out AbnormalityType t);
                var isShow = bool.Parse(s[2]);
                var isBuff = bool.Parse(s[3]);
                var infinity = bool.Parse(s[4]);
                var name = s[5];
                var tooltip = s[6].Replace("&#xA;", "\n");
                var iconName = s[7];

                //---add fixes here---//

                if(id == 78100006) //isBuff = true for lakan's souls world debuff (it's not supposed to make hp bar purple)
                {
                    isBuff = true;
                }

                //--------------------//
                var ab = new Abnormality(id, isShow, isBuff, infinity, t);
                ab.SetIcon(iconName);
                ab.SetInfo(name, tooltip);

                Abnormalities.Add(id, ab);
            }

        }
        public static void CheckIcons()
        {
            foreach (var abnorm in Abnormalities)
            {
                string filePath = Environment.CurrentDirectory + "/resources/images/" + abnorm.Value.IconName.Replace('.','/') + ".png";
                if (File.Exists(filePath))
                {
                    //Console.Write("\r[Icon Check] - Abnormality ID:{0} \t File name:{1} \t OK", abnorm.Value.Id, abnorm.Value.IconName);
                }
                else
                {
                    if(abnorm.Value.IconName != "" && !abnorm.Value.IconName.Contains("icon_ep"))
                    {
                        Console.WriteLine("[Icon Check] - File name:{1} \t Path:{0}", filePath, abnorm.Value.IconName);
                    }
                }
            }
        }
    }

    //public static class AbnormalityDatabaseOld
    //{
    //    public static Dictionary<uint ,Abnormality> Abnormalities;

    //    static List<XDocument> StrSheet_AbnormalityDocs;
    //    static List<XDocument> AbnormalityIconDataDocs;
    //    static List<XDocument> AbnormalityDataDocs;

    //    static void LoadFiles()
    //    {
    //        foreach (var f in Directory.EnumerateFiles(Environment.CurrentDirectory + @"/resources/database/StrSheet_Abnormality"))
    //        {
    //            var d = XDocument.Load(f);
    //            StrSheet_AbnormalityDocs.Add(d);
    //        }

    //        foreach (var f in Directory.EnumerateFiles(Environment.CurrentDirectory + @"/resources/database/AbnormalityIconData"))
    //        {
    //            var d = XDocument.Load(f);
    //            AbnormalityIconDataDocs.Add(d);
    //        }

    //        foreach (var f in Directory.EnumerateFiles(Environment.CurrentDirectory + @"/resources/database/Abnormality"))
    //        {
    //            var d = XDocument.Load(f);
    //            AbnormalityDataDocs.Add(d);
    //        }


    //    }
    //    static void ParseStrSheetAbnormalityDoc(XDocument doc)
    //    {
    //        foreach (XElement abn in doc.Descendants().Where(x => x.Name == "String"))
    //        {
    //            var id = Convert.ToUInt32(abn.Attribute("id").Value);
    //            string name = String.Empty;
    //            string toolTip = String.Empty;
    //            if(abn.Attributes().Any(x => x.Name == "name"))
    //            {
    //                name = abn.Attribute("name").Value;
    //            }
    //            if (abn.Attributes().Any(x => x.Name == "tooltip"))
    //            {
    //                toolTip = abn.Attribute("tooltip").Value;
    //            }

    //            //Abnormality ab = new Abnormality(id, name, toolTip);
    //            //Abnormalities.Add(id, ab);
    //            if (Abnormalities.TryGetValue(id, out Abnormality a))
    //            {
    //                a.SetInfo(name, toolTip);
    //            }

    //        }
    //    }
    //    static void ParseAbnormalityIconDoc(XDocument doc)
    //    {
    //        foreach (var s in doc.Descendants().Where(x => x.Name == "Icon"))
    //        {
    //            var id = Convert.ToUInt32(s.Attribute("abnormalityId").Value);
    //            string iconName = string.Empty;
    //            if(s.Attributes().Any(x => x.Name == "iconName"))
    //            {
    //                iconName = s.Attribute("iconName").Value;
    //            }

    //            if (Abnormalities.TryGetValue(id, out Abnormality a))
    //            {
    //                a.SetIcon(iconName);
    //            }
    //        }
    //    }
    //    static void ParseAbnormalityDataDoc(XDocument doc)
    //    {
    //        foreach (var a in doc.Descendants().Where(x => x.Name == "Abnormal"))
    //        {
    //            uint id = Convert.ToUInt32(a.Attribute("id").Value);
    //            bool isBuff = false;
    //            if(a.Attribute("isBuff").Value == "True")
    //            {
    //                isBuff = true;
    //            }
    //            bool isShow = true;
    //            if (a.Attribute("isShow").Value == "False")
    //            {
    //                isShow = false;
    //            }
    //            bool infinity = false;
    //            if (a.Attribute("infinity").Value == "True")
    //            {
    //                infinity = true;
    //            }
    //            int prop = Convert.ToInt32(a.Attribute("property").Value);

    //            Abnormality ab = new Abnormality(id, isBuff, isShow, infinity, prop);
    //            Abnormalities.Add(ab.Id, ab);



    //        }
    //    }
    //    public static void Populate()
    //    {
    //        Abnormalities = new Dictionary<uint, Abnormality>();
    //        StrSheet_AbnormalityDocs = new List<XDocument>();
    //        AbnormalityIconDataDocs = new List<XDocument>();
    //        AbnormalityDataDocs = new List<XDocument>();

    //        LoadFiles();

    //        foreach (var doc in AbnormalityDataDocs)
    //        {
    //            ParseAbnormalityDataDoc(doc);
    //        }
    //        foreach (var  doc in StrSheet_AbnormalityDocs)
    //        {
    //            ParseStrSheetAbnormalityDoc(doc);
    //        }
    //        foreach (var doc in AbnormalityIconDataDocs)
    //        {
    //            ParseAbnormalityIconDoc(doc);
    //        }

    //        StrSheet_AbnormalityDocs.Clear();
    //        AbnormalityIconDataDocs.Clear();
    //        AbnormalityDataDocs.Clear();
    //        var toBeRemovedList = new List<Abnormality>();
    //        foreach (var item in Abnormalities)
    //        {
    //            if(item.Value.Name == null)
    //            {
    //                toBeRemovedList.Add(item.Value);
    //            }
    //        }
    //        foreach (var item in toBeRemovedList)
    //        {
    //            Abnormalities.Remove(item.Id);
    //        }
    //    }

    //}
}

{'fraction_non_alphanumeric': 0.1380657327586207, 'fraction_numerical': 0.003502155172413793, 'mean_word_length': 1.2580596107055961, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 37, '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': '506762', 'n_tokens_mistral': 4329, 'n_tokens_neox': 4149, 'n_words': 747}