<commit_before><?php
namespace rafaelglikis\autogp\Helpers;

use DOMDocument;

class HtmlHelper
{
    // Heuristics
    const SPECIAL_CLASS_NAME_SCORE = 25;
    const IRRELEVANT_CLASS_NAME_SCORE = -50;
    const SPECIAL_ID_NAME_SCORE = 25;
    const IRRELEVANT_ID_NAME_SCORE = -50;


    // Regular Expressions
    const IRRELEVANT_ID_REGEX = "/(comment|meta|footer|footnote)/i";
    const SPECIAL_ID_REGEX = "/((^|\\s)(post|hentry|entry[-]?(content|text|body)?|article[-]?(content|text|body)?)(\\s|$))/i";
    const IRRELEVANT_CLASS_REGEX = "/(comment|meta|footer|footnote)/i";
    const SPECIAL_CLASS_REGEX = "/^(post|hentry|entry[-]?(content|text|body)?|article[-]?(content|text|body)?)$/i";


    /**
     * Takes the html from file or from Url
     * @param $source
     * @return string
     */
    public static function getHtmlFrom($source)
    {
        return file_get_contents($source);
    }

    public static function curl($url)
    {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $data = curl_exec($ch);
        curl_close($ch);

        return $data;
    }
<commit_msg>helpers created<commit_after><?php
namespace rafaelglikis\autogp\Helpers;

use DOMDocument;

class HtmlHelper
{
    // Heuristics
    const SPECIAL_CLASS_NAME_SCORE = 25;
    const IRRELEVANT_CLASS_NAME_SCORE = -50;
    const SPECIAL_ID_NAME_SCORE = 25;
    const IRRELEVANT_ID_NAME_SCORE = -50;



    // Regular Expressions
    const IRRELEVANT_ID_REGEX = "/(comment|meta|footer|footnote)/i";
    const SPECIAL_ID_REGEX = "/((^|\\s)(post|hentry|entry[-]?(content|text|body)?|article[-]?(content|text|body)?)(\\s|$))/i";
    const IRRELEVANT_CLASS_REGEX = "/(comment|meta|footer|footnote)/i";
    const SPECIAL_CLASS_REGEX = "/^(post|hentry|entry[-]?(content|text|body)?|article[-]?(content|text|body)?)$/i";


    /**
     * Takes the html from file or from Url
     * @param $source
     * @return string
     */
    public static function getHtmlFrom($source)
    {
        return file_get_contents($source);
    }

    public static function curl($url)
    {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $data = curl_exec($ch);
        curl_close($ch);

        return $data;
    }

{'fraction_non_alphanumeric': 0.14912654452492544, 'fraction_numerical': 0.007669365146996165, 'mean_word_length': 3.3401109057301293, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '1452226', 'n_tokens_mistral': 863, 'n_tokens_neox': 822, 'n_words': 139}