<commit_before><?php
/* 
 * 
 * 
 */

class EntitiesAcronymsFetcher {

    private static $instance;
    public $acronyms;
    public $entities;

    public static function getInstance()
    {
        if (!isset(self::$instance)) {
            $c = __CLASS__;
            self::$instance = new $c;
        }
        return self::$instance;
    }

    public function __construct()
    {
        $this->parseAcronyms();
        $this->parseEntities();
    }

    private function parseAcronyms()
    {
        $am = AccountManager::getInstance();
        $appConf = $am->appConf;
        $project = $am->project;

        $files = explode("|", $appConf[$project]['acronym.usedbyeditor.location']);

        $count = 0;
        while( list($k, $file) = each($files))
        {
            $content = file_get_contents($file);
            preg_match_all('/<varlistentry>(.*?)<term>(.*?)<\/term>(.*?)<simpara>(.*?)<\/simpara>(.*?)<\/varlistentry>/s', $content, $match);

            $from = explode('/',$file);

            for( $i=0; $i < count($match[2]); $i++ ) {
                if( trim($match[2][$i]) != "" ) {
                    $this->acronyms[$count]['id']       = $count;
                    $this->acronyms[$count]['from']     = $from[count($from)-1];
                    $this->acronyms[$count]['items']    = $match[2][$i];
                    $this->acronyms[$count]['value']    = htmlentities($match[4][$i]);
                    $count ++;
                }
            }
        }

    }

    private function parseEntities()
    {
        $am = AccountManager::getInstance();
        $appConf = $am->appConf;
        $project = $am->project;

        $files = explode("|", $appConf[$project]['entities.usedbyeditor.location']);

        $count = 0;
        while( list($k, $file) = each($files))
        {
            $content = file_get_contents($file);
            preg_match_all('/<!ENTITY\s(.*?)\s(\'|")(.*?)(\2)>/s', $content, $match);

            $from = explode('/',$file);

            for( $i=0; $i < count($match[1]); $i++ ) {
                $this->entities[$count]['id']       = $count;
                $this->entities[$count]['from']     = $from[count($from)-1];
                $this->entities[$count]['items']    = $match[1][$i];
                $this->entities[$count]['value']    = htmlentities($match[3][$i]);
                $count ++;
            }
        }

    }

    public function getEntities()<commit_msg>Exclude acronyms/entities if the path isn't correct into the config project file<commit_after><?php
/* 
 * 
 * 
 */

class EntitiesAcronymsFetcher {

    private static $instance;
    public $acronyms;
    public $entities;

    public static function getInstance()
    {
        if (!isset(self::$instance)) {
            $c = __CLASS__;
            self::$instance = new $c;
        }
        return self::$instance;
    }

    public function __construct()
    {
        $this->parseAcronyms();
        $this->parseEntities();
    }

    private function parseAcronyms()
    {
        $am = AccountManager::getInstance();
        $appConf = $am->appConf;
        $project = $am->project;

        $files = explode("|", $appConf[$project]['acronym.usedbyeditor.location']);

        unset($this->acronyms);

        $count = 0;
        while( list($k, $file) = each($files))
        {
            if( $content = file_get_contents($file) ) {
                continue;
            }

            preg_match_all('/<varlistentry>(.*?)<term>(.*?)<\/term>(.*?)<simpara>(.*?)<\/simpara>(.*?)<\/varlistentry>/s', $content, $match);

            $from = explode('/',$file);

            for( $i=0; $i < count($match[2]); $i++ ) {
                if( trim($match[2][$i]) != "" ) {
                    $this->acronyms[$count]['id']       = $count;
                    $this->acronyms[$count]['from']     = $from[count($from)-1];
                    $this->acronyms[$count]['items']    = $match[2][$i];
                    $this->acronyms[$count]['value']    = htmlentities($match[4][$i]);
                    $count ++;
                }
            }
        }

    }

    private function parseEntities()
    {
        $am = AccountManager::getInstance();
        $appConf = $am->appConf;
        $project = $am->project;

        $files = explode("|", $appConf[$project]['entities.usedbyeditor.location']);

        unset($this->entities);
            
        $count = 0;
        while( list($k, $file) = each($files))
        {        
            if( $content = file_get_contents($file) ) {
                continue;
            }
            
            preg_match_all('/<!ENTITY\s(.*?)\s(\'|")(.*?)(\2)>/s', $content, $match);

            $from = explode('/',$file);

            for( $i=0; $i < count($match[1]); $i++ ) {
                $this->entities[$count]['id']       = $count;
                $this->entities[$count]['from']     = $from[count($from)-1];
                $this->entities[$count]['items']    = $match[1][$i];
                $this->entities[$count]['value']    = htmlentities($match[3][$i]);
                $count ++;
            }
        }

    }

    public function getEntities()
{'fraction_non_alphanumeric': 0.19833106928003105, 'fraction_numerical': 0.005433727925480303, 'mean_word_length': 1.7844408427876823, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 47, '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': '1340707', 'n_tokens_mistral': 1620, 'n_tokens_neox': 1586, 'n_words': 238}