<commit_before>﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using spritz.Properties;
using System.Runtime.InteropServices;


namespace spritz
{
    public partial class Form1 : Form
    {
        [DllImportAttribute("user32.dll")]
        public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
        [DllImport("user32.dll")]
        public static extern bool ReleaseCapture();
        
        private string[] book_text;
        private bool status = false;
        private int word_index = 0;


        public Form1()
        {
            InitializeComponent();
        }

        private void button5_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void update_text(string word)
        {
            richTextBox1.SelectionStart = 0;
            richTextBox1.SelectionLength = 20;
            richTextBox1.SelectionColor = Color.Black;

            if (word.IndexOf("\r\n") > 0) word = word.Remove(word.IndexOf("\r\n"), 2);
            int index = get_colored_letter_number(word);
            richTextBox1.ForeColor = Color.Black;

            richTextBox1.Text = word;
            richTextBox1.SelectionStart = index;
            richTextBox1.SelectionLength = 1;
            richTextBox1.SelectionColor = Color.Red;
            richTextBox1.Location = get_point(index);
        }

        private int get_colored_letter_number(string word)
        {
            char[] chars_to_trim = {'.', ',',':',';','!','?','-'};
            if (word.Trim(chars_to_trim).Length >= 18)
                return 5;
            else if (word.Trim(chars_to_trim).Length >= 14)
                return 4;
            else if (word.Trim(chars_to_trim).Length >= 10)
                return 3;
            else if (word.Trim(chars_to_trim).Length >= 6)
                return 2;
            else if (word.Trim(chars_to_trim).Length >= 2)
                return 1;
            else 
                return 0;
        }

        private Point get_point(int index)
        {
            int X = richTextBox1.GetPositionFromCharIndex(index).X;
            int Y = richTextBox1.Location.Y;
            int letter_width = (int)richTextBox1.Font.Size / 2 - 4;
            return new Point(125 - X - letter_width, Y);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            timer1.Interval = 60 * 1000 / Convert.ToInt32(comboBox1.Text);
            if (status)
            {
                button2.Image = Resources.Symbols_Play_32xLG;
                timer1.Enabled = false;
                status = false;
            }
            else
            {
                button2.Image = Resources.Symbols_Pause_32xLG;
                timer1.Enabled = true;
                status = true;
                button3.Enabled = true;
                button4.Enabled = true;
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string text = System.IO.File.ReadAllText(openFileDialog1.FileName, Encoding.Default);
                book_text = text.Split(' ');
                button2.Enabled = true;
            }
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            update_text(book_text[word_index]);
            word_index += 1;
            if (word_index == book_text.Length)
            {<commit_msg>Update Form1.cs<commit_after>﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using spritz.Properties;
using System.Runtime.InteropServices;


namespace spritz
{
    public partial class Form1 : Form
    {
        [DllImportAttribute("user32.dll")]
        public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
        [DllImport("user32.dll")]
        public static extern bool ReleaseCapture();
        
        private string[] book_text;
        private bool status = false;
        private int word_index = 0;


        public Form1()
        {
            InitializeComponent();
        }

        private void button5_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void update_text(string word)
        {
            richTextBox1.SelectionStart = 0;
            richTextBox1.SelectionLength = 20;
            richTextBox1.SelectionColor = Color.Black;

            if (word.IndexOf("\r\n") > 0) word = word.Remove(word.IndexOf("\r\n"), 2);
            int index = get_colored_letter_number(word);
            richTextBox1.ForeColor = Color.Black;

            richTextBox1.Text = word;
            richTextBox1.SelectionStart = index;
            richTextBox1.SelectionLength = 1;
            richTextBox1.SelectionColor = Color.Red;
            richTextBox1.Location = get_point(index);
        }

        private int get_colored_letter_number(string word)
        {
            char[] chars_to_trim = {'.', ',',':',';','!','?','-'};
            if (word.Trim(chars_to_trim).Length >= 18)
                return 5;
            else if (word.Trim(chars_to_trim).Length >= 14)
                return 4;
            else if (word.Trim(chars_to_trim).Length >= 10)
                return 3;
            else if (word.Trim(chars_to_trim).Length >= 6)
                return 2;
            else if (word.Trim(chars_to_trim).Length >= 2)
                return 1;
            else 
                return 0;
        }

        private Point get_point(int index)
        {
            int X = richTextBox1.GetPositionFromCharIndex(index).X;
            int Y = richTextBox1.Location.Y;
            int letter_width = (int)richTextBox1.Font.Size / 2 - 4;
            return new Point(125 - X - letter_width, Y);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            timer1.Interval = 60 * 1000 / Convert.ToInt32(comboBox1.Text);
            if (status)
            {
                button2.Image = Resources.Symbols_Play_32xLG;
                timer1.Enabled = false;
                status = false;
            }
            else
            {
                button2.Image = Resources.Symbols_Pause_32xLG;
                timer1.Enabled = true;
                status = true;
                button3.Enabled = true;
                button4.Enabled = true;
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string text = System.IO.File.ReadAllText(openFileDialog1.FileName, Encoding.Default);
                book_text = text.Split(' ');
                button2.Enabled = true;
                string[] file_name = openFileDialog1.FileName.Split('\\');
                update_text(file_name[file_name.Length - 1]);
                word_index = 0;
            }
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            update_text(book_text[word_index]);
            word_index += 1;
            if (word_index == book_text.Length)
            {
{'fraction_non_alphanumeric': 0.0967009483104047, 'fraction_numerical': 0.01976759716842527, 'mean_word_length': 1.66951871657754, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '4353368', 'n_tokens_mistral': 2165, 'n_tokens_neox': 2009, 'n_words': 442}