From 2e0c957544fe4f04b2f208d0720838531f41d19d Mon Sep 17 00:00:00 2001
From: University <younes@youness-MacBook-Pro.local>
Date: Thu, 13 Feb 2025 11:43:21 +0100
Subject: [PATCH] construction mphf

---
 tp_2_miso_mphf.py | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/tp_2_miso_mphf.py b/tp_2_miso_mphf.py
index a87b444..18df0ab 100644
--- a/tp_2_miso_mphf.py
+++ b/tp_2_miso_mphf.py
@@ -46,7 +46,7 @@ def construction_mphf(set_kmer, n, gamma=2, nb_niveaux=3):
 				if tableau_principal[address] != -1:
 					collision.add(kmer)
 				else :
-					tableau_principal[address] = kmer
+					tableau_principal[address] = h
 
 			tableaux.append(tableau_principal) # Addition du tableau du dernier niveau dans un tableau contenant tous les tableaux des précédents niveaux
 			set_kmer_courant = collision.copy() # Création d'un set de kmer à partir des collisions pour créer tableau du niveau suivant
@@ -58,17 +58,16 @@ def construction_mphf(set_kmer, n, gamma=2, nb_niveaux=3):
 	for tableau in tableaux:
 		grand_tableau.extend(tableau) # Concaténation de tous les tableaux de niveaux
 
-	rangs = []
+
 	max_rang = 0
-	i = 0
+
 	for kmer in set_kmer:
-		pass # compléter:
-		# hacher le kmer
-		# si le hash est dans le grand_tableau
-			# récupérer son index
-			# récupérer son rang (utiliser la fonction count())
-			# ajouter à la mphf [h, rang]
-			# mettre à jour max_rang
+		h = hash(kmer)
+		if h in grand_tableau:
+			index = grand_tableau.index(h)
+			rang = index - grand_tableau[:index + 1].count(-1)
+			mphf.append((h, rang))
+			max_rang = max(max_rang, rang)
 
 	for kmer in set_kmer_courant: #gestion des collisions: expliquer les 3 lignes du dessous
 		max_rang += 1
-- 
GitLab