<commit_before><?php

// Default list of external phone book providers,
// may be overridden in "config.php"
if(!isset($providers))
{
	$providers = array();
}

// Default list of free_mailers,
// may be overridden in "config.php"
if(!isset($free_mailers))
{
  // List of excluded sites in "Homepage guessing"
  $free_mailers = array();
}

function guessOneHomepage($email) {

	global $free_mailers;

	$homepage = substr($email, strpos($email, '@')+1);
        foreach ($free_mailers as $free_mailer)
        {
              if( strpos($homepage, $free_mailer) !== FALSE && strpos($homepage, $free_mailer) == 0)
              {
	             $homepage = "";
	      }
        }

	if(strlen($homepage) == 0)
	{
		return "";
	} else {
		return "www.$homepage";
	}
}


function guessHomepage($email1, $email2) {

	if($email1 != "") {
	$homepage = guessOneHomepage($email1);
	if(strlen($homepage) > 0)
	{
		return $homepage;
	}
  }

	if($email2 != "") {
	$homepage = guessOneHomepage($email2);
	if(strlen($homepage) > 0)
	{
		return $homepage;
	}
	}

	return "";

}

function guessAddressFields($address) {
	
  global $company_exts, $title_exts;
  
  if(!isset($company_exts)) $company_exts = array();
  if(!isset($title_exts))   $title_exts   = array();

  $new_addr_list = array();

	$address = preg_replace("/--(-)*/", "", $address);
	$address = preg_replace("/__(_)*/", "", $address);
	$address = preg_replace("/==(=)*/", "", $address);
  //
  // Preprocess:
  // * Revert "mysql_real_escape"
  // * Split into block (newline, pipe, colon)
  // * Remove whitespaces & empty lines
  //  
	$address = stripslashes($address);
	$sign_delims = "�*|,-";
	$addr_list = preg_split("/(\n|\s?[".$sign_delims."]\s)/", $address);
	for($i = 0; $i < count($addr_list); $i++) {
		$addr_line = $addr_list[$i];
		$addr_line = trim($addr_line);
		if($addr_line != "" && $addr_line != null) {
		  $new_addr_list[] = $addr_line;
	  }
	}
	$addr_list = $new_addr_list;

	$is_phone = false;
	$is_url   = false;
	
	$unparsed_addr_lines = array();
	$phones    = array();
	$mails     = array();
	// $company   = "";
	// $homepage  = "";

	$firstname = "";
	$lastname  = "";
  $has_name  = false;
	
	for($i = 0; $i < count($addr_list); $i++) {
		
		$addr_line = $addr_list[$i];
		$addr_line = trim($addr_line);
		$addr_line = preg_replace('/^\p{Z}+|\p{Z}+$/u','',$addr_line);
		$addr_line = str_replace("(at)",  "@", $addr_line);
		$addr_line = str_replace("{at}",  "@", $addr_line);
		$addr_line = str_replace("'at'",  "@", $addr_line);
		$addr_line = str_replace("'dot'", ".", $addr_line);
		$keep_line = true;
		
		if(function_exists("mb_strtoupper")) {
		  $addr_line_upper = mb_strtoupper($addr_line);
		} else {
		  $addr_line_upper = strtoupper($addr_line);
		}

	  if((!isset($company) || $company == "")
	     && function_exists("mb_ereg_match")
	     && mb_ereg_match("(^|.* )(".implode("|", $company_exts).")(\W|$)", $addr_line_upper)) {
	  	$company = $addr_line;
		  $keep_line = false;
	  } elseif((!isset($title) || $title == "")
	     && function_exists("mb_ereg_match")
	     && mb_ereg_match("(^|.* |.*-)(".implode("|", $title_exts).")(\W|$)", $addr_line_upper)) {
	  	$title = $addr_line;
		  $keep_line = false;
	  } else

    //
    // fistname Lastname
    //
	  if(! $has_name) {
	  	$names = explode(" ", $addr_line, 2);
	  	$firstname = $names[0];
	  	$lastname  = "";<commit_msg>- Fix: Remove deprecated regexp.<commit_after><?php

// Default list of external phone book providers,
// may be overridden in "config.php"
if(!isset($providers))
{
	$providers = array();
}

// Default list of free_mailers,
// may be overridden in "config.php"
if(!isset($free_mailers))
{
  // List of excluded sites in "Homepage guessing"
  $free_mailers = array();
}

function guessOneHomepage($email) {

	global $free_mailers;

	$homepage = substr($email, strpos($email, '@')+1);
        foreach ($free_mailers as $free_mailer)
        {
              if( strpos($homepage, $free_mailer) !== FALSE && strpos($homepage, $free_mailer) == 0)
              {
	             $homepage = "";
	      }
        }

	if(strlen($homepage) == 0)
	{
		return "";
	} else {
		return "www.$homepage";
	}
}


function guessHomepage($email1, $email2) {

	if($email1 != "") {
	$homepage = guessOneHomepage($email1);
	if(strlen($homepage) > 0)
	{
		return $homepage;
	}
  }

	if($email2 != "") {
	$homepage = guessOneHomepage($email2);
	if(strlen($homepage) > 0)
	{
		return $homepage;
	}
	}

	return "";

}

function guessAddressFields($address) {
	
  global $company_exts, $title_exts;
  
  if(!isset($company_exts)) $company_exts = array();
  if(!isset($title_exts))   $title_exts   = array();

  $new_addr_list = array();

	$address = preg_replace("/--(-)*/", "", $address);
	$address = preg_replace("/__(_)*/", "", $address);
	$address = preg_replace("/==(=)*/", "", $address);
  //
  // Preprocess:
  // * Revert "mysql_real_escape"
  // * Split into block (newline, pipe, colon)
  // * Remove whitespaces & empty lines
  //  
	$address = stripslashes($address);
	$sign_delims = "�*|,-";
	$addr_list = preg_split("/(\n|\s?[".$sign_delims."]\s)/", $address);
	for($i = 0; $i < count($addr_list); $i++) {
		$addr_line = $addr_list[$i];
		$addr_line = trim($addr_line);
		if($addr_line != "" && $addr_line != null) {
		  $new_addr_list[] = $addr_line;
	  }
	}
	$addr_list = $new_addr_list;

	$is_phone = false;
	$is_url   = false;
	
	$unparsed_addr_lines = array();
	$phones    = array();
	$mails     = array();
	// $company   = "";
	// $homepage  = "";

	$firstname = "";
	$lastname  = "";
  $has_name  = false;
	
	for($i = 0; $i < count($addr_list); $i++) {
		
		$addr_line = $addr_list[$i];
		$addr_line = trim($addr_line);
		// $addr_line = preg_replace('/^\p{Z}+|\p{Z}+$/u','',$addr_line);
		$addr_line = str_replace("(at)",  "@", $addr_line);
		$addr_line = str_replace("{at}",  "@", $addr_line);
		$addr_line = str_replace("'at'",  "@", $addr_line);
		$addr_line = str_replace("'dot'", ".", $addr_line);
		$keep_line = true;
		
		if(function_exists("mb_strtoupper")) {
		  $addr_line_upper = mb_strtoupper($addr_line);
		} else {
		  $addr_line_upper = strtoupper($addr_line);
		}

	  if((!isset($company) || $company == "")
	     && function_exists("mb_ereg_match")
	     && mb_ereg_match("(^|.* )(".implode("|", $company_exts).")(\W|$)", $addr_line_upper)) {
	  	$company = $addr_line;
		  $keep_line = false;
	  } elseif((!isset($title) || $title == "")
	     && function_exists("mb_ereg_match")
	     && mb_ereg_match("(^|.* |.*-)(".implode("|", $title_exts).")(\W|$)", $addr_line_upper)) {
	  	$title = $addr_line;
		  $keep_line = false;
	  } else

    //
    // fistname Lastname
    //
	  if(! $has_name) {
	  	$names = explode(" ", $addr_line, 2);
	  	$firstname = $names[0];
	  	$lastname  = "";
{'fraction_non_alphanumeric': 0.21892530262769413, 'fraction_numerical': 0.0044286979627989375, 'mean_word_length': 3.445538057742782, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4853601', 'n_tokens_mistral': 2751, 'n_tokens_neox': 2618, 'n_words': 440}