LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
constraint.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 constraint.h
9 * @author besancon (besanconr@zoe.cea.fr)
10 * @date Tue Nov 26 2002
11 * copyright Copyright (C) 2002 by CEA LIST
12 * Project Automaton
13 *
14 * @brief this class is the description of the constraints applied
15 * on the transitions of the automata
16 *
17 *
18 ***********************************************************************/
19
20#ifndef CONSTRAINT_H
21#define CONSTRAINT_H
22
23#include "AutomatonExport.h"
24#include "constraintFunction.h"
25#include "constraintCheckList.h"
30#include <vector>
31#include <fstream>
32
33namespace Lima {
34namespace LinguisticProcessing {
35namespace Automaton {
36
38{
39friend class AutomatonReader;
40friend class AutomatonWriter;
41
42 public:
43 Constraint();
44 Constraint(const uint64_t i,
45 const std::string& functionName,
46 const ConstraintAction a,
47 MediaId language,
48 const LimaString& complement=LimaString(),
49 const bool negative=false);
50 Constraint(const Constraint&);
52 Constraint& operator = (const Constraint&);
53
54 friend LIMA_AUTOMATON_EXPORT std::ostream& operator << (std::ostream&, const Constraint&);
55 friend LIMA_AUTOMATON_EXPORT QDebug& operator << (QDebug&, const Constraint&);
56 friend bool operator == (const Constraint&,const Constraint&);
57
58 static const uint64_t noindex=UINT_MAX;
59
60 void reinit();
61
62 uint64_t index() const;
63 ConstraintFunction* functionAddr() const;
64 std::string functionName() const;
65 ConstraintAction action() const;
66 LimaString str() const;
67 void setIndex(const uint64_t);
68 void setFunctionAddr(ConstraintFunction* f);
69 void setAction(const ConstraintAction);
70
81 bool checkConstraint(const LinguisticAnalysisStructure::AnalysisGraph& graph,
82 const LinguisticGraphVertex& vertex,
83 AnalysisContent& analysis,
84 ConstraintCheckList& constraintCheckList) const;
85
99 bool apply(const LinguisticAnalysisStructure::AnalysisGraph& graph,
100 AnalysisContent& analysis,
101 ConstraintCheckList& constraintCheckList,
102 const bool success,
103 RecognizerMatch* result) const;
104
105 private:
106 uint64_t m_index;
108 ConstraintFunction* m_functionAddr;
109 ConstraintAction m_action;
110 bool m_negative;
112 // private functions
113 void writeConstraintAction(std::ofstream& file,
114 const ConstraintAction& a);
115 ConstraintAction readConstraintAction(std::ifstream& file);
116
117 // for debug output
118 std::string checkStringDebug(const LinguisticAnalysisStructure::AnalysisGraph& graph,
119 const LinguisticGraphVertex vertex) const;
120 std::string applyStringDebug(const LinguisticGraphVertex firstArg=0,
121 const LinguisticGraphVertex secondArg=0) const;
122 std::string actionString() const;
123
124};
125
126//**********************************************************************
127// inline functions
128inline uint64_t Constraint::index() const { return m_index; }
129inline ConstraintAction Constraint::action() const { return m_action; }
130inline void Constraint::setIndex(const uint64_t i) { m_index = i; }
131inline void Constraint::setAction(const ConstraintAction a) { m_action = a; }
132
134 return m_functionAddr;
135}
137 m_functionAddr=f;
138}
139
140
141
142} // end namespace
143} // end namespace
144} // end namespace
145
146
147#endif
#define LIMA_AUTOMATON_EXPORT
QDebug & operator<<(QDebug &qd, const std::string &str)
Definition QsLog.cpp:39
LinguisticGraph::vertex_descriptor LinguisticGraphVertex
Holds all data that pass through the ProcessUnits Analysis data are shared pointers,...
An AnalysisData containing a LinguisticGraph with a language and an id.
std::vector< ConstraintCheckListElement > ConstraintCheckList
NAUTITIA.
QString LimaString
Definition LimaString.h:33