<commit_before><?php

namespace Vimeo\ABLincoln\Operators;

/**
 * Easiest way to implement simple operators. The class automatically evaluates
 * the values of all parameters passed in via execute(), and stores the mapper 
 * object and evaluated parameters as instance variables.  The user can then 
 * extend AbstractOperator and implement simpleExecute().
 */
abstract class AbstractOperator
{
    protected $args;
    protected $parameters;
    protected $mapper;

    /**
     * Store the set of parameters to use as required and optional arguments
     *
     * @param array $args array mapping operator parameters to values
     */
    public function __construct($args)
    {
        $this->args = $args;
    }

    /**
     * Evaluate all parameters and store as instance variables, then execute
     * the operator as defined in simpleExecute()
     *
     * @param Assignment $mapper mapper object used to evaluate parameters
     * @return mixed the evaluated expression
     */
    public function execute($mapper)
    {
        $this->mapper = $mapper;
        $this->parameters = array();  // evaluated parameters
        foreach ($this->args as $key => $val) {
            $this->parameters[$key] = $mapper->evaluate($val);
        }
        return $this->simpleExecute();
    }

    /**
     * Implement with operator functionality
     *
     * @return mixed the evaluated expression
     */
    abstract protected function simpleExecute();

    /**
     * All operators must specify required and optional arguments to be used in
     * execute() by defining options(). The function should return an array 
     * formatted like so:
     *   array (
     *     'p' => array('required' => 1, 'description' => 'probability of success')
     *     'n' => array('required' => 0, 'description' => 'number of samples')
     *   )
     *
     * @return array array of required and optional arguments
     */
    public function options()
    {
        return array();
    }

    /**
     * Get array of all parameters belonging to the operation instance.
     *
     * @return array parameter array
     */
    public function getOptions()
    {
        if (!strcmp(get_class($this), 'Op')) {<commit_msg>fixed recursive options method to work with namespaces + new class names<commit_after><?php

namespace Vimeo\ABLincoln\Operators;

/**
 * Easiest way to implement simple operators. The class automatically evaluates
 * the values of all parameters passed in via execute(), and stores the mapper 
 * object and evaluated parameters as instance variables.  The user can then 
 * extend AbstractOperator and implement simpleExecute().
 */
abstract class AbstractOperator
{
    protected $args;
    protected $parameters;
    protected $mapper;

    /**
     * Store the set of parameters to use as required and optional arguments
     *
     * @param array $args array mapping operator parameters to values
     */
    public function __construct($args)
    {
        $this->args = $args;
    }

    /**
     * Evaluate all parameters and store as instance variables, then execute
     * the operator as defined in simpleExecute()
     *
     * @param Assignment $mapper mapper object used to evaluate parameters
     * @return mixed the evaluated expression
     */
    public function execute($mapper)
    {
        $this->mapper = $mapper;
        $this->parameters = array();  // evaluated parameters
        foreach ($this->args as $key => $val) {
            $this->parameters[$key] = $mapper->evaluate($val);
        }
        return $this->simpleExecute();
    }

    /**
     * Implement with operator functionality
     *
     * @return mixed the evaluated expression
     */
    abstract protected function simpleExecute();

    /**
     * All operators must specify required and optional arguments to be used in
     * execute() by defining options(). The function should return an array 
     * formatted like so:
     *   array (
     *     'p' => array('required' => 1, 'description' => 'probability of success')
     *     'n' => array('required' => 0, 'description' => 'number of samples')
     *   )
     *
     * @return array array of required and optional arguments
     */
    public function options()
    {
        return array();
    }

    /**
     * Get array of all parameters belonging to the operation instance.
     *
     * @return array parameter array
     */
    public function getOptions()
    {
        if (!strcmp(get_class($this), get_class())) {
{'fraction_non_alphanumeric': 0.09848821698532681, 'fraction_numerical': 0.0008892841262783459, 'mean_word_length': 2.5537124802527646, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, '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': '6809915', 'n_tokens_mistral': 1131, 'n_tokens_neox': 1109, 'n_words': 432}