LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
automatonReaderWriter.h
Go to the documentation of this file.
1// Copyright 2002-2013 CEA LIST
2// SPDX-FileCopyrightText: 2022 CEA LIST <gael.de-chalendar@cea.fr>
3//
4// SPDX-License-Identifier: MIT
5
6/************************************************************************
7 *
8 * @file automatonReader.h
9 * @author besancon (besanconr@zoe.cea.fr)
10 * @date Wed Mar 16 2005
11 * @version $Id$
12 * copyright Copyright (C) 2005-2012 by CEA LIST
13 * Project Automaton
14 *
15 * @brief
16 *
17 ***********************************************************************/
18
19#ifndef AUTOMATONREADER_H
20#define AUTOMATONREADER_H
21
22#include "AutomatonExport.h"
23#include "common/LimaCommon.h"
25#include <iostream>
26#include <map>
27#include <fstream>
28
29namespace Lima {
30namespace LinguisticProcessing {
31namespace Automaton {
32
33// classes defined external
34class Recognizer;
35class Rule;
36class Automaton;
37class TransitionUnit;
38class Constraint;
39class ConstraintFunction;
40
42{
43 public:
46
47 void readRecognizer(const std::string& filename,
48 Recognizer& reco);
49
50 void readRecognizer(std::ifstream& file,
51 Recognizer& reco);
52 Rule* readRule(std::ifstream& file,MediaId language);
53 void readAutomaton(std::ifstream& file,
54 Automaton& a,
55 MediaId language);
56 void readConstraint(std::ifstream& file,
57 Constraint& c);
58 TransitionUnit* readTransitionUnit(std::ifstream& file,MediaId language);
59 void readRegisteredConstraints(std::ifstream& file,
60 MediaId language);
61 MediaId readHeader(std::ifstream& file);
62
63 private:
64 std::map<uint64_t,ConstraintFunction*> m_constraintFunctionMap;
65 std::map<Common::MediaticData::EntityGroupId,Common::MediaticData::EntityGroupId> m_entityGroupMapping;
66 std::map<Common::MediaticData::EntityType,Common::MediaticData::EntityType> m_entityTypeMapping;
67 bool m_debug;
68};
69
71{
72 public:
75
76 void writeRecognizer(const Recognizer& reco,
77 const std::string& filename,
78 MediaId language,
79 bool debug=false);
80
81 void writeRecognizer(std::ofstream& file,
82 const Recognizer& reco,
83 MediaId language,
84 bool debug=false);
85
86 void writeRule(std::ofstream& file,
87 const Rule& rule,
88 MediaId language);
89 void writeAutomaton(std::ofstream& file,
90 const Automaton& automaton,
91 MediaId language);
92 void writeTransitionUnit(std::ofstream& file,
93 TransitionUnit* transition,
94 MediaId language);
95 void writeConstraint(std::ofstream& file,
96 const Constraint& c);
97 void writeRegisteredConstraints(std::ofstream& file);
98 void writeHeader(std::ofstream& file,MediaId lang);
99
100 private:
101 std::map<ConstraintFunction*,uint64_t> m_constraintFunctionMap;
102 bool m_debug;
103};
104
105} // end namespace
106} // end namespace
107} // end namespace
108
109#endif
#define LIMA_AUTOMATON_EXPORT
␈rief A class for the description of automata
Definition automaton.h:87
␈rief a class for the definition of a complete recognizer
Definition recognizer.h:78
NAUTITIA.