<commit_before>package rpg.text;

/**
 * ...
 * @author <NAME>
 */

class CmdParser
{
	private var rawText:String;

    private static var colorCodes = new ReadOnlyArray([0xFF0000, 0x00FF00, 0x0000FF]);
	
	public function new(rawText:String) 
	{
		this.rawText = rawText;
	}
    
    private function splitTokens():Array<String>
    {
        var r = ~/(((\\[CcS]\[[a-fA-F0-9]+\])*)(([\w\s!@?](\\n)*)+))/;
        var temp = rawText;
        var arrayTokens = new Array<String> ();
        while(r.match(temp))
        {
			//trace("Command Part: " + r.matched(2));
            //trace("Message Part: " + r.matched(4));
            //trace("Full Token: " + r.matched(1));
            arrayTokens.push(r.matched(1));
            temp = temp.substr(r.matchedPos().len);
        }
        return arrayTokens;
    }
	
	private function getTextColor(mText:String):Int
	{
		
		var r = ~/\\C\[([0-9]+)\]/;
		if (r.match(mText))
		{
            return colorCodes[Std.parseInt(r.matched(1))-1];
		}
            return 0;
	}
	
	private function getTextColorByHex(mText:String):Int
	{
		var r = ~/\\c\[([a-fA-F0-9]+)\]/;
		if (r.match(mText))
		{
			return Std.parseInt("0x"+r.matched(1));
		}
            return 0;
	}
	
	private function getTextSpeed(mText:String):Int
	{
		var r = ~/\\S\[([0-9]+)\]/;
		if (r.match(mText))
		{
			return Std.parseInt(r.matched(1));
		}
            return 0;
	}
	
	public function getText(mText):String
	{
		var r = ~/(\\[cCS]\[([a-fA-F0-9]+)\])*(.+)/;
		if (r.match(mText))
		{
			return r.matched(3);<commit_msg>Some fixes to CmdParser (Issue #2)<commit_after>package rpg.text;

/**
 * ...
 * @author <NAME>
 */

class CmdParser
{
	private var rawText:String;
	
    private static var colorCodes = new ReadOnlyArray([0xFF0000, 0x00FF00, 0x0000FF]); //System Color Codes
	
	public function new(rawText:String) 
	{
		this.rawText = rawText;
	}
    
    private function splitTokens():Array<String>
    {
        var r = ~/(((\\[CcS]\[[a-fA-F0-9]+\])*)(([\w\s\.!@?](\\n)*)+))/;
        var temp = rawText;
        var arrayTokens = new Array<String> ();
        while(r.match(temp))
        {
			//trace("Command Part: " + r.matched(2));
            //trace("Message Part: " + r.matched(4));
            //trace("Full Token: " + r.matched(1));
            arrayTokens.push(r.matched(1));
            temp = temp.substr(r.matchedPos().len);
        }
        return arrayTokens;
    }
	
	private function getTextColor(mText:String):Int
	{
		
		var r = ~/\\C\[([0-9]+)\]/;
		if (r.match(mText))
		{
            return colorCodes[Std.parseInt(r.matched(1))-1];
		}
            return 0;
	}
	
	private function getTextColorByHex(mText:String):Int
	{
		var r = ~/\\c\[([a-fA-F0-9]+)\]/;
		if (r.match(mText))
		{
			return Std.parseInt("0x"+r.matched(1));
		}
            return 0;
	}
	
	private function getTextSpeed(mText:String):Int
	{
		var r = ~/\\S\[([0-9]+)\]/;
		if (r.match(mText))
		{
			return Std.parseInt(r.matched(1));
		}
            return 0;
	}
	
	private function getText(mText):String
	{
		var r = ~/(\\[cCS]\[([a-fA-F0-9]+)\])*(.+)/;
		if (r.match(mText))
		{
			return r.matched(3);
{'fraction_non_alphanumeric': 0.20673076923076922, 'fraction_numerical': 0.02467948717948718, 'mean_word_length': 2.2714884696016773, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '3999087', 'n_tokens_mistral': 1305, 'n_tokens_neox': 1211, 'n_words': 199}