Main Page   Compound List   File List   Compound Members   File Members  

binlm2arpa.c

Go to the documentation of this file.
00001 /*=====================================================================
00002                 =======   COPYRIGHT NOTICE   =======
00003 Copyright (C) 1996, Carnegie Mellon University, Cambridge University,
00004 Ronald Rosenfeld and Philip Clarkson.
00005 
00006 All rights reserved.
00007 
00008 This software is made available for research purposes only.  It may be
00009 redistributed freely for this purpose, in full or in part, provided
00010 that this entire copyright notice is included on any copies of this
00011 software and applications and derivations thereof.
00012 
00013 This software is provided on an "as is" basis, without warranty of any
00014 kind, either expressed or implied, as to any matter including, but not
00015 limited to warranty of fitness of purpose, or merchantability, or
00016 results obtained from use of this software.
00017 ======================================================================*/
00018 
00019 
00020 #include <stdio.h>
00021 #include <stdlib.h>
00022 #include <string.h>
00023 
00024 #include "ngram.h"
00025 #include "toolkit.h"
00026 #include "pc_libs/pc_general.h"
00027 #include "rr_libs/general.h"
00028 #include "idngram2lm.h"
00029 #include "evallm.h"
00030 
00035 void main (int argc,char **argv) {
00036 
00037   char *bin_path;
00038   int verbosity;
00039   ng_t ng;
00040 
00041   if (pc_flagarg(&argc,argv,"-help") || argc == 1) {
00042     fprintf(stderr,"binlm2arpa : Convert a binary format language model to ARPA format.\n");
00043     fprintf(stderr,"Usage : binlm2arpa -binary .binlm\n");
00044     fprintf(stderr,"                   -arpa .arpa\n");
00045     fprintf(stderr,"                 [ -verbosity n ]\n");
00046     exit(1);
00047   }
00048 
00049   report_version(&argc,argv);
00050 
00051   verbosity = pc_intarg(&argc,argv,"-verbosity",DEFAULT_VERBOSITY);
00052 
00053   bin_path = salloc(pc_stringarg(&argc,argv,"-binary",""));
00054 
00055   if (!strcmp(bin_path,"")) {
00056     quit(-1,"Error : must specify a binary language model file.\n");
00057   }
00058 
00059   ng.arpa_filename = salloc(pc_stringarg(&argc,argv,"-arpa",""));
00060 
00061   if (!strcmp(ng.arpa_filename,"")) {
00062     quit(-1,"Error : must specify an ARPA language model file.\n");
00063   }
00064 
00065   ng.arpa_fp = rr_oopen(ng.arpa_filename);
00066 
00067   pc_report_unk_args(&argc,argv,verbosity);
00068 
00069   pc_message(verbosity,1,"Reading binary language model from %s...",bin_path);
00070 
00071   load_lm(&ng,bin_path);
00072 
00073   if (verbosity>=2) {
00074     display_stats(&ng);
00075   }
00076 
00077   pc_message(verbosity,1,"Done\n");
00078 
00079   write_arpa_lm(&ng,verbosity);
00080 
00081   pc_message(verbosity,0,"binlm2arpa : Done.\n");
00082 
00083   exit(0);
00084 
00085 }

Generated on Tue Dec 21 13:54:44 2004 by doxygen1.2.18