<commit_before>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using Umbraco.Core.Logging;

namespace Jumoo.uSync.Core.Extensions
{
    public static class XElementTrackerExtension
    {
        internal static XElement GetLocalizeduSyncElement(this XElement node)
        {
            if (node == null)
                return null;
            XElement copy = new XElement(node);

            // strip ids and stuff.
            var preVals = copy.Element("PreValues");
            if (preVals != null && preVals.HasElements)
            {
                foreach (var preVal in preVals.Elements("PreValue"))
                {
                    preVal.SetAttributeValue("Id", "");
                }
            }

            // take out any keys? 
            // we might not want to do this, as 
            // keys are something we can set
            /* 
            foreach(var key in copy.Descendants("Key"))
            {
                key.Remove();
            }
            */

            // in content types we remove Definition for comparision, because for 
            // custom types it can change. 
            if (copy.Element("GenericProperties") != null)
            {
                foreach (var defId in copy.Element("GenericProperties").Descendants("Definition"))
                {
                    defId.Value = "";
                }
            }

            var nodes = copy.Element("Nodes");
            if (nodes != null)
                nodes.Remove();

            var tabs = copy.Element("Tab");
            if (tabs != null && tabs.HasElements)
            {
                foreach (var tab in tabs.Elements("Tab"))
                {
                    if (tab.Element("Id") != null)
                        tab.Element("Id").Remove();
                }
            }

            if (copy.Name.LocalName == "Language" && copy.Attribute("Id") != null)
            {
                copy.Attribute("Id").Remove();
            }

            if (copy.Name.LocalName == "DictionaryItem")
            {<commit_msg>don't blank defID when doing check #126 #127<commit_after>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using Umbraco.Core.Logging;

namespace Jumoo.uSync.Core.Extensions
{
    public static class XElementTrackerExtension
    {
        internal static XElement GetLocalizeduSyncElement(this XElement node)
        {
            if (node == null)
                return null;
            XElement copy = new XElement(node);

            // strip ids and stuff.
            var preVals = copy.Element("PreValues");
            if (preVals != null && preVals.HasElements)
            {
                foreach (var preVal in preVals.Elements("PreValue"))
                {
                    preVal.SetAttributeValue("Id", "");
                }
            }

            // take out any keys? 
            // we might not want to do this, as 
            // keys are something we can set
            /* 
            foreach(var key in copy.Descendants("Key"))
            {
                key.Remove();
            }
            */

            // in content types we remove Definition for comparision, because for 
            // custom types it can change. 

            // 7.3.3. update - don't do this now, as it means you can miss some changes.
            // and everything is guids so less faulse positives. in later umbraco v's
            // 
            //if (copy.Element("GenericProperties") != null)
            //{
            //    foreach (var defId in copy.Element("GenericProperties").Descendants("Definition"))
            //    {
            //        defId.Value = "";
            //    }
            //}

            var nodes = copy.Element("Nodes");
            if (nodes != null)
                nodes.Remove();

            var tabs = copy.Element("Tab");
            if (tabs != null && tabs.HasElements)
            {
                foreach (var tab in tabs.Elements("Tab"))
                {
                    if (tab.Element("Id") != null)
                        tab.Element("Id").Remove();
                }
            }

            if (copy.Name.LocalName == "Language" && copy.Attribute("Id") != null)
            {
                copy.Attribute("Id").Remove();
            }

            if (copy.Name.LocalName == "DictionaryItem")
            {
{'fraction_non_alphanumeric': 0.10878480466220591, 'fraction_numerical': 0.0019425857975393912, 'mean_word_length': 1.3404040404040405, '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': '4149692', 'n_tokens_mistral': 1193, 'n_tokens_neox': 1122, 'n_words': 303}