<commit_before>#include <stdexcept>
#include <cctype>
#include <cmath>
#include <iostream>

#include "param.h"

using namespace std;

namespace PARAM {
    int Int(string s) {
        int res = 0;
        size_t i = 0;
        int sign = 1;
        if (s[0] == '-') {
            sign = -1;
            i = 1;
            if (s.length() == 1) {
                throw invalid_argument(s + " isn't a valid integer number.");
            }
        }
        for (; i < s.length(); i++) {
            if (isdigit(s[i])) {
                res = res * 10 + s[i] - '0';
            } else {
                throw invalid_argument(s + " isn't a valid integer number.");
            }
        }
        return (res * sign);
    }
    float Float(string s) {
        float res = 0;
        size_t i = 0;
        int sign = 1;
        if (s[0] == '-') {
            sign = -1;
            i = 1;
            if ((s.length() == 1) || (s.length() == 2 && s[1] == '.')) {
                throw invalid_argument(s + " isn't a valid flaot number.");
            }
        }
        int decimalPos = 0;
        for (; i < s.length(); ++i) {
            if (isdigit(s[i])) {
                if (decimalPos == 0) {
                    res = res * 10 + s[i] - '0';
                } else {
                    res = res + (s[i] - '0') / (pow(10, decimalPos));
                    ++decimalPos;
                }
            } else {
                if (decimalPos == 0 && s[i] == '.') {
                    ++decimalPos;
                } else {
                    throw invalid_argument(s + " isn't a valid float number.");
                }
            }
        }
        return (res * sign);
    }
    string Name(string s) {
        if (s.length() == 0 || !isalpha(s[0])) {
            throw invalid_argument(s + " isn't a valid name.");
        }
        for (size_t i = 0; i < s.length(); i++) {
            if (s[i] != '_' && !isalnum(s[i])) {
                throw invalid_argument(s + " isn't a valid name.");
            }
        }
        return s;
    }

    string rmSpaceAndBracket(string s) {
        string res = "";
        string rS = string(s.rbegin(), s.rend());
        size_t pos, rPos;
        size_t length = s.length();
        try {
            pos = s.find('('); rPos = rS.find(')');
            s[pos] = ' '; s[length - 1 - rPos] = ' ';

            if ((pos != string::npos && rPos == string::npos) || (pos == string::npos && rPos != string::npos) || (pos + rPos > length - 1)) {
                throw invalid_argument("unmatched bracket.");
            }
        } catch (invalid_argument& e) {
            cout << "Syntax Error: " << e.what() << endl;
        }
        size_t st = 0, ed = s.length();
        while (ed > 0 && s[ed - 1] == ' ') {
          --ed;
        }
        while (st < ed && s[st] == ' ') {<commit_msg>fix bug<commit_after>#include <stdexcept>
#include <cctype>
#include <cmath>
#include <iostream>

#include "param.h"

using namespace std;

namespace PARAM {
    int Int(string s) {
        int res = 0;
        size_t i = 0;
        int sign = 1;
        if (s[0] == '-') {
            sign = -1;
            i = 1;
            if (s.length() == 1) {
                throw invalid_argument(s + " isn't a valid integer number.");
            }
        }
        for (; i < s.length(); i++) {
            if (isdigit(s[i])) {
                res = res * 10 + s[i] - '0';
            } else {
                throw invalid_argument(s + " isn't a valid integer number.");
            }
        }
        return (res * sign);
    }
    float Float(string s) {
        float res = 0;
        size_t i = 0;
        int sign = 1;
        if (s[0] == '-') {
            sign = -1;
            i = 1;
            if ((s.length() == 1) || (s.length() == 2 && s[1] == '.')) {
                throw invalid_argument(s + " isn't a valid flaot number.");
            }
        }
        int decimalPos = 0;
        for (; i < s.length(); ++i) {
            if (isdigit(s[i])) {
                if (decimalPos == 0) {
                    res = res * 10 + s[i] - '0';
                } else {
                    res = res + (s[i] - '0') / (pow(10, decimalPos));
                    ++decimalPos;
                }
            } else {
                if (decimalPos == 0 && s[i] == '.') {
                    ++decimalPos;
                } else {
                    throw invalid_argument(s + " isn't a valid float number.");
                }
            }
        }
        return (res * sign);
    }
    string Name(string s) {
        if (s.length() == 0 || !isalpha(s[0])) {
            throw invalid_argument(s + " isn't a valid name.");
        }
        for (size_t i = 0; i < s.length(); i++) {
            if (s[i] != '_' && !isalnum(s[i])) {
                throw invalid_argument(s + " isn't a valid name.");
            }
        }
        return s;
    }

    string rmSpaceAndBracket(string s) {
        string res = "";
        string rS = string(s.rbegin(), s.rend());
        size_t pos, rPos;
        size_t length = s.length();
        try {
            pos = s.find('('); rPos = rS.find(')');
            if (!(pos == string::npos && rPos == string::npos) && ((pos != string::npos && rPos == string::npos) || (pos == string::npos && rPos != string::npos) || (pos + rPos > length - 1))) {
                throw invalid_argument("unmatched bracket.");
            }
            if (pos != string::npos) {
                s[pos] = ' ';
            }
            if (rPos != string::npos) {
                s[length - 1 - rPos] = ' ';
            }
        } catch (invalid_argument& e) {
            cout << "Syntax Error: " << e.what() << endl;
        }
        size_t st = 0, ed = s.length();
        while (ed > 0 && s[ed - 1] == ' ') {
          --ed;
        }
        while (st < ed && s[st] == ' ') {
{'fraction_non_alphanumeric': 0.17071086807928912, 'fraction_numerical': 0.012303485987696514, 'mean_word_length': 1.1946006749156355, 'pattern_counts': {'":': 0, '<': 31, '<?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': '5246485', 'n_tokens_mistral': 1941, 'n_tokens_neox': 1831, 'n_words': 475}