Blame view

tools/lia_ltbox/lia_tagg/src/format/add_code_to_lex_phon.c 938 Bytes
e6be5137b   Jean-François Rey   reinitialized pro...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
  /*  Add a digit code to lexicon with phon: each different
   *  word token receive a different code. Warning the input
   *  lex MUST be sorted   */
  /*  FRED 0703  */
  
  #include <stdio.h>
  #include <stdlib.h>
  #include <string.h>
  #include <strings.h>
  
  /*................................................................*/
  
  #define TailleLigne     40000
  
  #define True    1
  #define False   0
  
  void ERREUR(char *ch1,char *ch2)
  {
  fprintf(stderr,"ERREUR : %s %s
  ",ch1,ch2);
  exit(0);
  }
  
  /*................................................................*/
  
  int main(int argc, char **argv)
  {
  char ch[TailleLigne],previous[TailleLigne],*word,*phon;
  int nb;
  
  for(nb=0,previous[0]='\0';fgets(ch,TailleLigne,stdin);)
   {
   word=strtok(ch,"\t"); if (word) phon=strtok(NULL,"
  "); else phon=NULL;
   if ((word==NULL)||(phon==NULL)) ERREUR("bad format:",ch);
   if (strcmp(word,previous)) nb++;
   printf("%d\t%s\t%s
  ",nb,word,phon);
   strcpy(previous,word);
   }
  }