⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 libs-client-server.h

📁 Language, Script, and Encoding Identification with String Kernel Classifiers
💻 H
字号:
/*** Copyright (C) 2006 Thai Computational Linguistics Laboratory (TCL)** National Institute of Information and Communications Technology (NICT)** Canasai Kruengkrai <canasai xx gmail yy com, where xx=at and yy=dot>**** This file is part of the `libs' library.**** This library is free software; you can redistribute it and/or modify** it under the terms of the GNU General Public License as published by** the Free Software Foundation; either version 2 of the License, or** (at your option) any later version.**** This program is distributed in the hope that it will be useful,** but WITHOUT ANY WARRANTY; without even the implied warranty of** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the** GNU General Public License for more details.**** You should have received a copy of the GNU General Public License** along with this program; if not, write to the Free Software** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.*/#ifdef __cplusplusextern "C" {#include "text.h"#endif#ifdef __cplusplus}#endif#define Malloc( type, n ) ( type * )malloc( ( n )*sizeof( type ) )#define malloc_error( str1, str2 ) fprintf( stderr, "ERROR: In function `%s': Could not allocate memory for `%s'\n", str1, str2 ), exit( 1 )#define MAX_LINE_LEN 204800char **label;void error( char *msg ){    perror( msg );    exit( 1 );}void zombie_handler(){#ifdef OLD_SIGHANDLER    ( void )sigset( SIGCHLD, handler );#else    ( void )sigset( SIGCHLD, SIG_IGN );#endif}void load_label( char *label_file_name ){    int num_tokens   = 0;     int num_lines    = 0;     int longest_line = 0;     text_scan( label_file_name, &num_tokens, &num_lines, &longest_line );     char *line = Malloc( char, longest_line );     label = Malloc( char *, num_lines );     FILE *label_file = fopen( label_file_name, "r" );    while( fgets( line, longest_line, label_file ) != NULL )     {        if( text_not_blank( line ) )        {            line[ strlen( line ) - 1 ] = '\0';             char *tmp_ptr = text_copy4( line );             char *tmp_ptr2 = tmp_ptr;             tmp_ptr2 = strchr( tmp_ptr2, ' ' );             if( tmp_ptr2 == NULL )            {                fprintf( stderr, "ERROR: read label file, %s\n", label_file_name );                 exit( 0 );             }            *tmp_ptr2 = '\0';               ++tmp_ptr2;             int index = ( int )atof( tmp_ptr );             label[index]  = text_copy( tmp_ptr2 );             free( tmp_ptr );         }    }    free( line );    fclose( label_file );}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -