<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
using UnityEngine;
using UnityEditor;


public class AssetsReporterUtils{
	public static StringBuilder AddJsonObject(StringBuilder sb, string key, string val)
	{
		sb.Append(key).Append(":\"").Append(val).Append('"');
		return sb;
	}
	public static StringBuilder AddJsonObjectArray(StringBuilder sb, string key, string[] arr)
	{
		sb.Append(key).Append(":[");
		bool isFirst = true;
		if (arr != null)
		{
			foreach (var val in arr)
			{
				if (isFirst) { isFirst = false; }
				else { sb.Append(','); }
				sb.Append('"').Append(val).Append('"');
			}
		}
		sb.Append("]");
		return sb;
	}
	public static StringBuilder AddJsonObject(StringBuilder sb, string key, float val)
	{
		sb.Append(key).Append(":\"").Append(val).Append('"');
		return sb;
	}
	public static StringBuilder AddJsonObject(StringBuilder sb, string key, bool val)
	{
		sb.Append(key).Append(":");
		if (val)
		{
			sb.Append("true");
		}
		else
		{
			sb.Append("false");
		}
		return sb;
	}
	public static StringBuilder AddJsonObject(StringBuilder sb, string key, int val)
	{
		sb.Append(key).Append(":").Append(val);
		return sb;
	}
	public static void AddCountVarObject<T>(StringBuilder sb, string varname, Dictionary<T, int> set)
	{
		sb.Append(varname).Append("=[");
		bool isFirst = true;
		foreach (var format in set)
		{
			if (isFirst)
			{
				isFirst = false;
			}
			else
			{
				sb.Append(',');
			}
			sb.Append("{val:");
			sb.Append('"').Append(format.Key.ToString()).Append('"');
			sb.Append(",cnt:").Append('"').Append(format.Value).Append('"');
			sb.Append("}");
		}
		sb.Append("];\n");
	}
	public static bool IsPathMatch(string path, List<string> list)
	{
		if (list == null)
		{
			return false;
		}
		foreach (var pattern in list)
		{
			Regex reg = new Regex(pattern, RegexOptions.IgnoreCase | RegexOptions.Singleline);
			if (reg.IsMatch(path))
			{
				return true;
			}
		}
		return false;
	}

	public static void AddCountDictionary<T>(Dictionary<T, int> dict, T key)
	{
		if (!dict.ContainsKey(key))
		{
			dict.Add(key, 1);
			return;
		}
		dict[key] += 1;
	}
	public static void AddCurrenTimeVar(StringBuilder sb)
	{
		var now = DateTime.Now;
		sb.Append("g_report_at=\"");
		sb.Append(now.Year).Append("-").Append( string.Format("{0:D2}",now.Month)).Append("-").Append(string.Format("{0:D2}",now.Day)).Append(" ");
		sb.Append(string.Format("{0:D2}", now.Hour)).Append(":").Append(string.Format("{0:D2}", now.Minute)).Append(":").Append(string.Format("{0:D2}", now.Second));
		sb.Append("\";\n");<commit_msg>English style dat<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
using UnityEngine;
using UnityEditor;


public class AssetsReporterUtils{
	public static StringBuilder AddJsonObject(StringBuilder sb, string key, string val)
	{
		sb.Append(key).Append(":\"").Append(val).Append('"');
		return sb;
	}
	public static StringBuilder AddJsonObjectArray(StringBuilder sb, string key, string[] arr)
	{
		sb.Append(key).Append(":[");
		bool isFirst = true;
		if (arr != null)
		{
			foreach (var val in arr)
			{
				if (isFirst) { isFirst = false; }
				else { sb.Append(','); }
				sb.Append('"').Append(val).Append('"');
			}
		}
		sb.Append("]");
		return sb;
	}
	public static StringBuilder AddJsonObject(StringBuilder sb, string key, float val)
	{
		sb.Append(key).Append(":\"").Append(val).Append('"');
		return sb;
	}
	public static StringBuilder AddJsonObject(StringBuilder sb, string key, bool val)
	{
		sb.Append(key).Append(":");
		if (val)
		{
			sb.Append("true");
		}
		else
		{
			sb.Append("false");
		}
		return sb;
	}
	public static StringBuilder AddJsonObject(StringBuilder sb, string key, int val)
	{
		sb.Append(key).Append(":").Append(val);
		return sb;
	}
	public static void AddCountVarObject<T>(StringBuilder sb, string varname, Dictionary<T, int> set)
	{
		sb.Append(varname).Append("=[");
		bool isFirst = true;
		foreach (var format in set)
		{
			if (isFirst)
			{
				isFirst = false;
			}
			else
			{
				sb.Append(',');
			}
			sb.Append("{val:");
			sb.Append('"').Append(format.Key.ToString()).Append('"');
			sb.Append(",cnt:").Append('"').Append(format.Value).Append('"');
			sb.Append("}");
		}
		sb.Append("];\n");
	}
	public static bool IsPathMatch(string path, List<string> list)
	{
		if (list == null)
		{
			return false;
		}
		foreach (var pattern in list)
		{
			Regex reg = new Regex(pattern, RegexOptions.IgnoreCase | RegexOptions.Singleline);
			if (reg.IsMatch(path))
			{
				return true;
			}
		}
		return false;
	}

	public static void AddCountDictionary<T>(Dictionary<T, int> dict, T key)
	{
		if (!dict.ContainsKey(key))
		{
			dict.Add(key, 1);
			return;
		}
		dict[key] += 1;
	}
	public static void AddCurrenTimeVar(StringBuilder sb)
	{
		var now = DateTime.Now;
		sb.Append("g_report_at=\"");
        sb.Append(now.ToString());
		sb.Append("\";\n");
{'fraction_non_alphanumeric': 0.17904274177663976, 'fraction_numerical': 0.002757533976757928, 'mean_word_length': 3.8500477554918815, 'pattern_counts': {'":': 12, '<': 13, '<?xml version=': 0, '>': 13, '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': '7657007', 'n_tokens_mistral': 2008, 'n_tokens_neox': 1793, 'n_words': 382}