diff options
Diffstat (limited to 'training/utils')
-rw-r--r-- | training/utils/Makefile.am | 23 | ||||
-rw-r--r-- | training/utils/sentclient.cc (renamed from training/utils/sentclient.c) | 0 | ||||
-rw-r--r-- | training/utils/sentserver.cc (renamed from training/utils/sentserver.c) | 14 |
3 files changed, 25 insertions, 12 deletions
diff --git a/training/utils/Makefile.am b/training/utils/Makefile.am index c9405d4e..27c6e344 100644 --- a/training/utils/Makefile.am +++ b/training/utils/Makefile.am @@ -2,21 +2,31 @@ noinst_LIBRARIES = libtraining_utils.a bin_PROGRAMS = \ sentserver \ - sentclient + sentclient \ + grammar_convert noinst_PROGRAMS = \ lbfgs_test \ optimize_test -sentserver_SOURCES = sentserver.c +EXTRA_DIST = decode-and-evaluate.pl libcall.pl parallelize.pl + +sentserver_SOURCES = sentserver.cc sentserver_LDFLAGS = -pthread -sentclient_SOURCES = sentclient.c +sentclient_SOURCES = sentclient.cc sentclient_LDFLAGS = -pthread TESTS = lbfgs_test optimize_test libtraining_utils_a_SOURCES = \ + candidate_set.h \ + entropy.h \ + lbfgs.h \ + online_optimizer.h \ + optimize.h \ + risk.h \ + sentserver.h \ candidate_set.cc \ entropy.cc \ optimize.cc \ @@ -24,10 +34,13 @@ libtraining_utils_a_SOURCES = \ risk.cc optimize_test_SOURCES = optimize_test.cc -optimize_test_LDADD = libtraining_utils.a $(top_srcdir)/utils/libutils.a +optimize_test_LDADD = libtraining_utils.a ../../utils/libutils.a + +grammar_convert_SOURCES = grammar_convert.cc +grammar_convert_LDADD = ../../decoder/libcdec.a ../../mteval/libmteval.a ../../utils/libutils.a lbfgs_test_SOURCES = lbfgs_test.cc -lbfgs_test_LDADD = $(top_srcdir)/utils/libutils.a +lbfgs_test_LDADD = ../../utils/libutils.a AM_CPPFLAGS = -W -Wall -Wno-sign-compare -I$(top_srcdir)/decoder -I$(top_srcdir)/utils -I$(top_srcdir)/mteval -I$(top_srcdir)/klm diff --git a/training/utils/sentclient.c b/training/utils/sentclient.cc index 91d994ab..91d994ab 100644 --- a/training/utils/sentclient.c +++ b/training/utils/sentclient.cc diff --git a/training/utils/sentserver.c b/training/utils/sentserver.cc index c20b4fa6..b425955f 100644 --- a/training/utils/sentserver.c +++ b/training/utils/sentserver.cc @@ -85,7 +85,7 @@ struct line * queue_get(int fid) { if (log_mutex) fprintf(stderr, "Unlocking input mutex (%d)\n", fid); pthread_mutex_unlock(&input_mutex); - cur = malloc(sizeof (struct line)); + cur = (line*)malloc(sizeof (struct line)); cur->id = n_sent; cur->s = s; cur->next = NULL; @@ -99,7 +99,7 @@ struct line * queue_get(int fid) { fprintf(stderr, "Received ===SYNCH=== signal (fid %d)\n", fid); // Note: queue_finish calls free(cur->s). // Therefore we need to create a new string here. - synch = malloc((strlen("===SYNCH===\n")+2) * sizeof (char)); + synch = (char*)malloc((strlen("===SYNCH===\n")+2) * sizeof (char)); synch = strcpy(synch, s); if (log_mutex) fprintf(stderr, "Unlocking queue mutex (%d)\n", fid); @@ -247,7 +247,7 @@ void queue_finish(struct line *node, char *s, int fid) { char * read_line(int fd, int multiline) { int size = 80; char errorbuf[100]; - char *s = malloc(size+2); + char *s = (char*)malloc(size+2); int result, errors=0; int i = 0; @@ -257,7 +257,7 @@ char * read_line(int fd, int multiline) { if (result < 0) { perror("read()"); sprintf(errorbuf, "Error code: %d\n", errno); - fprintf(stderr, errorbuf); + fputs(errorbuf, stderr); errors++; if (errors > 5) { free(s); @@ -301,7 +301,7 @@ char * read_line(int fd, int multiline) { if (i == size) { size = size*2; - s = realloc(s, size+2); + s = (char*)realloc(s, size+2); } } @@ -343,7 +343,7 @@ void * new_client(void *arg) { if (result < strlen(cur->s)){ perror("write()"); sprintf(errorbuf, "Error code: %d\n", errno); - fprintf(stderr, errorbuf); + fputs(errorbuf, stderr); pthread_mutex_lock(&clients_mutex); n_clients--; @@ -474,7 +474,7 @@ int main (int argc, char *argv[]) { sleep(1); continue; } - client = malloc(sizeof(struct clientinfo)); + client = (clientinfo*)malloc(sizeof(struct clientinfo)); client->s = g; bcopy(&from, &client->sin, len); |