<commit_before>﻿using System;
using System.Text.RegularExpressions;
using System.Xml;

namespace EyeInTheSky
{
    public class SimpleStalk : Stalk
    {
        public SimpleStalk(string flag) : base(flag)
        {

        }

        private SimpleStalk(string flag, string time, string time2)
            : base(flag, time, time2)
        {
        }


        public bool HasUserSearch
        {
            get { return hasusercheck; }
        }

        public bool HasPageSearch
        {
            get { return haspagecheck; }
        }

        public bool HasSummarySearch
        {
            get { return hassummarycheck; }
        }

        private bool hasusercheck;
        private bool haspagecheck;
        private bool hassummarycheck;

        private Regex user, page, summary;


        public void setUserSearch(string regex, bool isupdate)
        {
            hasusercheck = true;
            user = new Regex(regex);

            if (isupdate)
                this.LastUpdateTime = DateTime.Now;
        }
        public void setPageSearch(string regex, bool isupdate)
        {
            haspagecheck = true;
            page = new Regex(regex);

            if (isupdate)
                this.LastUpdateTime = DateTime.Now;
        }
        public void setSummarySearch(string regex, bool isupdate)
        {
            hassummarycheck = true;
            summary = new Regex(regex);

            if (isupdate)
                this.LastUpdateTime = DateTime.Now;
        }

        public override bool match(RecentChange rc)
        {
            if (!(HasUserSearch || HasPageSearch || hassummarycheck))
                return false;

            if(HasUserSearch && ! user.Match(rc.User).Success)
            {
                return false;
            }

            if(HasPageSearch && ! page.Match(rc.Page).Success)
            {
                return false;
            }

            if (hassummarycheck && !summary.Match(rc.EditSummary).Success)
            {
                return false;
            }

            return true;
        }

        public override XmlElement ToXmlFragment(XmlDocument doc, string xmlns)
        {
            XmlElement e = doc.CreateElement("stalk", xmlns);
            e.SetAttribute("flag", flag);
            e.SetAttribute("lastupdate", LastUpdateTime.ToString());<commit_msg>last trigger time<commit_after>﻿using System;
using System.Text.RegularExpressions;
using System.Xml;

namespace EyeInTheSky
{
    public class SimpleStalk : Stalk
    {
        public SimpleStalk(string flag) : base(flag)
        {

        }

        private SimpleStalk(string flag, string time, string time2)
            : base(flag, time, time2)
        {
        }


        public bool HasUserSearch
        {
            get { return hasusercheck; }
        }

        public bool HasPageSearch
        {
            get { return haspagecheck; }
        }

        public bool HasSummarySearch
        {
            get { return hassummarycheck; }
        }

        private bool hasusercheck;
        private bool haspagecheck;
        private bool hassummarycheck;

        private Regex user, page, summary;


        public void setUserSearch(string regex, bool isupdate)
        {
            hasusercheck = true;
            user = new Regex(regex);

            if (isupdate)
                this.LastUpdateTime = DateTime.Now;
        }
        public void setPageSearch(string regex, bool isupdate)
        {
            haspagecheck = true;
            page = new Regex(regex);

            if (isupdate)
                this.LastUpdateTime = DateTime.Now;
        }
        public void setSummarySearch(string regex, bool isupdate)
        {
            hassummarycheck = true;
            summary = new Regex(regex);

            if (isupdate)
                this.LastUpdateTime = DateTime.Now;
        }

        public override bool match(RecentChange rc)
        {
            if (!(HasUserSearch || HasPageSearch || hassummarycheck))
                return false;

            if(HasUserSearch && ! user.Match(rc.User).Success)
            {
                return false;
            }

            if(HasPageSearch && ! page.Match(rc.Page).Success)
            {
                return false;
            }

            if (hassummarycheck && !summary.Match(rc.EditSummary).Success)
            {
                return false;
            }

            this.LastTriggerTime = DateTime.Now;
            return true;
        }

        public override XmlElement ToXmlFragment(XmlDocument doc, string xmlns)
        {
            XmlElement e = doc.CreateElement("stalk", xmlns);
            e.SetAttribute("flag", flag);
            e.SetAttribute("lastupdate", LastUpdateTime.ToString());
{'fraction_non_alphanumeric': 0.07871048775382039, 'fraction_numerical': 0.0008373456144023446, 'mean_word_length': 1.4989539748953975, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '2235360', 'n_tokens_mistral': 1255, 'n_tokens_neox': 1190, 'n_words': 291}