mootNgramsCompiler.h
Go to the documentation of this file.
1 /* -*- Mode: C++ -*- */
2 
3 /*
4  libmoot : moocow's part-of-speech tagging library
5  Copyright (C) 2003-2009 by Bryan Jurish <moocow@cpan.org>
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Lesser General Public
9  License as published by the Free Software Foundation; either
10  version 3 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public
18  License along with this library; if not, write to the Free Software
19  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21 
22 /*============================================================================
23  * File: mootNgramsCompiler.h
24  * Author: Bryan Jurish <moocow@cpan.org>
25  * Description:
26  * Compiler for TnT parameter files for moot PoS tagger
27  *============================================================================*/
28 
34 #ifndef _moot_NGRAMS_COMPILER_H
35 #define _moot_NGRAMS_COMPILER_H
36 
37 #include "mootNgramsLexer.h"
38 //#include "mootNgramsParser.h" //-- used by mootNgramsLexer.h
39 
40 moot_BEGIN_NAMESPACE
41 
50  public:
51  // -- public data
54 
59  const char *objname;
60 
65  const char *srcname;
66 
67  public:
68  // -- public methods: CONSTRUCTORS / DESTRUCTORS
70  mootNgramsCompiler() : objname(NULL), srcname(NULL) {};
72  virtual ~mootNgramsCompiler() {};
73 
74  // -- high-level parsing methods
75 
77  inline mootNgrams *parse_from_file(FILE *file, const char *filename=NULL) {
78  select_streams(file,stdout);
79  return parse_ngrams();
80  };
81 
83  inline mootNgrams *parse_from_string(const char *string, const char *srcname=NULL) {
84  select_string(string,srcname);
85  return parse_ngrams();
86  };
87 
88  // -- low-level public methods: INPUT SELECTION
90  void select_streams(FILE *in, FILE *out, const char *my_srcname=NULL) {
91  theLexer.select_streams(in,out);
92  srcname = my_srcname;
93  };
94 
99  void select_string(const char *in, const char *my_srcname=NULL) {
100  theLexer.select_string(in);
101  srcname = my_srcname;
102  };
103 
104  // -- low-level public methods: PARSING
105  virtual int yylex();
106 
111  mootNgrams *parse_ngrams();
112 
113  // -- low-level public methods: ERRORS & WARNINGS
115  virtual void yyerror(const char *msg);
116 
118  virtual void yywarn(const char *msg);
119 };
120 
121 
122 moot_END_NAMESPACE
123 
124 #endif /* _moot_NGRAMS_COMPILER_H */
bison++ parser for (TnT-style) moot n-gram frequency parameter files
Definition: mootNgramsParser.h:64
const char * srcname
Definition: mootNgramsCompiler.h:65
flex++ n-gram frequency parameter file lexer: autogenerated header
const char * objname
Definition: mootNgramsCompiler.h:59
mootNgramsLexer theLexer
Definition: mootNgramsCompiler.h:53
Class for storage & retrieval of raw N-Gram frequencies.
Definition: mootNgrams.h:44
void select_string(const char *in, FILE *out=stderr, const char *myname=__null)
Definition: mootGenericLexer.h:231
mootNgramsCompiler()
Definition: mootNgramsCompiler.h:70
void select_streams(FILE *in, FILE *out=stdout, const char *myname=__null)
Definition: mootGenericLexer.h:220
flex++ lexer for (TnT-style) moot n-gram frequency parameter files
Definition: mootNgramsLexer.h:51
N-gram parameter-file compiler.
Definition: mootNgramsCompiler.h:49