Forums Rue-Montgallet.com
Rue-Montgallet.comRue-Hardware.comRue-Occasion.comRue-DVD.comRue-Jeuxvideo.comRue-AudioVideo.comRue-Telephone.comForums
S'inscrire | S'identifier |
| Recherche avancée | Aide
 
 

Il y a 52 utilisateurs connus et inconnus. Pour voir la liste des connectés connus, cliquez ici

 Mot :   Pseudo :  
 
Bas de page
Auteur
 Sujet :

Analyse de texte ?!

 
n°15353
wilbrod
Profil : Jeune recrue
Posté le 30-11-2005 à 23:09:24  profilanswer
 

Bonjour à vous tous,
Je suis nouveau sur ce forum et j'aurais besoin d'aide...
Voici mon code :
Hey oui! Il est bien structuré; et avec des méthodes en plus !
 
import javax.swing.* ;
import java.io.* ;
 
public class StatistiquesTextuelles
{    
     
   public static final int LONGEUR_LIGNE = 80 ;
   public static final int LONGEUR_MOTS = 1 ;
   public static final int OCCURENCE_CONSSONNES = 2 ;
   public static final int OCCURENCE_VOYELLES = 3 ;
   public static final int SORTIE = 4 ;
   public static final int MOT_LONGEUR_MAX = 20 ;
   public static final int NB_SYMBOLE_ALPHABET = 36 ;
   public static final char DERNIER_LIMITEUR = ' ' ;
 
   
   public static int cptrSymbole = 0 ;
   public static int cptrLongeur = 0 ;
   public static int cptrMots = 0 ;
   public static int cptrLimiteurs = 0 ;
   public static int cptrLettres = 0 ;
   public static int menuOption = 0 ;
   
   public static FileInputStream fichierLu ;
   public static FileOutputStream statistiques ;
   public static DataInputStream lectureFichier ;
   public static PrintStream sortieStatistiques ;
   
   public static String cheminAccesEntree = new String ( ) ;
   public static String cheminAccesSortie = new String ( ) ;
   public static String affichage = new String ( ) ;
   public static String lectureDeLigne = new String (  ) ;
   public static String nouvelleLigne = new String ( ) ;
   public static String recherche ;
 
