mootLexfreqsCompiler.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-2014 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: mootLexfreqsCompiler.h
24  * Author: Bryan Jurish <moocow@cpan.org>
25  * Description:
26  * Compiler for TnT-style lexical-frequency parameter files for moot PoS tagger
27  *============================================================================*/
28 
34 #ifndef _moot_LEXFREQS_COMPILER_H
35 #define _moot_LEXFREQS_COMPILER_H
36 
37 #include "mootLexfreqsLexer.h"
38 //#include "mootLexfreqsParser.h" //-- included by mootLexfreqsLexer.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  mootLexfreqsCompiler() : objname(NULL), srcname(NULL) {};
71 
73  virtual ~mootLexfreqsCompiler() {};
74 
75  // -- high-level parsing methods
76 
78  inline mootLexfreqs *parse_from_file(FILE *file, const char *filename=NULL) {
79  select_streams(file,stdout);
80  return parse_lexfreqs();
81  };
82 
84  inline mootLexfreqs *parse_from_string(const char *string, const char *srcname=NULL) {
85  select_string(string,srcname);
86  return parse_lexfreqs();
87  };
88 
89  // -- low-level public methods: INPUT SELECTION
91  void select_streams(FILE *in, FILE *out, const char *my_srcname=NULL) {
92  theLexer.select_streams(in,out);
93  srcname = my_srcname;
94  };
95 
100  void select_string(const char *in, const char *my_srcname=NULL) {
101  theLexer.select_string(in);
102  srcname = my_srcname;
103  };
104 
105  // -- low-level public methods: PARSING
106  virtual int yylex();
107 
112  mootLexfreqs *parse_lexfreqs();
113 
114  // -- low-level public methods: ERRORS & WARNINGS
116  virtual void yyerror(const char *msg);
117 
119  virtual void yywarn(const char *msg);
120 };
121 
122 moot_END_NAMESPACE
123 
124 #endif /* _moot_LEXFREQS_COMPILER_H */
const char * objname
Definition: mootLexfreqsCompiler.h:59
mootLexfreqsCompiler()
Definition: mootLexfreqsCompiler.h:70
flex++ lexical-frequency parameter file lexer: autogenerated header
bison++ parser for (TnT-style) moot lexical-frequency parameter files
Definition: mootLexfreqsParser.h:64
Lexical frequency parameter-file compiler.
Definition: mootLexfreqsCompiler.h:49
void select_string(const char *in, FILE *out=stderr, const char *myname=__null)
Definition: mootGenericLexer.h:231
Class for storage and retrieval of raw lexical frequencies.
Definition: mootLexfreqs.h:44
flex++ lexer for (TnT-style) moot lexical-frequency parameter files
Definition: mootLexfreqsLexer.h:51
mootLexfreqsLexer theLexer
Definition: mootLexfreqsCompiler.h:53
void select_streams(FILE *in, FILE *out=stdout, const char *myname=__null)
Definition: mootGenericLexer.h:220
const char * srcname
Definition: mootLexfreqsCompiler.h:65