<commit_before><?php

class Parser_Winamax_Engine extends Parser_Abstract
{
    const T_HEADER = '@Winamax Poker - .+ - .+ - [^\(]+\((\d.+/)?(\d.+)/(\d.+)\) - .*@';
    const T_TABLE = '@Table: .* (\d+)-max .* Seat #(\d+) .*@';
    const T_STACK = '@Seat (\d+): (.+) \((\d.+)\)@';
    const T_ANTE = '@(.+) posts ante (\d.+)@';
    const T_BIG_BLIND = '@(.+) posts big blind \d.+ out of position@';
    const T_DEALT = '@Dealt to (.+) \[(..) (..)\]@';
    const T_FOLD = '@(.+) folds@';
    const T_RAISE = '@(.+) raises \S+ to (\S+).*@';
    const T_BET = '@(.+) bets (\S+)@';
    const T_CALL = '@(.+) calls (\S+)@';
    const T_CHECK = '@(.+) checks@';
    const T_FLOP = '@\*\*\* FLOP \*\*\* \[(..) (..) (..)\]@';
    const T_TURN = '@\*\*\* TURN \*\*\* \[.. .. ..\]\[(..)\]@';
    const T_RIVER = '@\*\*\* RIVER \*\*\* \[.. .. .. ..\]\[(..)\]@';
    const T_SHOWDOWN_WON = '@Seat \d+: ([^\(]+)( \(.+\))? showed \[(..) (..)\] and won (\d\S+)@';
    const T_SHOWDOWN_LOST = '@Seat \d+: ([^\(]+)( \(.+\))? showed \[(..) (..)\]@';
    const T_WINNER = '@Seat \d+: (.+) won (\d\S+)@';


    protected $rules = array(
        'parseHeader' => self::T_HEADER,
        'parseTable' => self::T_TABLE,
        'parseStack' => self::T_STACK,
        'parseAnte' => self::T_ANTE,
        'parseBigBlind' => self::T_BIG_BLIND,
        'parseDealt' => self::T_DEALT,
        'parseFold' => self::T_FOLD,
        'parseRaise' => self::T_RAISE,
        'parseBet' => self::T_BET,
        'parseCall' => self::T_CALL,
        'parseCheck' => self::T_CHECK,
        'parseFlop' => self::T_FLOP,
        'parseTurn' => self::T_TURN,
        'parseRiver' => self::T_RIVER,
        'parseShowdownWon' => self::T_SHOWDOWN_WON,
        'parseShowdownLost' => self::T_SHOWDOWN_LOST,
        'parseWinner' => self::T_WINNER,
    );
    private $btnPosition;
    private $hero;
    private $showdown = array();
    private $winnings = array();


    public function isLogValid()
    {
        if (preg_match(self::T_HEADER, $this->file[0], $matches)) return true;

        return false;
    }

    protected function postParsing()
    {
        $this->detectAwayPlayers();

        $nb = count($this->hand->stacks);
        $positions = TablePosition::getPositionsOrderByBtnPos($nb, $this->btnPosition);

        foreach ($this->hand->stacks as $k => &$stack) {
            $stack->pos = $positions[$k];

            if (isset($stack->hc)) $this->hand->heroPosition = $stack->pos;
        }

        if (!empty($this->showdown)) {
            $action = new stdClass();
            $action->type = 'show';
            $action->players = $this->showdown;
            $this->hand->actions[] = $action;
        }

        if (!empty($this->winnings)) {
            $action = new stdClass();
            $action->type = 'winning';
            $action->players = $this->winnings;
            $this->hand->actions[] = $action;
        }
    }

    private function detectAwayPlayers()
    {
        $actives = array();
        foreach ($this->hand->actions as $action) {
            if (isset($action->player)) $actives[$action->player] = true;
        }

        foreach ($this->hand->stacks as $k => $stack) {
            if (!isset($actives[$stack->name])) {
                unset($this->hand->stacks[$k]);
            }
        }
        $this->hand->stacks = array_values($this->hand->stacks);
    }

    protected function parseHeader($line, $matches)
    {
        $this->detectCurrency($matches[2]);
        $this->hand->blinds['sb'] = $this->rmCurrency($matches[2]);
        $this->hand->blinds['bb'] = $this->rmCurrency($matches[3]);
    }

    protected function parseTable($line, $matches)
    {
        $this->hand->format = $matches[1];
        $this->btnPosition = $matches[2];
    }

    protected function parseStack($line, $matches)
    {
        $stack = new stdClass();
        $stack->name = $matches[2];
        $stack->stack = $this->rmCurrency($matches[3]);
        $this->hand->addStack($stack);

        if ($matches[1] == $this->btnPosition) {
            $this->btnPosition = count($this->hand->stacks);
        }
    }

    protected function parseAnte($line, $matches)
    {
        $this->hand->addAnte($matches[1], $matches[2]);
    }

    protected function parseBigBlind($line, $matches)
    {
        $this->hand->addBigBlinds($matches[1]);
    }

