<commit_before><?php

class url  extends __native {
  protected $_accessibles = array('query');

  function __construct($url){
    $this->data  = urls::parse($url);
    if(!$url) $this->empty = true;
  }

  static function from($url){
    return ($url instanceof url)?$url:new url($url);
  }

  function merge($url){
    if($url->empty) return $this;
    if($this->is_relative) return $url;

    if($url->host && $this->host != $url->host) return $url;
    if($url->scheme && $this->scheme  != $url->scheme) return $url;

    $path = files::paths_merge($this->path, $url->path);
    $merge = array_filter(array(
        'host'=>$this->host,
        'scheme'=>$this->scheme,
        'path'=>$path,
        'query'=> $url->query?$url->query:($path!=$this->path?false:$this->query),
        'fragment'=>$url->fragment,
    ));
    return new url($merge);
  }

  function is_ssl(){
    return $this->scheme == 'https';
  }

  function is_relative(){
    return substr($this->path,0,1)!="/";
  }

  function is_absolute(){
    return !$this->is_relative;
  }
  function is_browsable(){
    return isset($this['scheme']) && isset($this['host']) && isset($this['path']);
  }

  function get_hash($full = false){
    if(!$this->scheme || !$this->host)
        throw new Exception("Partial url");

    $str = "{$this->scheme}://{$this->host}";
    $str .=$this->path;
    if($full){
        if($this->query)$str.="?{$this->query}";
        if($this->fragment)$str.="#{$this->fragment}";
    } return $str;
  }

  function get_http_query(){
    $str = $this->path;
    if($this->query)$str.="?".($this->query);
    return $str;
  }


  function __toString(){
    try {
        return $this->get_hash(true);
    } catch(Exception $e){
        return "##!!invalid partial url ##";
    }
  }
}<commit_msg>url serialisation, tolerant mode<commit_after><?php

class url  extends __native {
  protected $_accessibles = array('query', 'host');

  function __construct($url){
    $this->data  = urls::parse($url);
    if(!$url) $this->empty = true;
  }

  static function from($url){
    return ($url instanceof url)?$url:new url($url);
  }

  function merge($url){
    if($url->empty) return $this;
    if($this->is_relative) return $url;

    if($url->host && $this->host != $url->host) return $url;
    if($url->scheme && $this->scheme  != $url->scheme) return $url;

    $path = files::paths_merge($this->path, $url->path);
    $merge = array_filter(array(
        'host'=>$this->host,
        'scheme'=>$this->scheme,
        'path'=>$path,
        'query'=> $url->query?$url->query:($path!=$this->path?false:$this->query),
        'fragment'=>$url->fragment,
    ));
    return new url($merge);
  }

  function is_ssl(){
    return $this->scheme == 'https';
  }

  function is_relative(){
    return substr($this->path,0,1)!="/";
  }

  function is_absolute(){
    return !$this->is_relative;
  }
  function is_browsable(){
    return isset($this['scheme']) && isset($this['host']) && isset($this['path']);
  }

  function get_hash($full = false){
    if(!$this->scheme || !$this->host)
       $str = "[Partial url]";
    else $str = "{$this->scheme}://{$this->host}";
    $str .= $this->get_client_part($full);
    return $str;
  }

  function get_client_part($full = true){
    $str = $this->path;
    if($full){
        if($this->query)$str.="?{$this->query}";
        if($this->fragment)$str.="#{$this->fragment}";
    }
    return $str;
  }

  function get_http_query(){
    $str = $this->path;
    if($this->query)$str.="?".($this->query);
    return $str;
  }


  function __toString(){
    return $this->get_hash(true);
  }
}
{'fraction_non_alphanumeric': 0.22286661143330572, 'fraction_numerical': 0.0011046672190002762, 'mean_word_length': 3.2313084112149535, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 84, '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': '5635430', 'n_tokens_mistral': 1251, 'n_tokens_neox': 1230, 'n_words': 224}