<commit_before>#region Disclaimer/Info
///////////////////////////////////////////////////////////////////////////////////////////////////
// Subtext WebLog
// 
// Subtext is an open source weblog system that is a fork of the .TEXT
// weblog system.
//
// For updated news and information please visit http://subtextproject.com/
// Subtext is hosted at SourceForge at http://sourceforge.net/projects/subtext
// The development mailing list is at <EMAIL> 
//
// This project is licensed under the BSD license.  See the License.txt file for more information.
///////////////////////////////////////////////////////////////////////////////////////////////////
#endregion

using System;
using System.Collections;
using System.IO;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Caching;
using Subtext.Framework.Configuration;

namespace Subtext.Framework.Util
{
	/// <summary>
	/// Borrowed From Rob's Forum Code :) <- This is a joke :) <- Again...I will stop now
	/// </summary>
	public class Transform
	{
		public static string EmoticonTransforms (string formattedPost) 
		{
			// Load the emoticon transform table
			//
			ArrayList emoticonTxTable = LoadTransformFile("emoticons.txt");

			// Do the transforms
			//
			return PerformUserTransforms(formattedPost, emoticonTxTable);
		}

		static string PerformUserTransforms(string stringToTransform, ArrayList userDefinedTransforms) 
		{
			if(userDefinedTransforms == null)
				return stringToTransform;

			int iLoop = 0;	
			string host = Config.CurrentBlog.RootUrl;
			while (iLoop < userDefinedTransforms.Count) 
			{		
				// Special work for anchors
				stringToTransform = Regex.Replace(stringToTransform, userDefinedTransforms[iLoop].ToString(), string.Format(userDefinedTransforms[iLoop+1].ToString(),host), RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Multiline);

				iLoop += 2;
			}
<commit_msg>[FIX: 1443314 Emoticons File Not Found Handled Gracefully]<commit_after>#region Disclaimer/Info
///////////////////////////////////////////////////////////////////////////////////////////////////
// Subtext WebLog
// 
// Subtext is an open source weblog system that is a fork of the .TEXT
// weblog system.
//
// For updated news and information please visit http://subtextproject.com/
// Subtext is hosted at SourceForge at http://sourceforge.net/projects/subtext
// The development mailing list is at <EMAIL> 
//
// This project is licensed under the BSD license.  See the License.txt file for more information.
///////////////////////////////////////////////////////////////////////////////////////////////////
#endregion

using System;
using System.Collections;
using System.IO;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Caching;
using log4net;
using Subtext.Framework.Logging;
using Subtext.Framework.Configuration;

namespace Subtext.Framework.Util
{
	/// <summary>
	/// Class used to provide various transforms such as the 
	/// Emoticon transforms.
	/// </summary>
	public sealed class Transform
	{
		private static ILog Log = new Log();
		private Transform() {}

		/// <summary>
		/// Transforms emoticons into image references based on the 
		/// settings within the emoticons.txt file in the webroot.
		/// </summary>
		/// <param name="formattedPost">The formatted post.</param>
		/// <returns></returns>
		public static string EmoticonTransforms(string formattedPost) 
		{
			try
			{
				ArrayList emoticonTxTable = LoadTransformFile("emoticons.txt");
				return PerformUserTransforms(formattedPost, emoticonTxTable);
			}
			catch(System.IO.IOException e)
			{
				Log.Warn("Missing an emoticons.txt file in the webroot. Please download it from <a href=\"http://haacked.com/images/emoticons.zip\" title=\"Emoticons file\">here</a>.", e);
				return formattedPost;
			}
		}

		static string PerformUserTransforms(string stringToTransform, ArrayList userDefinedTransforms) 
		{
			if(userDefinedTransforms == null)
				return stringToTransform;

			int iLoop = 0;	
			string host = Config.CurrentBlog.RootUrl;
			while (iLoop < userDefinedTransforms.Count) 
			{		
				// Special work for anchors
				stringToTransform = Regex.Replace(stringToTransform, userDefinedTransforms[iLoop].ToString(), string.Format(userDefinedTransforms[iLoop+1].ToString(),host), RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Multiline);

				iLoop += 2;
			}

{'fraction_non_alphanumeric': 0.1837800999545661, 'fraction_numerical': 0.0031803725579282144, 'mean_word_length': 2.609016393442623, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4327005', 'n_tokens_mistral': 1305, 'n_tokens_neox': 1158, 'n_words': 341}