<commit_before><?php namespace Mayconbordin\Generator\Parsers;

class NameParser
{
    const ACTIONS = [
        'create' => 'create', 'make'    => 'create',
        'delete' => 'delete', 'remove'  => 'delete',
        'drop'   => 'drop'  , 'destroy' => 'drop'  ,
        'add'    => 'add'   , 'append'  => 'add'   , 'update' => 'add', 'insert' => 'add',
    ];

    /**
     * Parse the migration name into something we can use.
     *
     * @param  string $name
     * @return array
     */
    public function parse($name)
    {
        $segments = array_reverse(explode('_', $name));

        if ($segments[0] == 'table') {
            array_shift($segments);
        }

        return [
            'action' => $this->getAction($segments),
            'table'  => $this->getTableName($segments)
        ];
    }

    /**
     * Calculate the table name.
     *
     * @param  array $segments
     * @return array
     */
    private function getTableName($segments)
    {
        $tableName = [];

        foreach ($segments as $segment) {
            if ($this->isConnectingWord($segment)) {
                break;
            }

            $tableName[] = $segment;
        }

        return implode('_', array_reverse($tableName));
    }

    /**
     * Determine the user's desired action for the migration.
     *
     * @param  array $segments
     * @return mixed
     */
    private function getAction(&$segments)
    {
        if ($this->normalizeActionName(end(array_values($segments))) != null) {
            return $this->normalizeActionName(array_pop($segments));
        }

        return null;
    }

    /**
     * Normalize the user's chosen action to name to
     * something that we recognize.
     *
     * @param  string $action
     * @return string
     */
    private function normalizeActionName($action)
    {
        return array_get(self::ACTIONS, $action, null);
    }<commit_msg>Fixed error on the name parser<commit_after><?php namespace Mayconbordin\Generator\Parsers;

class NameParser
{
    const ACTIONS = [
        'create' => 'create', 'make'    => 'create',
        'delete' => 'delete', 'remove'  => 'delete',
        'drop'   => 'drop'  , 'destroy' => 'drop'  ,
        'add'    => 'add'   , 'append'  => 'add'   , 'update' => 'add', 'insert' => 'add',
    ];

    /**
     * Parse the migration name into something we can use.
     *
     * @param  string $name
     * @return array
     */
    public function parse($name)
    {
        $segments = array_reverse(explode('_', $name));

        if ($segments[0] == 'table') {
            array_shift($segments);
        }

        return [
            'action' => $this->getAction($segments),
            'table'  => $this->getTableName($segments)
        ];
    }

    /**
     * Calculate the table name.
     *
     * @param  array $segments
     * @return array
     */
    private function getTableName($segments)
    {
        $tableName = [];

        foreach ($segments as $segment) {
            if ($this->isConnectingWord($segment)) {
                break;
            }

            $tableName[] = $segment;
        }

        return implode('_', array_reverse($tableName));
    }

    /**
     * Determine the user's desired action for the migration.
     *
     * @param  array $segments
     * @return mixed
     */
    private function getAction(&$segments)
    {
        $temp = array_values($segments);

        if ($this->normalizeActionName(end($temp)) != null) {
            return $this->normalizeActionName(array_pop($segments));
        }

        return null;
    }

    /**
     * Normalize the user's chosen action to name to
     * something that we recognize.
     *
     * @param  string $action
     * @return string
     */
    private function normalizeActionName($action)
    {
        return array_get(self::ACTIONS, $action, null);
    }
{'fraction_non_alphanumeric': 0.1456987858434513, 'fraction_numerical': 0.0005166623611469904, 'mean_word_length': 1.8938714499252616, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 37, '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': '4933007', 'n_tokens_mistral': 1172, 'n_tokens_neox': 1139, 'n_words': 263}