Main Page   Compound List   File List   Compound Members   File Members  

rr_libs/read_wlist_si.c

Go to the documentation of this file.
00001 /* read_wlist_into_siht: read a word list into a (string-to-intval) hash table */
00002 /*=====================================================================
00003                 =======   COPYRIGHT NOTICE   =======
00004 Copyright (C) 1994, Carnegie Mellon University and Ronald Rosenfeld.
00005 All rights reserved.
00006 
00007 This software is made available for research purposes only.  It may be
00008 redistributed freely for this purpose, in full or in part, provided
00009 that this entire copyright notice is included on any copies of this
00010 software and applications and derivations thereof.
00011 
00012 This software is provided on an "as is" basis, without warranty of any
00013 kind, either expressed or implied, as to any matter including, but not
00014 limited to warranty of fitness of purpose, or merchantability, or
00015 results obtained from use of this software.
00016 ======================================================================*/
00017 
00018 /* Edited by Philip Clarkson, March 1997 to prevent compilation warnings */
00019 
00020 #include <stdio.h>
00021 #include <string.h>
00022 #include "general.h"
00023 #include "sih.h"
00024 
00028 void read_wlist_into_siht(char *wlist_filename, int verbosity,  
00029                           sih_t *p_word_id_ht, int *p_n_wlist)
00030 {
00031   static char rname[]="read_wlist_into_siht";
00032   FILE   *wlist_fp = rr_iopen(wlist_filename);
00033   char   wlist_entry[1024], word[256], *word_copy;
00034   int    entry_no = 0;
00035 
00036   while (fgets (wlist_entry, sizeof (wlist_entry), wlist_fp)) {
00037      if (strncmp(wlist_entry,"##",2) == 0) continue;
00038      entry_no++;
00039      sscanf (wlist_entry, "%s ", word);
00040      if (strncmp(wlist_entry,"#",1)==0) {
00041         fprintf(stderr,"\n\n===========================================================\n");
00042         fprintf(stderr,"%s:\nWARNING: line assumed NOT a comment:\n",rname);
00043         fprintf(stderr,     ">>> %s <<<\n",wlist_entry);
00044         fprintf(stderr,     "         '%s' will be included in the vocabulary\n",word);
00045         fprintf(stderr,     "         (comments must start with '##')\n");
00046         fprintf(stderr,"===========================================================\n\n");
00047      }
00048      word_copy = salloc(word);
00049      sih_add(p_word_id_ht, word_copy, entry_no);
00050   }
00051   rr_iclose(wlist_fp);
00052   if (verbosity) 
00053      fprintf(stderr,"%s: a list of %d words was read from \"%s\".\n",
00054                     rname,entry_no,wlist_filename);
00055   *p_n_wlist = entry_no;
00056 }

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