<commit_before>#include <iostream>
#include <string>

using namespace std;

class Solution {
public:
  //use BNF
  //https://dai1741.github.io/maximum-algo-2012/docs/parsing/
  /*
    <expr> ::= <term>[('.')<term>]*
    <term> ::= <str>[('*')<term>]*
    <str> ::= '.'と‘*’以外の文字列[<expr>]*
  */
  /*
  "a*ab"
  "a*b"
  correct answer is true but leetcode got a false.......OMG
  it should get a greedy answer.but....that's ok
  */
    bool isMatch(string s, string r) {
      return expr(s, r, 0, 0);
    }

    bool expr(string s, string r, size_t spos, size_t rpos){
      //cout << "[str] " << "s:" << s << " r:" << r << " spos:" << spos << " rpos:" << rpos << endl;
      if(spos >= s.size() && rpos >= s.size()) return true;
      if(spos >= s.size() || rpos >= s.size()) return false;
      if(r[rpos] == '.')
        return term(s, r, spos + 1, rpos + 1);
      return term(s, r, spos, rpos);
    }

    bool term(string s, string r, size_t spos, size_t rpos){
      //cout << "[expr] " << "s:" << s << " r:" << r << " spos:" << spos << " rpos:" << rpos << endl;
      if(spos >= s.size() && rpos >= s.size()) return true;
      if(spos >= s.size() || rpos >= s.size()) return false;
      size_t rnext = rpos < r.size() - 1 ? rpos + 1 : rpos;
      while(r[rpos] == '*' && r[rnext] != s[spos]) spos++;
      if(r[rpos] == '*')
        return str(s, r, spos, rpos + 1);
      else return str(s, r, spos, rpos);
    }

    bool str(string s, string r, size_t spos, size_t rpos){
      //cout << "[term] " << "s:" << s << " r:" << r << " spos:" << spos << " rpos:" << rpos << endl;
      if(spos >= s.size() && rpos >= s.size()) return true;
      if(spos >= s.size() || rpos >= s.size()) return false;
      if(r[rpos] == '.' || r[rpos] == '*')
        return expr(s, r, spos, rpos);
      else if(r[rpos] == s[spos])
        return expr(s, r, spos + 1, rpos + 1);<commit_msg>fix mistake<commit_after>#include <iostream>
#include <string>

using namespace std;

class Solution {
public:
  //use BNF
  //https://dai1741.github.io/maximum-algo-2012/docs/parsing/
  /*
    <expr> ::= <term>[('.')<term>]*
    <term> ::= <str>[('*')<term>]*
    <str> ::= '.'と‘*’以外の文字列[<expr>]*
  */
  /*
  "a*ab"
  "a*b"
  correct answer is true but leetcode got a false.......OMG
  it should get a greedy answer.but....that's ok
  */
    bool isMatch(string s, string r) {
      return expr(s, r, 0, 0);
    }

    bool expr(string s, string r, size_t spos, size_t rpos){
      //cout << "[str] " << "s:" << s << " r:" << r << " spos:" << spos << " rpos:" << rpos << endl;
      if(spos >= s.size() && rpos >= r.size()) return true;
      if(spos >= s.size() || rpos >= r.size()) return false;
      if(r[rpos] == '.')
        return term(s, r, spos + 1, rpos + 1);
      return term(s, r, spos, rpos);
    }

    bool term(string s, string r, size_t spos, size_t rpos){
      //cout << "[expr] " << "s:" << s << " r:" << r << " spos:" << spos << " rpos:" << rpos << endl;
      if(spos >= s.size() && rpos >= r.size()) return true;
      if(spos >= s.size() || rpos >= r.size()) return false;
      size_t rnext = rpos < r.size() - 1 ? rpos + 1 : rpos;
      while(r[rpos] == '*' && r[rnext] != s[spos]) spos++;
      if(r[rpos] == '*')
        return str(s, r, spos, rpos + 1);
      else return str(s, r, spos, rpos);
    }

    bool str(string s, string r, size_t spos, size_t rpos){
      //cout << "[term] " << "s:" << s << " r:" << r << " spos:" << spos << " rpos:" << rpos << endl;
      if(spos >= s.size() && rpos >= r.size()) return true;
      if(spos >= s.size() || rpos >= r.size()) return false;
      if(r[rpos] == '.' || r[rpos] == '*')
        return expr(s, r, spos, rpos);
      else if(r[rpos] == s[spos])
        return expr(s, r, spos + 1, rpos + 1);
{'fraction_non_alphanumeric': 0.24321447578499203, 'fraction_numerical': 0.009047365620010643, 'mean_word_length': 2.392599277978339, 'pattern_counts': {'":': 0, '<': 145, '<?xml version=': 0, '>': 47, 'https://': 2, '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': '5048736', 'n_tokens_mistral': 1550, 'n_tokens_neox': 1505, 'n_words': 396}