<commit_before><?php

/**
 * This file is part of the OpenPNE package.
 * (c) OpenPNE Project (http://www.openpne.jp/)
 *
 * For the full copyright and license information, please view the LICENSE
 * file and the NOTICE file that were distributed with this source code.
 */

class openpneDataMaskTask extends sfDoctrineBaseTask
{
  protected function configure()
  {
    $this->namespace        = 'openpne';
    $this->name             = 'data-mask';

    $this->briefDescription = 'mask data';
    $this->detailedDescription = <<<EOF
The [openpne:data-mask|INFO] task masks data.
EOF;
  }

  protected function execute($arguments = array(), $options = array())
  {
    $databaseManager = new sfDatabaseManager($this->configuration);
    $yaml = sfYaml::load(sfConfig::get('sf_config_dir').'/mask.yml');

    Doctrine::initializeModels(array_keys($yaml));

    foreach ($yaml as $model => $tasks)
    {
      $table = Doctrine::getTable($model);
      $table->getRecordListener()->setOption('disabled', true);
<commit_msg>#4218:added the --file option that is a path to masking rule definition file<commit_after><?php

/**
 * This file is part of the OpenPNE package.
 * (c) OpenPNE Project (http://www.openpne.jp/)
 *
 * For the full copyright and license information, please view the LICENSE
 * file and the NOTICE file that were distributed with this source code.
 */

class openpneDataMaskTask extends sfDoctrineBaseTask
{
  protected function configure()
  {
    $this->namespace        = 'openpne';
    $this->name             = 'data-mask';

    $this->addOptions(array(
      new sfCommandOption('file', 'f', sfCommandOption::PARAMETER_OPTIONAL, 'The path to masking rule definition file.', sfConfig::get('sf_config_dir').'/mask.yml'),
    ));

    $this->briefDescription = 'mask data';
    $this->detailedDescription = <<<EOF
The [openpne:data-mask|INFO] task masks data.
EOF;
  }

  protected function execute($arguments = array(), $options = array())
  {
    $databaseManager = new sfDatabaseManager($this->configuration);
    $yaml = sfYaml::load($options['file']);

    Doctrine::initializeModels(array_keys($yaml));

    foreach ($yaml as $model => $tasks)
    {
      $table = Doctrine::getTable($model);
      $table->getRecordListener()->setOption('disabled', true);

{'fraction_non_alphanumeric': 0.14048140043763677, 'fraction_numerical': 0.00175054704595186, 'mean_word_length': 3.8638297872340424, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2542047', 'n_tokens_mistral': 676, 'n_tokens_neox': 661, 'n_words': 183}