   public static int tabLongeur [ ] = new int [ MOT_LONGEUR_MAX ] ;
   public static char tabLigne [ ] = new char [ LONGEUR_LIGNE ] ;
   public static char tabLimiteurs [ ] =  
      { ',' , ';' , '.' , '!' , '?' , ' ' } ;
   public static char tabAlphabet [ ] =  
      { 'a' , 'b' , 'c' , 'd' , 'e' , 'f' , 'g' , 'h' , 'i' , 'j' ,  
      'k' , 'l' , 'm' , 'n' , 'o' , 'p' , 'q' , 'r' , 's' , 't' ,  
      'v' , 'w' , 'x' , 'y' , 'z' , '1' , '2' , '3' , '4' , '5' ,  
      '6' , '7' , '8' , '9' , '0' } ;
       
 
   public static void main ( String[ ] args )  
   {
      debuterProgramme ( ) ;    
      System.exit ( 0 ) ;  
   }
   public static void debuterProgramme ( )
   {
         demanderCheminEntree ( ) ;
         try
         {      
            fichierLu = new FileInputStream ( cheminAccesEntree ) ;
            try
            {
               demanderCheminSortie ( ) ;
               statistiques = new FileOutputStream ( cheminAccesSortie, true ) ;    
               try
               {
                  lectureFichier = new DataInputStream ( fichierLu ) ;
                  sortieStatistiques = new PrintStream ( statistiques ) ;
                  try
                  {
                     do
                     {
                        lectureDeLigne = lectureFichier.readLine ( ) ;
                        ouvrirMenu ( ) ;
                        choisirOptionMenu ( ) ;
                     }
                     while ( menuOption != 4 ) ;
                  }
                  catch ( Exception Traitement )
                  {
                     verifierTraitement ( ) ;
                  }
               }
               catch ( Exception Chargement )
               {
                  verifierChargement ( ) ;
               }
            }
            catch ( Exception CheminSortie )
            {
               verifierCheminSortie ( ) ;
            }
         }
         catch ( Exception CheminEntree )
         {
            verifierCheminEntree ( ) ;
         }
   }
   public static void demanderCheminEntree ( )
   {
      cheminAccesEntree = JOptionPane.showInputDialog( "Veuillez entrer :" +
         "\nle chemin d'accès," +
         "\nle nom du fichier texte" +
         "\net son extension :" ) ;
   }
   public static void verifierCheminEntree ( )
   {
      affichage = "Erreur : " +
         "\nFichier Entree : " +
         "\n\nAvez-vous bien inscrit :" +
         "\n\nle chemin d'accès" +
         "\nle nom du fichier" +
         "\net son extension ?" +
         "\n\nEssayez la forme suivante:" +
         "\n[Lecteur]:\\[Dossier]\\...\\Fichier.txt" +
         "\n\nOù cliquez sur 'annuler' pour quitter. " ;
      JOptionPane.showMessageDialog ( null, affichage,  
         "Erreur", JOptionPane.WARNING_MESSAGE ) ;
   }
   public static void demanderCheminSortie ( )
   {
      cheminAccesSortie = JOptionPane.showInputDialog( "Veuillez entrer :" +
         "\nle chemin d'accès," +
         "\nle nom du fichier texte," +
         "\ndans lequel vous sauvegarderez vos statistiques," +
         "\net son extension :" ) ;
   }
   public static void verifierCheminSortie ( )
   {
      affichage = "Erreur : " +
         "\nFichier Sortie : " +
         "\n\nAvez-vous bien inscrit :" +
         "\n\nle chemin d'accès" +
         "\nle nom du fichier" +
         "\net son extension ?" +
         "\n\nEssayez la forme suivante:" +
         "\n[Lecteur]:\\[Dossier]\\...\\Fichier.txt" +
         "\n\nOù cliquez sur 'annuler' pour quitter. " ;
      JOptionPane.showMessageDialog ( null, affichage,  
         "Erreur", JOptionPane.WARNING_MESSAGE ) ;
   }
   public static void verifierChargement ( )
   {
     affichage = "Erreur :" +
         "\nChargement :" +
         "\n\nProblème lors du chargement des données" +
         "\nVeuillez redémarrez le programme" ;
     JOptionPane.showMessageDialog ( null, affichage,  
         "Erreur", JOptionPane.WARNING_MESSAGE ) ;
       
   }
   public static void verifierTraitement ( )
   {
     affichage = "Erreur :" +
         "\nTraitement :" +
         "\n\nProblème lors du traitement des données" +
         "\nVeuillez redémarrez le programme" ;
     JOptionPane.showMessageDialog ( null, affichage,  
         "Erreur", JOptionPane.WARNING_MESSAGE ) ;
   }
   public static void ouvrirMenu ( )
   {
      affichage = JOptionPane.showInputDialog ( "Menu" +
         "\nVeuillez choisir l'option désiré :" +
         "\n\n1-Afficher l'occurence et la longeur des mots" +
         "\n2-Afficher l'occurence des consonnes" +
         "\n3-Afficher l'occurence des voyelles" +
         "\n4-Sortir du programme" +
         "\n\nVotre choix :" ) ;
      menuOption = Integer.parseInt ( affichage ) ;
   }
   public static void choisirOptionMenu ( )
   {
      switch ( menuOption )
      {
         case LONGEUR_MOTS :
         {
            calculerLongeurMots ( ) ;
            afficherLongeurMots ( ) ;
            break ;
         }
         case OCCURENCE_CONSSONNES :
         {
            calculerOccurenceConssonnes ( ) ;
            afficherTableauConssonnes ( ) ;
            break ;
         }
         case OCCURENCE_VOYELLES :
         {
            calculerOccurenceVoyelles ( ) ;
            afficherTableauVoyelles ( ) ;
            break ;
         }
         default :
         {
             affichage = "Erreur :" +
             "\nChoix de menu :" +
             "\nVeuillez choisir une des options disponibles" ;
             JOptionPane.showMessageDialog  
                ( null, affichage, "Erreur", JOptionPane.WARNING_MESSAGE ) ;
         }
      }
   }
   public static void calculerLongeurMots ( )
   {
      while ( lectureDeLigne != null )
      {    
         tabLigne = nouvelleLigne.toCharArray ( )  ;
         while ( cptrMots != LONGEUR_LIGNE )
         {          
            while ( tabLigne [ cptrMots ] != tabLimiteurs [ cptrLimiteurs ] )
            {
 
            }        
            cptrMots ++ ;
         }
      }
   }
   public static void afficherLongeurMots ( )
   {
      affichage = "Longeur et occurence des mots :\n" ;
      for ( cptrLongeur = 0 ; tabLongeur [ cptrSymbole ] <= tabLongeur [ MOT_LONGEUR_MAX ] ; cptrLongeur ++  )
      {
         if ( cptrSymbole == 0 )
            affichage += "" ;
         else
            affichage += "Il y a" + cptrLongeur + " de mots de " + tabLongeur [ cptrSymbole ] + " lettres." ;
      }
      JOptionPane.showMessageDialog ( null, affichage, "Option 1", JOptionPane.PLAIN_MESSAGE ) ;
   }
   public static void calculerOccurenceConssonnes ( )
   {
 
   }
   public static void afficherTableauConssonnes ( )
   {
       
   }
   public static void calculerOccurenceVoyelles ( )
   {
       
   }
   public static void afficherTableauVoyelles ( )
   {
       
   }
}
 
Il semblerait avoir un problème dans l'éxécution au niveau de la méthode calculerLongeurMots, seulement je n'arrive pas à comprendre pourquoi ?!
 
Oui, je sais que c'est compliquer pour un rien, mais il s'agit des restrictions imposés pour l'écriture du programme.
 
Merci d'avance

n°15358
m@noo
je javaïse, je phpïse ^=^
Profil : Habitué
Posté le 01-12-2005 à 10:09:23  profilanswer
 

quel JDK ? car je compile mais je plante à l'exécution.
Readfile() est deprecated en jdk 1.4.2
 
edit> scuse fausse piste, erreur de classpath de mon côté :D


Message édité par m@noo le 01-12-2005 à 10:50:38

Aller à :
Ajouter une réponse