<commit_before><?php

namespace RecastAI;

/**
 * Class Response
 * @package RecastAI
 */
class Response
{

    /**
     * Response constructor.
     * @param $response
     */
    public function __construct($json)
    {
      var_dump($json);
        $response = json_decode($json->body);
        $this->entities = [];

        $this->act = $response->results->act;
        $this->type = $response->results->type;
        $this->source = $response->results->source;
        $this->intents = $response->results->intents;
        $this->sentiment = $response->results->sentiment;

        foreach ($response->results->entities as $key => $value) {
            foreach ($value as $i => $entity) {
                $this->entities[] = new Entity($key, $entity);
            }
        }

        $this->uuid = $response->results->uuid;
        $this->language = $response->results->language;
        $this->version = $response->results->version;
        $this->timestamp = $response->results->timestamp;
        $this->status = $response->results->status;
    }

    /**
     * Returns the first Entity whose name matches the parameter
     * @param {String} name: the entity's name
     * @return {Entity}: returns the first entity that matches - name -
     */
    public function get($name)
    {
        $count = count($this->entities);

        for ($i = 0; $i <= $count; $i++) {
            if ($this->entities[$i]->name == $name) {
                return ($this->entities[$i]);
            }
        }

        return null;
    }

    /**
     * Returns all the entities whose name matches the parameter
     * @param {String} name: the entity's name
     * @return {Array}: returns an array of Entity, or null
     */
    public function all($name)
    {
        $count = count($this->entities);
        $res = [];

        for ($i = 0; $i < $count; $i++) {
            if ($this->entities[$i]->name == $name) {
                $res[] = $this->entities[$i];
            }
        }

        return ($res);
    }

    /**
     * Returns the first Intent if there is one
     * @return {Sentence}: returns the first Intent or null
     */
    public function intent()
    {
        if ($this->intents[0]) {
            return ($this->intents[0]);
        }

        return (null);
    }

    /**
     * ACT HELPERS
     * Returns whether or not the response act corresponds to the checked one
     * @return {boolean}: true or false
     */
    public function isAssert()
    {
        return ($this->act === Constants::ACT_ASSERT);
    }

    /**
     * @return bool
     */
    public function isCommand()
    {
        return ($this->act === Constants::ACT_COMMAND);
    }

    /**
     * @return bool
     */<commit_msg>[FIX] modif intent if no intent<commit_after><?php

namespace RecastAI;

/**
 * Class Response
 * @package RecastAI
 */
class Response
{

    /**
     * Response constructor.
     * @param $response
     */
    public function __construct($json)
    {
      var_dump($json);
        $response = json_decode($json->body);
        $this->entities = [];

        $this->act = $response->results->act;
        $this->type = $response->results->type;
        $this->source = $response->results->source;
        $this->intents = $response->results->intents;
        $this->sentiment = $response->results->sentiment;

        foreach ($response->results->entities as $key => $value) {
            foreach ($value as $i => $entity) {
                $this->entities[] = new Entity($key, $entity);
            }
        }

        $this->uuid = $response->results->uuid;
        $this->language = $response->results->language;
        $this->version = $response->results->version;
        $this->timestamp = $response->results->timestamp;
        $this->status = $response->results->status;
    }

    /**
     * Returns the first Entity whose name matches the parameter
     * @param {String} name: the entity's name
     * @return {Entity}: returns the first entity that matches - name -
     */
    public function get($name)
    {
        $count = count($this->entities);

        for ($i = 0; $i <= $count; $i++) {
            if ($this->entities[$i]->name == $name) {
                return ($this->entities[$i]);
            }
        }

        return null;
    }

    /**
     * Returns all the entities whose name matches the parameter
     * @param {String} name: the entity's name
     * @return {Array}: returns an array of Entity, or null
     */
    public function all($name)
    {
        $count = count($this->entities);
        $res = [];

        for ($i = 0; $i < $count; $i++) {
            if ($this->entities[$i]->name == $name) {
                $res[] = $this->entities[$i];
            }
        }

        return ($res);
    }

    /**
     * Returns the first Intent if there is one
     * @return {Sentence}: returns the first Intent or null
     */
    public function intent()
    {
      return ($this->intents[0] || null);
    }

    /**
     * ACT HELPERS
     * Returns whether or not the response act corresponds to the checked one
     * @return {boolean}: true or false
     */
    public function isAssert()
    {
        return ($this->act === Constants::ACT_ASSERT);
    }

    /**
     * @return bool
     */
    public function isCommand()
    {
        return ($this->act === Constants::ACT_COMMAND);
    }

    /**
     * @return bool
     */
{'fraction_non_alphanumeric': 0.15615171137835338, 'fraction_numerical': 0.0012950971322849213, 'mean_word_length': 1.900214592274678, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 100, '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': '3257402', 'n_tokens_mistral': 1552, 'n_tokens_neox': 1527, 'n_words': 400}