Commit 5c016b2c3764a65cf2dec42e75ca75405e8bc354

Authored by hraouak
1 parent d7eb54d2

Pas besoin

Showing 1 changed file with 0 additions and 108 deletions   Show diff stats
#projet.c# deleted
... ... @@ -1,108 +0,0 @@
1   -#include <stdio.h>
2   -#include <stdlib.h>
3   -#include <string.h>
4   -#include <stdbool.h>
5   -#include <ctype.h>
6   -
7   -typedef struct noeud {
8   - int valeur;
9   - struct noeud *lettre[28];
10   -} noeud ;
11   -
12   -typedef struct{
13   - noeud *dictionnaire[26];
14   -} dico;
15   -
16   -void creer_et_initialiser_le_noeud(noeud ** parbre, int v){
17   - *parbre=malloc(sizeof(noeud));
18   - (*parbre)->valeur=v;
19   - for(int i=0;i<28;i++)
20   - (*parbre)->lettre[i]=NULL;
21   -}
22   -
23   -void remplissage(noeud ** parbre, char ch[128]){
24   - int i,n=strlen(ch);
25   - if(*parbre==NULL)
26   - creer_et_initialiser_le_noeud(parbre,tolower(ch[0]));
27   - for(i=1;i<n;i++){
28   - if(ch[i]==39)
29   - parbre=&(*parbre)->lettre[26];
30   - else
31   - parbre=&(*parbre)->lettre[tolower(ch[i])-'a'];
32   - if(*parbre == NULL)
33   - creer_et_initialiser_le_noeud(parbre,tolower(ch[i]));
34   - }
35   - creer_et_initialiser_le_noeud(&(*parbre)->lettre[27],0);
36   -}
37   -
38   -
39   -void lecture(noeud ** parbre, FILE *fichier,int v){
40   - char ch[128];
41   - noeud ** tmp_parbre=parbre;
42   - while(fscanf(fichier,"%s",ch)==1)
43   - if(tolower(ch[0])==v)
44   - remplissage(tmp_parbre,ch);
45   -}
46   -
47   -void insertion_dictionnaire(noeud * Arbre[26]){
48   - int i;
49   - for(i=0;i<26;i++){
50   - FILE *dico=fopen("dico.txt","r");
51   - lecture(&Arbre[i],dico,i+'a');
52   - fclose(dico);
53   - }
54   -}
55   -
56   -void initialiser_dictionnaire(noeud * Arbre[26]){
57   - int i;
58   - for(i=0;i<26;i++)
59   - Arbre[i]=NULL;
60   -}
61   -
62   -int existe(noeud ** parbre,char ch[128]){
63   - int n=strlen(ch);
64   - int a,cpt=0;
65   - noeud ** tmp_parbre=parbre;
66   - for(int i=0;i<n-1;i++){
67   - if((*tmp_parbre)!=NULL){
68   - if(tolower(ch[i])==(*tmp_parbre)->valeur){
69   - cpt++;
70   - if (ch[i+1]==39)
71   - tmp_parbre=&(*tmp_parbre)->lettre[26];
72   - else
73   - tmp_parbre=&(*tmp_parbre)->lettre[tolower(ch[i+1])-'a'];
74   - }
75   - }
76   - }
77   - if ((*tmp_parbre)!=NULL){
78   - if (tolower(ch[cpt])==(*tmp_parbre)->valeur)
79   - if ((*tmp_parbre)->lettre[27]!=NULL)
80   - a=1;
81   - }
82   - else a=0;
83   - return a;
84   -}
85   -void corriger_texte(noeud*arbre[26]){
86   - char ch[128];
87   - FILE *texte=fopen("texte.txt","r");
88   - while(fscanf(texte,"%s",ch)==1){
89   - if(!existe(&arbre[tolower(ch[0])-'a'],ch))
90   - printf("%s\n",ch);
91   - }
92   - fclose(texte);
93   -}
94   -
95   -int main (){
96   - dico d;
97   - initialiser_dictionnaire(d.dictionnaire);
98   - insertion_dictionnaire(d.dictionnaire);
99   - printf("-----------------------------------------------------------\n");
100   - printf("Bienvenue dans le correcteur orthographique de HAROUN V1.0\n");
101   - printf("-----------------------------------------------------------\n");
102   - printf("\nvoici les fautes dans le texte: \n \n");
103   - corriger_texte(d.dictionnaire);
104   - printf("\n");
105   -
106   - return 0;
107   -}
108   -