<commit_before><?php

namespace MemePuush;


use Imagick;
use ImagickDraw;
use ImagickPixel;

class Caption
{
    /**
     * @var Imagick
     */
    protected $target;

    /**
     * @var ImagickDraw
     */
    protected $draw;

    /**
     * @var ImagickPixel
     */
    protected $pixel;

    /**
     * @var int
     */
    protected $gravity;

    /**
     * @var string
     */
    protected $text;

    /**
     * @var string
     */
    protected $location;

    /**
     * @var int
     */
    protected $stringLength;

    /**
     * @var string
     */
    protected $fontPath = 'fonts/impact.ttf';

    /**
     * @var int
     */
    protected $fontSize;

    /**
     * @var ImagickDraw
     */
    protected $drawLayer;

    /**
     * @var array
     */
    protected $boundingBox;

    /**
     * @var int
     */
    protected $multiplier = 4;
    /**
     * @var bool
     */
    protected $debug = false;

    public function __construct( Image $image, $text, $location = 'top' )
    {
        $this->target = $image;
        $this->setText( $text );
        $this->setLocation( $location );

        //set border params based on location
        if( $this->location == 'top' )
        {
            $this->boundingBox = array(
                'x1'     => 2,
                'x2'     => (int) ( $this->target->getWidth() - 2 ),
                'x'      => (int) ( $this->target->getWidth() / 2 ),
                'width'  => (int) $this->target->getWidth(),
                'y1'     => 2,
                'y2'     => (int) ( ( $this->target->getHeight() / $this->multiplier ) - 2 ),
                'y'      => 10,
                'height' => (int) ( $this->target->getHeight() / $this->multiplier )

            );
        }
        else
        {
            $this->boundingBox = array(
                'x1'     => 2,
                'x2'     => (int) ( $this->target->getWidth() - 2 ),
                'x'      => (int) ( $this->target->getWidth() / 2 ),
                'width'  => (int) $this->target->getWidth(),
                'y1'     => (int) ( $this->target->getHeight() - ( $this->target->getHeight() / $this->multiplier ) - 2 ),
                'y2'     => (int) ( $this->target->getHeight() - 2 ),
                'y'      => (int) ( $this->target->getHeight() - ( $this->target->getHeight() / $this->multiplier ) - 2 ),
                'height' => (int) ( $this->target->getHeight() / $this->multiplier )
            );
        }
    }

    public function setDebug( $debug )
    {
        $this->debug = $debug;
    }

    /**
     * @return bool
     */
    public function isEmpty()
    {
        return ( $this->getStringLength() > 0 ) ? false : true;
    }

    /**
     * @return string
     */
    public function getLocation()
    {
        return $this->location;
    }

    /**
     * @param $location
     */
    private function setLocation( $location )
    {
        $this->location = $location;
    }

    /**
     * @return string
     */
    public function getText()
    {
        return strtoupper( $this->text );
    }

    /**
     * @param string $text
     */
    private function setText( $text )
    {
        $this->text = $text;
    }

    /**
     * @return int
     */
    public function getStringLength()
    {
        return strlen( $this->text );
    }

    /**
     * @param string $fontPath
     */
    public function setFontPath( $fontPath )
    {
        $this->fontPath = $fontPath;
    }<commit_msg>set font path as relative<commit_after><?php

namespace MemePuush;


use Imagick;
use ImagickDraw;
use ImagickPixel;

class Caption
{
    /**
     * @var Imagick
     */
    protected $target;

    /**
     * @var ImagickDraw
     */
    protected $draw;

    /**
     * @var ImagickPixel
     */
    protected $pixel;

    /**
     * @var int
     */
    protected $gravity;

    /**
     * @var string
     */
    protected $text;

    /**
     * @var string
     */
    protected $location;

    /**
     * @var int
     */
    protected $stringLength;

    /**
     * @var string
     */
    protected $fontPath;

    /**
     * @var int
     */
    protected $fontSize;

    /**
     * @var ImagickDraw
     */
    protected $drawLayer;

    /**
     * @var array
     */
    protected $boundingBox;

    /**
     * @var int
     */
    protected $multiplier = 4;
    /**
     * @var bool
     */
    protected $debug = false;

    public function __construct( Image $image, $text, $location = 'top' )
    {
        $this->target = $image;
        $this->setText( $text );
        $this->setLocation( $location );

        //set border params based on location
        if( $this->location == 'top' )
        {
            $this->boundingBox = array(
                'x1'     => 2,
                'x2'     => (int) ( $this->target->getWidth() - 2 ),
                'x'      => (int) ( $this->target->getWidth() / 2 ),
                'width'  => (int) $this->target->getWidth(),
                'y1'     => 2,
                'y2'     => (int) ( ( $this->target->getHeight() / $this->multiplier ) - 2 ),
                'y'      => 10,
                'height' => (int) ( $this->target->getHeight() / $this->multiplier )

            );
        }
        else
        {
            $this->boundingBox = array(
                'x1'     => 2,
                'x2'     => (int) ( $this->target->getWidth() - 2 ),
                'x'      => (int) ( $this->target->getWidth() / 2 ),
                'width'  => (int) $this->target->getWidth(),
                'y1'     => (int) ( $this->target->getHeight() - ( $this->target->getHeight() / $this->multiplier ) - 2 ),
                'y2'     => (int) ( $this->target->getHeight() - 2 ),
                'y'      => (int) ( $this->target->getHeight() - ( $this->target->getHeight() / $this->multiplier ) - 2 ),
                'height' => (int) ( $this->target->getHeight() / $this->multiplier )
            );
        }
    }

    public function setDebug( $debug )
    {
        $this->debug = $debug;
    }

    /**
     * @return bool
     */
    public function isEmpty()
    {
        return ( $this->getStringLength() > 0 ) ? false : true;
    }

    /**
     * @return string
     */
    public function getLocation()
    {
        return $this->location;
    }

    /**
     * @param $location
     */
    private function setLocation( $location )
    {
        $this->location = $location;
    }

    /**
     * @return string
     */
    public function getText()
    {
        return strtoupper( $this->text );
    }

    /**
     * @param string $text
     */
    private function setText( $text )
    {
        $this->text = $text;
    }

    /**
     * @return int
     */
    public function getStringLength()
    {
        return strlen( $this->text );
    }

    /**
     * @param string $fontPath
     */
    public function setFontPath( $fontPath )
    {
        if( !$this->fontPath )
            $this->fontPath = dirname( dirname( __DIR__ . '/fonts/impact.ttf' ) );

        $this->fontPath = $fontPath;
    }
{'fraction_non_alphanumeric': 0.16940509915014165, 'fraction_numerical': 0.006515580736543909, 'mean_word_length': 1.385472972972973, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 133, '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': '3069407', 'n_tokens_mistral': 2311, 'n_tokens_neox': 2206, 'n_words': 446}