<commit_before><?php

namespace Everzet\Gherkin;

use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;

/*
 * This file is part of the Gherkin.
 * (c) 2010 <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 * Gherkin Parser.
 *
 * @author      <NAME> <<EMAIL>>
 */
class Parser
{
    protected $file             = null;
    protected $locale           = 'en';
    protected $translator       = null;
    protected $container        = null;
    protected $lines            = array();
    protected $currentLineNb    = -1;
    protected $currentLine      = '';
    protected $regex            = null;
    protected $feature          = null;

    public function __construct(Container $container = null)
    {
        if (null === $container) {
            $container  = new ContainerBuilder();
            $xmlLoader  = new XmlFileLoader($container);
            $xmlLoader->load(__DIR__ . '/ServiceContainer/container.xml');
        }

        $this->container    = $container;
        $this->translator   = $container->get('gherkin.translator');
    }

    public function parseFile($file)
    {
        $this->file = $file;
        $feature = $this->parse(file_get_contents($file));
        $this->file = null;

        return $feature;
    }

    public function parse($value)
    {
        $this->currentLineNb = -1;
        $this->currentLine = '';
        $this->lines = explode("\n", $this->cleanup($value));

        if (preg_match('#^\#\s*language\:\s*(?P<lang>[\w]+?)\s*$#', $this->lines[0], $values)) {
            $this->locale = $values['lang'];
            $this->translator->setLocale($this->locale);
        }
        $this->lexer = new Lexer($this->translator);

        if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
            $mbEncoding = mb_internal_encoding();
            mb_internal_encoding('ASCII');
        }

        while ($this->moveToNextLine()) {
            if ($this->isCurrentLineEmpty()) {
                continue;
            }<commit_msg>added regions support (ru-RU, pt-BR etc.)<commit_after><?php

namespace Everzet\Gherkin;

use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;

/*
 * This file is part of the Gherkin.
 * (c) 2010 <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 * Gherkin Parser.
 *
 * @author      <NAME> <<EMAIL>>
 */
class Parser
{
    protected $file             = null;
    protected $locale           = 'en';
    protected $translator       = null;
    protected $container        = null;
    protected $lines            = array();
    protected $currentLineNb    = -1;
    protected $currentLine      = '';
    protected $regex            = null;
    protected $feature          = null;

    public function __construct(Container $container = null)
    {
        if (null === $container) {
            $container  = new ContainerBuilder();
            $xmlLoader  = new XmlFileLoader($container);
            $xmlLoader->load(__DIR__ . '/ServiceContainer/container.xml');
        }

        $this->container    = $container;
        $this->translator   = $container->get('gherkin.translator');
    }

    public function parseFile($file)
    {
        $this->file = $file;
        $feature = $this->parse(file_get_contents($file));
        $this->file = null;

        return $feature;
    }

    public function parse($value)
    {
        $this->currentLineNb = -1;
        $this->currentLine = '';
        $this->lines = explode("\n", $this->cleanup($value));

        if (preg_match('#^\#\s*language\:\s*(?P<lang>[\w-]+?)\s*$#', $this->lines[0], $values)) {
            $this->locale = $values['lang'];
            $this->translator->setLocale($this->locale);
        }
        $this->lexer = new Lexer($this->translator);

        if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
            $mbEncoding = mb_internal_encoding();
            mb_internal_encoding('ASCII');
        }

        while ($this->moveToNextLine()) {
            if ($this->isCurrentLineEmpty()) {
                continue;
            }
{'fraction_non_alphanumeric': 0.14637904468412943, 'fraction_numerical': 0.0035219018269865726, 'mean_word_length': 2.3216374269005846, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '2338273', 'n_tokens_mistral': 1327, 'n_tokens_neox': 1294, 'n_words': 275}