/**************************************************************************/ // Проверить грамматические словари на полноту // И напечатать все слова, которые отсутсвуют в грамматических словарях /**************************************************************************/ # include # include # include # include # include # include # include # include t_Slowo3 Macro ; // словарь английских сокращений t_Slowo3 DicConst ; // словарь английских constant t_Slowo3 Perevod ; t_Slowo2 *SlowoF,*SlowoT ; short *i_FormatT ; // соответствие часть речи -> SlowoT short *i_FormatF ; // соответствие часть речи -> SlowoF short n_SlowoF=0,n_SlowoT=0 ; // размер массивов t_Core Core ; static char f_data_read=0 ; // данные уже были прочитаны FILE *fw ; char *ru_part[]={ "сущ","прил","глагол",NULL }; char *en_part[]={ "сущ", "глагол",NULL }; char *es_part[]={ "сущ","прил","глагол",NULL }; int main1( char *Prefix1, char *Prefix2, char **Part1, char **Part2 ); void my_grep( char *File, char *Str ); void Grep( char *File1, char *File2, char *Str1 ); long FileToString( char *File, char ***_Str ); long FileToWord( char *File, char ***_Str ); void WordsSort1( char *File1, char *File2 ); /************************************************************************/ /************************************************************************/ int main( void ) { t_DirTrans DT ; unlink( "../../dicts/z_knowlege/tmp/absend" ); fw=Fopen( "../../dicts/z_knowlege/tmp/absend","w" ); read_grammar( "../../grammar/english_russian/lang.txt",&DT ); main1( "en_","ru_",en_part,ru_part ); read_grammar( "../../grammar/esperanto_russkij/lang.txt",&DT ); main1( "es_","ru_",es_part,ru_part ); Fclose( fw ); my_grep( "../../dicts/z_knowlege/absend/ru_sub", "ru_сущ" ); my_grep( "../../dicts/z_knowlege/absend/ru_adj", "ru_прил" ); my_grep( "../../dicts/z_knowlege/absend/ru_verb","ru_глагол" ); my_grep( "../../dicts/z_knowlege/absend/en_sub", "en_сущ" ); my_grep( "../../dicts/z_knowlege/absend/en_verb","en_глагол" ); my_grep( "../../dicts/z_knowlege/absend/es_sub", "es_сущ" ); my_grep( "../../dicts/z_knowlege/absend/es_adj", "es_прил" ); my_grep( "../../dicts/z_knowlege/absend/es_verb","es_глагол" ); } /***************************************************************************/ // прочесть все данные /***************************************************************************/ char read_grammar( char *FileGrammar, t_DirTrans *DT ) { t_File *F ; long i,N ; char Filename[200] ; char Path[]="../../" ; char r ; try { r=Grammar.make_all( FileGrammar ); if( r<0 ) return r ; File_Error=Fopen("mercury.err","w+"); // ---------------- прочитать словари источника -------------------- for( i=0 ; iFileName[0] ), &From, &From.Format[F->i_format] ); i_FormatF[F->i_part]=i ; } // ---------------- прочитать словари приемника -------------------- for( i=0 ; iFileName[0]), &To, &To.Format[F->i_format] ); i_FormatT[F->i_part]=i ; } // -------------- прочитать словари перевода --------------- Perevod.read( Path, &Grammar ); Fclose( File_Error ); if( Read_Error==0 ) { unlink("mercury.err") ; f_data_read=1 ; } return Read_Error ; // если тут 0, то все в порядке } catch( int E ) { Fclose( File_Error ); return -1 ; } } /***************************************************************************/ // пристыковать к имени каталога имя файла /***************************************************************************/ char *filename( char *Path, char *File ) { static char Str[200] ; Strcpy( Str,Path,200 ); if( Str[strlen(Str)-1]!='/' ) Strcat( Str,"/",200 ); Strcat( Str,File,200 ); return Str ; } /***************************************************************************/ // /***************************************************************************/ int main1( char *Prefix1, char *Prefix2, char **Part1, char **Part2 ) { long i,i1,i2,j,i_struct,i_dict ; t_sStruct *S ; long Ant[20] ; t_Form Form[20] ; for( i=0 ; isy_struct ) ; for( i1=0 ; i1n_Word ; i1++ ) { i_struct=S->Word[i1].i_struct ; if( i_struct<0 ) continue ; if( Grammar[i_struct].From.type!=TWORD ) continue ; i_dict=i_FormatF[i_struct] ; if( i_dict<0 ) continue ; for( i2=0 ; Part1[i2]!=NULL ; i2++ ) if( 0==strcmp(Grammar[i_struct].From.Name,Part1[i2]) ) goto M_OK1 ; continue ; M_OK1: if( 0>=SlowoF[i_dict].quest( S->Word[i1].str,Ant,Form ) ) fprintf( fw, "\n%s%s %s",Prefix1,Part1[i2],S->Word[i1].str ); } } for( i=0 ; in_struct ; j++ ) { S=Perevod.sstruct(Perevod.record(i)->sy_struct+j) ; for( i1=0 ; i1n_Word ; i1++ ) { i_struct=S->Word[i1].i_struct ; if( i_struct<0 ) continue ; if( Grammar[i_struct].From.type!=TWORD ) continue ; i_dict=i_FormatT[i_struct] ; if( i_dict<0 ) continue ; for( i2=0 ; Part2[i2]!=NULL ; i2++ ) if( 0==strcmp(Grammar[i_struct].To.Name,Part2[i2]) ) goto M_OK2 ; continue ; M_OK2 : if( 0>=SlowoT[i_dict].quest( S->Word[i1].str,Ant,Form ) ) fprintf( fw,"\n%s%s %s",Prefix2,Part2[i2],S->Word[i1].str ); } } } return 0 ; } /****************************************************************************/ void my_grep( char *File, char *Str1 ) { long i,i1,j,z,N ; char **Str ; Grep( "../../dicts/z_knowlege/tmp/absend","../../dicts/z_knowlege/tmp/tmp.txt",Str1 ); N=FileToString( "../../dicts/z_knowlege/tmp/tmp.txt", &Str ); FILE *fw=Fopen( "../../dicts/z_knowlege/tmp/tmp1.txt","w" ); for( i=0 ; i