huhuuicoxrweRQYsxdcfvypfsurwefgiyu^y
This commit is contained in:
parent
82ce381418
commit
211ddbee93
|
|
@ -52,6 +52,7 @@ public class Avis {
|
||||||
else note = 1.0;
|
else note = 1.0;
|
||||||
|
|
||||||
sommenote += note;
|
sommenote += note;
|
||||||
|
System.out.println("lasommeest"+sommenote);
|
||||||
} else {
|
} else {
|
||||||
// Si aucun mot utile dans le commentaire, on peut ignorer ou mettre une note neutre (par ex. 3)
|
// Si aucun mot utile dans le commentaire, on peut ignorer ou mettre une note neutre (par ex. 3)
|
||||||
sommenote += 3.0;
|
sommenote += 3.0;
|
||||||
|
|
@ -61,10 +62,10 @@ public class Avis {
|
||||||
if (!a.isEmpty()) {
|
if (!a.isEmpty()) {
|
||||||
return (int) Math.round(sommenote / a.size());
|
return (int) Math.round(sommenote / a.size());
|
||||||
} else {
|
} else {
|
||||||
|
System.out.println("cestlamerde");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public String getCommentaire() {
|
public String getCommentaire() {
|
||||||
|
|
|
||||||
|
|
@ -42,11 +42,12 @@ public class Inter extends JFrame {
|
||||||
private ListeAvis listeAvis;
|
private ListeAvis listeAvis;
|
||||||
private String cheminBigCsv;
|
private String cheminBigCsv;
|
||||||
private String cheminDictionnaire;
|
private String cheminDictionnaire;
|
||||||
|
private Dictionnaire dico;
|
||||||
|
|
||||||
// Cache des données
|
// Cache des données
|
||||||
// private final Map<Integer, List<String>> commentairesFilms = new HashMap<>();
|
// private final Map<Integer, List<String>> commentairesFilms = new HashMap<>();
|
||||||
private final Map<Integer, Integer> notesFilms = new HashMap<>();
|
private final Map<Integer, Integer> notesFilms = new HashMap<>();
|
||||||
private final Map<String, Integer> dictionnaireSentiments = new HashMap<>();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Launch the application.
|
* Launch the application.
|
||||||
|
|
@ -70,7 +71,8 @@ public class Inter extends JFrame {
|
||||||
cheminBigCsv = "";
|
cheminBigCsv = "";
|
||||||
cheminDictionnaire = "";
|
cheminDictionnaire = "";
|
||||||
|
|
||||||
initialiserDictionnaireSentiments();
|
|
||||||
|
|
||||||
initialiserInterface();
|
initialiserInterface();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -173,13 +175,13 @@ public class Inter extends JFrame {
|
||||||
listeAvis = new ListeAvis(cheminBigCsv);
|
listeAvis = new ListeAvis(cheminBigCsv);
|
||||||
|
|
||||||
// Créer ou charger le dictionnaire
|
// Créer ou charger le dictionnaire
|
||||||
Dictionnaire dictionnaire = new Dictionnaire();
|
dico =new Dictionnaire(cheminDictionnaire);
|
||||||
|
|
||||||
// Apprentissage du dictionnaire à partir des avis
|
// Apprentissage du dictionnaire à partir des avis
|
||||||
dictionnaire.apprentissageSentiment(listeAvis.getListeAvis());
|
dico.apprentissageSentiment(listeAvis.getListeAvis());
|
||||||
|
|
||||||
// Sauvegarder le dictionnaire
|
// Sauvegarder le dictionnaire
|
||||||
dictionnaire.sauvegarderDictionnaireCSV(cheminDictionnaire);
|
dico.sauvegarderDictionnaireCSV(cheminDictionnaire);
|
||||||
|
|
||||||
// Passer à l'écran des films
|
// Passer à l'écran des films
|
||||||
afficherFilms();
|
afficherFilms();
|
||||||
|
|
@ -199,29 +201,7 @@ public class Inter extends JFrame {
|
||||||
rafraichirPanel();
|
rafraichirPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialise le dictionnaire de sentiments
|
|
||||||
*/
|
|
||||||
private void initialiserDictionnaireSentiments() {
|
|
||||||
// Mots positifs
|
|
||||||
String[] motsPositifs = {"aime", "bien", "super", "excellent", "génial", "bon",
|
|
||||||
"agréable", "intéressant", "beau", "magnifique"};
|
|
||||||
int[] valeursPositives = {80, 70, 90, 95, 90, 75, 65, 60, 70, 85};
|
|
||||||
|
|
||||||
// Mots négatifs
|
|
||||||
String[] motsNegatifs = {"mauvais", "nul", "horrible", "déteste", "ennuyeux",
|
|
||||||
"décevant", "médiocre", "pire", "terrible", "affreux"};
|
|
||||||
int[] valeursNegatives = {20, 10, 5, 10, 25, 30, 35, 15, 20, 15};
|
|
||||||
|
|
||||||
// Remplir le dictionnaire
|
|
||||||
for (int i = 0; i < motsPositifs.length; i++) {
|
|
||||||
dictionnaireSentiments.put(motsPositifs[i], valeursPositives[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < motsNegatifs.length; i++) {
|
|
||||||
dictionnaireSentiments.put(motsNegatifs[i], valeursNegatives[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Affiche la grille des 10 films
|
* Affiche la grille des 10 films
|
||||||
|
|
@ -298,7 +278,7 @@ public class Inter extends JFrame {
|
||||||
|
|
||||||
private int calculerNoteMoyenne(int filmNumber) {
|
private int calculerNoteMoyenne(int filmNumber) {
|
||||||
int totalNotes= 0;
|
int totalNotes= 0;
|
||||||
Dictionnaire dico=new Dictionnaire(cheminDictionnaire);
|
|
||||||
Avis av = new Avis();
|
Avis av = new Avis();
|
||||||
|
|
||||||
totalNotes += av.Analyse(listeAvis.getCommentairesParFilm(filmNumber), dico);
|
totalNotes += av.Analyse(listeAvis.getCommentairesParFilm(filmNumber), dico);
|
||||||
|
|
@ -489,25 +469,31 @@ public class Inter extends JFrame {
|
||||||
*/
|
*/
|
||||||
private void ajouterCommentaire(int filmNumber, String c) {
|
private void ajouterCommentaire(int filmNumber, String c) {
|
||||||
// Récupérer la liste des commentaires
|
// Récupérer la liste des commentaires
|
||||||
Dictionnaire dico = new Dictionnaire(cheminDictionnaire);
|
|
||||||
Avis av =new Avis();
|
Avis av =new Avis(0,c,"none",filmNumber);
|
||||||
List<String> commentaires = listeAvis.getCommentairesParFilm(filmNumber);
|
List<String> commentaires = listeAvis.getCommentairesParFilm(filmNumber);
|
||||||
commentaires.add(c);
|
commentaires.add(c);
|
||||||
|
listeAvis.add(new Avis(filmNumber, "url", c, 0));
|
||||||
|
|
||||||
|
List<String> com = new ArrayList<>();
|
||||||
|
com.add("c");
|
||||||
|
int note = av.Analyse(com, dico);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Calculer la nouvelle note moyenne
|
// Calculer la nouvelle note moyenne
|
||||||
int noteMoyenne = av.Analyse(commentaires, dico);
|
// int noteMoyenne = av.Analyse(commentaires, dico);
|
||||||
notesFilms.put(filmNumber, noteMoyenne);
|
// notesFilms.put(filmNumber, noteMoyenne);
|
||||||
|
|
||||||
// Mettre à jour l'interface
|
// Mettre à jour l'interface
|
||||||
afficherDetailFilm(filmNumber);
|
afficherDetailFilm(filmNumber);
|
||||||
|
|
||||||
// Afficher un message de confirmation
|
// Afficher un message de confirmation
|
||||||
JOptionPane.showMessageDialog(panel,
|
JOptionPane.showMessageDialog(panel,
|
||||||
"Commentaire ajouté avec succès !\nNote moyenne du film : " + noteMoyenne + "/5",
|
"Commentaire ajouté avec succès !\nNote moyenne du commentaire : " + note + "/5",
|
||||||
"Succès",
|
"Succès",
|
||||||
JOptionPane.INFORMATION_MESSAGE);
|
JOptionPane.INFORMATION_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rafraîchit l'affichage du panel principal
|
* Rafraîchit l'affichage du panel principal
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue