<commit_before>﻿using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;

namespace CGbR
{
    /// <summary>
    /// <see cref="IParser"/> implementation that uses only regex to extract the most basic syntax elements
    /// like properties or attributes
    /// </summary>
    internal class RegexParser : IParser
    {
        // Regex used to parse source file
        private readonly Regex _namespaceRegex = new Regex(@"namespace (?<namespace>(?:\w\.?)*)");
        private readonly Regex _attributeRegex = new Regex(@" \[(?<attributeName>\w+)\(?(?:(?<parameter>\d+),? ?)*(?:(?<property>\w+) ?= ?(?<value>\d+),? ?)*");

        private readonly Regex _classRegex = new Regex(@" (?<accessModifier>(?:public|internal))(?<isPartial> partial)? class (?<className>\w+)(?: : )?(?<baseType>[A-Z][a-z]\w+)?(?:, )?(?:(?<interface>I\w+)(?:, )?)*");
        private readonly Regex _enumRegex = new Regex(@" (?<accessModifier>(?:public|internal)) enum (?<enumName>\w+)(?: : )?(?<type>\w+)?");

        private readonly Regex _propRegex = new Regex(@" (?<accessModifier>(?:public|internal|private)) (?:(?<collectionType>\w+)<)?(?<type>\w+)(?<isArray>\[(?<dimensions>, ?)*\])?>? (?<name>_?\w+)");
        private readonly Regex _memberRegex = new Regex(@" (?<name>\w+)(?: ?= ?)?(?<value>\d+)?");


        /// <seealso cref="IParser"/>
        public string Name { get; } = "Regex";

        /// <seealso cref="IParser"/>
        public CodeElementModel ParseFile(string filePath)
        {
            // Read the file
            var file = File.ReadAllLines(filePath);

            CodeElementModel model = null;
            var @namespace = string.Empty;
            for (var i = 0; i < file.Length; i++)
            {
                var line = file[i];
<commit_msg>Bug: Methods read as properties<commit_after>﻿using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;

namespace CGbR
{
    /// <summary>
    /// <see cref="IParser"/> implementation that uses only regex to extract the most basic syntax elements
    /// like properties or attributes
    /// </summary>
    internal class RegexParser : IParser
    {
        // Regex used to parse source file
        private readonly Regex _namespaceRegex = new Regex(@"namespace (?<namespace>(?:\w\.?)*)");
        private readonly Regex _attributeRegex = new Regex(@" \[(?<attributeName>\w+)\(?(?:(?<parameter>\d+),? ?)*(?:(?<property>\w+) ?= ?(?<value>\d+),? ?)*");

        private readonly Regex _classRegex = new Regex(@" (?<accessModifier>(?:public|internal))(?<isPartial> partial)? class (?<className>\w+)(?: : )?(?<baseType>[A-Z][a-z]\w+)?(?:, )?(?:(?<interface>I\w+)(?:, )?)*");
        private readonly Regex _enumRegex = new Regex(@" (?<accessModifier>(?:public|internal)) enum (?<enumName>\w+)(?: : )?(?<type>\w+)?");

        private readonly Regex _propRegex = new Regex(@" (?<accessModifier>(?:public|internal|private)) (?:(?<collectionType>\w+)<)?(?<type>\w+)(?<isArray>\[(?<dimensions>, ?)*\])?>? (?<name>_?\w+) ");
        private readonly Regex _memberRegex = new Regex(@" (?<name>\w+)(?: ?= ?)?(?<value>\d+)?");


        /// <seealso cref="IParser"/>
        public string Name { get; } = "Regex";

        /// <seealso cref="IParser"/>
        public CodeElementModel ParseFile(string filePath)
        {
            // Read the file
            var file = File.ReadAllLines(filePath);

            CodeElementModel model = null;
            var @namespace = string.Empty;
            for (var i = 0; i < file.Length; i++)
            {
                var line = file[i];

{'fraction_non_alphanumeric': 0.21094391244870042, 'fraction_numerical': 0.0005471956224350205, 'mean_word_length': 3.1357466063348416, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 57, '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': '3595121', 'n_tokens_mistral': 1175, 'n_tokens_neox': 1123, 'n_words': 268}