<commit_before><?php
/**
 * This class has been auto-generated by the Doctrine ORM Framework
 */
class ParlementaireTable extends PersonnaliteTable
{
  public function findOneByNomSexeGroupeCirco($nom, $sexe = null, $groupe = null, $circo = null, $document = null) {
    $depute = null;
    $memeNom = $this->findByNom($nom);
    if (count($memeNom) != 1 && ($circo)) {
      $query = $this->createQuery('p')
        ->where('p.nom_de_famille = ?', $nom)
        ->andWhere('p.nom_circo LIKE ?', $circo);
      $memeNom = $query->execute();
    }
    if (count($memeNom) == 0 && ($circo)) {
      $query = $this->createQuery('p')
        ->where('p.nom = ?', $nom)
        ->andWhere('p.nom_circo LIKE ?', $circo);
      $memeNom = $query->execute();
    }
    if (count($memeNom) == 0 && ($circo)) {
      $memeNom = $this->findByNom($circo." ".$nom);
    }
    if (count($memeNom) == 0) {
      $query = $this->createQuery('p')
        ->where('p.nom_de_famille = ?' , $nom);
      if ($document) $query->andWhere('p.fin_mandat is null or p.fin_mandat > ?', $document->getDate());
      $memeNom = $query->execute();
    }
    if (count($memeNom) > 1) {
      $exactNom = array();
      foreach ($memeNom as $d) if ($d->nom_de_famille == $nom)
        $exactNom[] = $d;
      if (count($exactNom) == 1) $memeNom = $exactNom;
    }
    if (count($memeNom) == 0 && preg_match('/(Des |des |de La |de la |de l\'|de |du )?([A-ZÉ].*) ([A-ZÉ].*)/', $nom, $match)) {
      $revert_nom = $match[3]." ".$match[1].$match[2];
      $memeNom = $this->findByNom($revert_nom);
    }
    if (count($memeNom) == 0) $depute = $this->similarTo(preg_replace('/^\s*(de |du |la )+\s*/i', '', $nom), $sexe);
    elseif (count($memeNom) == 1) $depute = $memeNom[0];
    else {
      $memeSexe = array();
      if ($sexe) {
        foreach ($memeNom as $de)
          if ($de->sexe == $sexe) array_push($memeSexe, $de);
        if (count($memeSexe) == 1) $depute = $memeSexe[0];
      }
      if (!$depute && $groupe) {
        $memeGroupe = array();
        $procheGroupe = array();
        if (count($memeSexe) == 0) $memeSexe = $memeNom;
        foreach ($memeSexe as $de) {
          $groupe2 = $de->groupe_acronyme;
          if ($groupe2 === $groupe) array_push($memeGroupe, $de);
          else foreach(myTools::convertYamlToArray(sfConfig::get('app_groupes_proximite', '')) as $gpe) {
            $gpes = explode(' / ', $gpe);
            if (($groupe2 === $gpes[0] && $groupe === $gpes[1]) || ($groupe2 === $gpes[1] && $groupe === $gpes[0]))
              array_push($procheGroupe, $de);
          }
        }
        if (count($memeGroupe) == 1) $depute = $memeGroupe[0];
        elseif (count($procheGroupe) == 1) $depute = $procheGroupe[0];
        unset($memeGroupe);
        unset($procheGroupe);
      }<commit_msg>handle homonymes hors mandat<commit_after><?php
/**
 * This class has been auto-generated by the Doctrine ORM Framework
 */
class ParlementaireTable extends PersonnaliteTable
{
  public function findOneByNomSexeGroupeCirco($nom, $sexe = null, $groupe = null, $circo = null, $document = null) {
    $depute = null;
    $memeNom = $this->findByNom($nom);
    if (count($memeNom) != 1 && ($circo)) {
      $query = $this->createQuery('p')
        ->where('p.nom_de_famille = ?', $nom)
        ->andWhere('p.nom_circo LIKE ?', $circo);
      $memeNom = $query->execute();
    }
    if (count($memeNom) == 0 && ($circo)) {
      $query = $this->createQuery('p')
        ->where('p.nom = ?', $nom)
        ->andWhere('p.nom_circo LIKE ?', $circo);
      $memeNom = $query->execute();
    }
    if (count($memeNom) == 0 && ($circo)) {
      $memeNom = $this->findByNom($circo." ".$nom);
    }
    if (count($memeNom) == 0) {
      $query = $this->createQuery('p')
        ->where('p.nom_de_famille = ?' , $nom);
      if ($document) $query->andWhere('p.fin_mandat is null or p.fin_mandat > ?', $document->getDate());
      $memeNom = $query->execute();
    }
    if (count($memeNom) > 1) {
      $exactNom = array();
      foreach ($memeNom as $d) if ($d->nom_de_famille == $nom)
        $exactNom[] = $d;
      if (count($exactNom) == 1) $memeNom = $exactNom;
    }
    if (count($memeNom) == 0 && preg_match('/(Des |des |de La |de la |de l\'|de |du )?([A-ZÉ].*) ([A-ZÉ].*)/', $nom, $match)) {
      $revert_nom = $match[3]." ".$match[1].$match[2];
      $memeNom = $this->findByNom($revert_nom);
    }
    if (count($memeNom) == 0) $depute = $this->similarTo(preg_replace('/^\s*(de |du |la )+\s*/i', '', $nom), $sexe);
    elseif (count($memeNom) == 1) $depute = $memeNom[0];
    else {
      $memeSexe = array();
      if ($sexe) {
        foreach ($memeNom as $de)
          if ($de->sexe == $sexe) array_push($memeSexe, $de);
        if (count($memeSexe) == 1) $depute = $memeSexe[0];
      }
      if (!$depute && $groupe) {
        $memeGroupe = array();
        $procheGroupe = array();
        if (count($memeSexe) == 0) $memeSexe = $memeNom;
        foreach ($memeSexe as $de) {
          $groupe2 = $de->groupe_acronyme;
          if ($groupe2 === $groupe) array_push($memeGroupe, $de);
          else foreach(myTools::convertYamlToArray(sfConfig::get('app_groupes_proximite', '')) as $gpe) {
            $gpes = explode(' / ', $gpe);
            if (($groupe2 === $gpes[0] && $groupe === $gpes[1]) || ($groupe2 === $gpes[1] && $groupe === $gpes[0]))
              array_push($procheGroupe, $de);
          }
        }
        if (count($memeGroupe) == 1) $depute = $memeGroupe[0];
        elseif (count($procheGroupe) == 1) $depute = $procheGroupe[0];
        $memeSexe = $memeGroupe;
        unset($memeGroupe);
        unset($procheGroupe);
      }
      if (!$depute) {
        $enmandat = array();
        foreach ($memeSexe as $de)
          if (!$de->fin_mandat) array_push($enmandat, $de);
        if (count($enmandat) == 1) $depute = $enmandat[0];
      }
{'fraction_non_alphanumeric': 0.2131063829787234, 'fraction_numerical': 0.009872340425531916, 'mean_word_length': 2.686323713927227, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 48, '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': '4815823', 'n_tokens_mistral': 2346, 'n_tokens_neox': 2237, 'n_words': 436}