LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
constraintFunction.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 constraintFunction.h
9 * @author besancon (besanconr@zoe.cea.fr)
10 * @date Mon Sep 1 2003
11 * copyright Copyright (C) 2003 by CEA LIST
12 * Project Automaton
13 *
14 * @brief this class describes the basic constraint visitor
15 * (used in the recognizer)
16 *
17 *
18 ***********************************************************************/
19
20#ifndef CONSTRAINTFUNCTION_H
21#define CONSTRAINTFUNCTION_H
22
24#include "recognizerMatch.h"
27#include <map>
28#include <string>
29#include <iostream>
30#include <stdexcept>
31
32namespace Lima {
33namespace LinguisticProcessing {
34namespace Automaton {
35
37{
38 public:
39 virtual ~ConstraintFunction() {};
40
49 const LinguisticGraphVertex& /*unused*/,
50 const LinguisticGraphVertex& /*unused*/,
51 AnalysisContent& /*unused*/) const {
52 std::string functionName;
53 LimaString complement;
55 getFunctionName(this,functionName,complement);
56 std::cerr << "binary constraint function "
57 << functionName
58 << " not defined" << std::endl;
59 return true;
60 }
61
70 const LinguisticGraphVertex& /*unused*/,
71 AnalysisContent& /*unused*/) const {
72
73 std::string functionName;
74 LimaString complement;
76 getFunctionName(this,functionName,complement);
77 std::cerr << "unary constraint function "
78 << functionName
79 << " not defined" << std::endl;
80 return true;
81 }
82
90 virtual bool operator()(AnalysisContent& /*unused*/) const {
91
92 std::string functionName;
93 LimaString complement;
95 getFunctionName(this,functionName,complement);
96 std::cerr << "action function "
97 << functionName
98 << " not defined" << std::endl;
99 return true;
100 }
101
110 virtual bool operator()(RecognizerMatch& /*unused*/,
111 AnalysisContent& /*unused*/) const {
112
113 std::string functionName;
114 LimaString complement;
116 getFunctionName(this,functionName,complement);
117 std::cerr << "action function (using recognized expression) "
118 << functionName
119 << " not defined" << std::endl;
120 return true;
121 }
122
123 virtual bool actionNeedsRecognizedExpression() { return false; }
124
126 unsigned char getLanguage() { return m_language_id; }
127
128 protected:
129 explicit ConstraintFunction(MediaId language,
130 const LimaString& complement=LimaString()):
131 m_language_id(language),
132 m_complement(complement) {}
133
134 // a unusual name to be different from existing m_language in existing
135 // constraints => @todo : remove m_language from existing contraints
138};
139
140} // end namespace
141} // end namespace
142} // end namespace
143
144#endif
LinguisticGraph::vertex_descriptor LinguisticGraphVertex
Holds all data that pass through the ProcessUnits Analysis data are shared pointers,...
virtual bool operator()(AnalysisContent &) const
zero-ary constraint function : applies the function without a vertex indication (used for actions,...
ConstraintFunction(MediaId language, const LimaString &complement=LimaString())
virtual bool operator()(RecognizerMatch &, AnalysisContent &) const
zero-ary constraint function : applies the function without a vertex indication (used for actions,...
virtual bool operator()(const LinguisticAnalysisStructure::AnalysisGraph &, const LinguisticGraphVertex &, const LinguisticGraphVertex &, AnalysisContent &) const
binary constraint function : the constraint only applies on two vertices in the graph (the graph is a...
virtual bool operator()(const LinguisticAnalysisStructure::AnalysisGraph &, const LinguisticGraphVertex &, AnalysisContent &) const
unary constraint function : the constraint only applies on one vertices in the graph (the graph is al...
An AnalysisData containing a LinguisticGraph with a language and an id.
static const ConstraintFunctionManager & single()
const singleton accessor
Definition Singleton.h:51
NAUTITIA.
QString LimaString
Definition LimaString.h:33