    protected function parseDealt($line, $matches)
    {
        $cards = array(strtoupper($matches[2]), strtoupper($matches[3]));
        $this->hero = $this->hand->cleanPlayerName($matches[1]);
<commit_msg>Remove bug fix<commit_after><?php

class Parser_Winamax_Engine extends Parser_Abstract
{
    const T_HEADER = '@Winamax Poker - .+ - .+ - [^\(]+\((\d.+/)?(\d.+)/(\d.+)\) - .*@';
    const T_TABLE = '@Table: .* (\d+)-max .* Seat #(\d+) .*@';
    const T_STACK = '@Seat (\d+): (.+) \((\d.+)\)@';
    const T_ANTE = '@(.+) posts ante (\d.+)@';
    const T_BIG_BLIND = '@(.+) posts big blind \d.+ out of position@';
    const T_DEALT = '@Dealt to (.+) \[(..) (..)\]@';
    const T_FOLD = '@(.+) folds@';
    const T_RAISE = '@(.+) raises \S+ to (\S+).*@';
    const T_BET = '@(.+) bets (\S+)@';
    const T_CALL = '@(.+) calls (\S+)@';
    const T_CHECK = '@(.+) checks@';
    const T_FLOP = '@\*\*\* FLOP \*\*\* \[(..) (..) (..)\]@';
    const T_TURN = '@\*\*\* TURN \*\*\* \[.. .. ..\]\[(..)\]@';
    const T_RIVER = '@\*\*\* RIVER \*\*\* \[.. .. .. ..\]\[(..)\]@';
    const T_SHOWDOWN_WON = '@Seat \d+: ([^\(]+)( \(.+\))? showed \[(..) (..)\] and won (\d\S+)@';
    const T_SHOWDOWN_LOST = '@Seat \d+: ([^\(]+)( \(.+\))? showed \[(..) (..)\]@';
    const T_WINNER = '@Seat \d+: (.+) won (\d\S+)@';


    protected $rules = array(
        'parseHeader' => self::T_HEADER,
        'parseTable' => self::T_TABLE,
        'parseStack' => self::T_STACK,
        'parseAnte' => self::T_ANTE,
        'parseBigBlind' => self::T_BIG_BLIND,
        'parseDealt' => self::T_DEALT,
        'parseFold' => self::T_FOLD,
        'parseRaise' => self::T_RAISE,
        'parseBet' => self::T_BET,
        'parseCall' => self::T_CALL,
        'parseCheck' => self::T_CHECK,
        'parseFlop' => self::T_FLOP,
        'parseTurn' => self::T_TURN,
        'parseRiver' => self::T_RIVER,
        'parseShowdownWon' => self::T_SHOWDOWN_WON,
        'parseShowdownLost' => self::T_SHOWDOWN_LOST,
        'parseWinner' => self::T_WINNER,
    );
    private $btnPosition;
    private $hero;
    private $showdown = array();
    private $winnings = array();


    public function isLogValid()
    {
        if (preg_match(self::T_HEADER, $this->file[0], $matches)) return true;

        return false;
    }

    protected function postParsing()
    {
        $this->detectAwayPlayers();

        $nb = count($this->hand->stacks);
        $positions = TablePosition::getPositionsOrderByBtnPos($nb, $this->btnPosition);

        foreach ($this->hand->stacks as $k => &$stack) {
            $stack->pos = $positions[$k];

            if (isset($stack->hc)) $this->hand->heroPosition = $stack->pos;
        }

        if (!empty($this->showdown)) {
            $action = new stdClass();
            $action->type = 'show';
            $action->players = $this->showdown;
            $this->hand->actions[] = $action;
        }

        if (!empty($this->winnings)) {
            $action = new stdClass();
            $action->type = 'winning';
            $action->players = $this->winnings;
            $this->hand->actions[] = $action;
        }
    }

    private function detectAwayPlayers()
    {
        $actives = array();
        foreach ($this->hand->actions as $action) {
            if (isset($action->player)) $actives[$action->player] = true;
        }

        foreach ($this->hand->stacks as $k => $stack) {
            if (!isset($actives[$stack->name])) {
                unset($this->hand->stacks[$k]);
            }
        }
        $this->hand->stacks = array_values($this->hand->stacks);
    }

    protected function parseHeader($line, $matches)
    {
        $this->detectCurrency($matches[2]);
        $this->hand->blinds['sb'] = $this->rmCurrency($matches[2]);
        $this->hand->blinds['bb'] = $this->rmCurrency($matches[3]);
    }

    protected function parseTable($line, $matches)
    {
        $this->hand->format = $matches[1];
        $this->btnPosition = $matches[2];
    }

    protected function parseStack($line, $matches)
    {
        $stack = new stdClass();
        $stack->name = $matches[2];
        $stack->stack = $this->rmCurrency($matches[3]);
        $this->hand->addStack($stack);
    }

    protected function parseAnte($line, $matches)
    {
        $this->hand->addAnte($matches[1], $matches[2]);
    }

    protected function parseBigBlind($line, $matches)
    {
        $this->hand->addBigBlinds($matches[1]);
    }

    protected function parseDealt($line, $matches)
    {
        $cards = array(strtoupper($matches[2]), strtoupper($matches[3]));
        $this->hero = $this->hand->cleanPlayerName($matches[1]);

{'fraction_non_alphanumeric': 0.22762602709304908, 'fraction_numerical': 0.003220075505218743, 'mean_word_length': 2.269328493647913, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 163, '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': '7049945', 'n_tokens_mistral': 3240, 'n_tokens_neox': 3058, 'n_words': 525}