<commit_before><?php

namespace Bolt;

use Silex;

class Content implements \ArrayAccess
{
    private $app;
    public $id;
    public $values;
    public $taxonomy;
    public $relation;
    public $contenttype;

    // The last time we weight a searchresult
    private $last_weight = 0;

    public function __construct(Silex\Application $app, $contenttype = "", $values = "")
    {

        $this->app = $app;

        if (!empty($contenttype)) {
            // Set the contenttype
            $this->setContenttype($contenttype);

            // If this contenttype has a taxonomy with 'grouping', initialize the group.
            if (isset($this->contenttype['taxonomy'])) {
                foreach ($this->contenttype['taxonomy'] as $taxonomytype) {
                    if ($this->app['config']->get('taxonomy/'.$taxonomytype.'/behaves_like') == "grouping") {
                        $this->setGroup('', '', $taxonomytype);
                    }
                }
            }
        }

        $this->user = $this->app['users']->getCurrentUser();

        if (!empty($values)) {
            $this->setValues($values);
        } else {
            // Ininitialize fields with empty values.
            $values = array();
            if (is_array($this->contenttype)) {
                foreach ($this->contenttype['fields'] as $key => $parameters) {
                    // Set the default values.
                    if (isset($parameters['default'])) {
                        $values[$key] = $parameters['default'];
                    } else {
                        $values[$key] = '';
                    }
                }
            }

            if (!empty($this->contenttype['singular_name'])) {
                $contenttypename = $this->contenttype['singular_name'];
            } else {
                $contenttypename = "unknown";
            }
            // Specify an '(undefined contenttype)'..
            $values['name'] = "(undefined $contenttypename)";
            $values['title'] = "(undefined $contenttypename)";
<commit_msg>axonomy default value<commit_after><?php

namespace Bolt;

use Silex;

class Content implements \ArrayAccess
{
    private $app;
    public $id;
    public $values;
    public $taxonomy;
    public $relation;
    public $contenttype;

    // The last time we weight a searchresult
    private $last_weight = 0;

    public function __construct(Silex\Application $app, $contenttype = "", $values = "")
    {

        $this->app = $app;

        if (!empty($contenttype)) {
            // Set the contenttype
            $this->setContenttype($contenttype);

            // If this contenttype has a taxonomy with 'grouping', initialize the group.
            if (isset($this->contenttype['taxonomy'])) {
                foreach ($this->contenttype['taxonomy'] as $taxonomytype) {
                    if ($this->app['config']->get('taxonomy/'.$taxonomytype.'/behaves_like') == "grouping") {
                        $this->setGroup('', '', $taxonomytype);
                    }
					
					// add support for taxonomy default value when options is set 
					$default_value = $this->app['config']->get('taxonomy/'.$taxonomytype.'/default');
					$options = $this->app['config']->get('taxonomy/'.$taxonomytype.'/options');
					if ( 	isset( $options ) &&
							isset($default_value) && 
							array_search($default_value, array_keys($options)) !== false ) {
							$name = $this->app['config']->get('taxonomy/'.$taxonomytype.'/options/'.$default_value);
							$this->setTaxonomy($taxonomytype, $default_value);
							$this->sortTaxonomy();
					}
                }
            }
        }

        $this->user = $this->app['users']->getCurrentUser();

        if (!empty($values)) {
            $this->setValues($values);
        } else {
            // Ininitialize fields with empty values.
            $values = array();
            if (is_array($this->contenttype)) {
                foreach ($this->contenttype['fields'] as $key => $parameters) {
                    // Set the default values.
                    if (isset($parameters['default'])) {
                        $values[$key] = $parameters['default'];
                    } else {
                        $values[$key] = '';
                    }
                }
            }

            if (!empty($this->contenttype['singular_name'])) {
                $contenttypename = $this->contenttype['singular_name'];
            } else {
                $contenttypename = "unknown";
            }
            // Specify an '(undefined contenttype)'..
            $values['name'] = "(undefined $contenttypename)";
            $values['title'] = "(undefined $contenttypename)";

{'fraction_non_alphanumeric': 0.15072278911564627, 'fraction_numerical': 0.00042517006802721087, 'mean_word_length': 1.7774498229043683, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, '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': '6578131', 'n_tokens_mistral': 1308, 'n_tokens_neox': 1206, 'n_words': 256}