![]() |
LIMA
Libre Multilingual Analyzer — C++ API
|
␈rief A class for the description of automata More...
#include <linguisticProcessing/core/Automaton/automaton.h>
Classes | |
| class | CompareAutomatonMatch |
| class | DFSStack |
Public Types | |
| typedef std::pair< RecognizerMatch, ConstraintCheckList > | AutomatonMatch |
| types defined to store the result (or results of the application of the automaton on a graph | |
| typedef std::set< AutomatonMatch, CompareAutomatonMatch > | AutomatonMatchSet |
Public Member Functions | |
| Automaton (const std::string &automId="") | |
| void constructor initializes an empty automaton (no state, no transition) | |
| Automaton (const Automaton &a) | |
| copy constructor | |
| Automaton (const Tstate nbStates) | |
| constructor: build an automaton with a predefined number of states, no indications of final states, no transitions | |
| ~Automaton () | |
| destructor | |
| Automaton & | operator= (const Automaton &a) |
| assignment operator | |
| Tstate | numberOfStates () const |
| get the number of states of the automaton | |
| uint64_t | numberOfTransitions () const |
| get the number of transitions in the automaton | |
| uint64_t | numberOfTransitions (const Tstate state) const |
| find the number of transitions leaving from the state indicated in argument | |
| Transition const & | nthTransition (const Tstate state, const uint64_t n) const |
| find the nth transition leaving from a particular state | |
| bool | isFinalState (const Tstate state) const |
| test if a given state is a final state of the automaton | |
| std::vector< Tstate > | finalStates () const |
| get the list of the final states of the automaton | |
| std::vector< Transition > const & | getTransitionsState (const Tstate state) const |
| get the list of transitions leaving from a given state | |
| bool | hasTransitionsState (const Tstate state) const |
| test if a state of the automaton has out transitions | |
| bool | isDeterministic () const |
| test if the automaton is deterministic or not | |
| void | reinit () |
| reinitializes the automaton (no states, no transitions) | |
| void | setActionHash (const std::vector< std::pair< LimaString, Constraint > > &actionsWithOneArgument) |
| set a property hashcode to each transition which represent the constraint(s?) of type action attached to it | |
| bool | getBestMatch (const LinguisticAnalysisStructure::AnalysisGraph &graph, const LinguisticGraphVertex &begin, const LinguisticGraphVertex &limit, AnalysisContent &analysis, RecognizerMatch &longestMatch, ConstraintCheckList &checkList, const SearchGraphSense sense, const AutomatonControlParams &controlParams) const |
| test if a text corresponds to the automaton : the text is represented as a LinguisticAnalysisStructure::AnalysisGraph | |
| bool | getAllMatches (const LinguisticAnalysisStructure::AnalysisGraph &graph, const LinguisticGraphVertex &begin, const LinguisticGraphVertex &limit, AnalysisContent &analysis, AutomatonMatchSet &allMatches, ConstraintCheckList &checkList, ForwardSearch &forward, BackwardSearch &backward, const SearchGraphSense sense, const AutomatonControlParams &controlParams) const |
| get all matches found between automaton and graph between two points (WARNING: in case of backward search, matches returned are reversed : to to reverse them if natural sense of the graph is needed) | |
| Tstate | addState (bool is_final=false) |
| add a state to the automaton | |
| bool | addTransition (Tstate initialState, Tstate finalState, TransitionUnit *transition) |
| add a transition between two states | |
| void | removeState (const Tstate state) |
| void | removeTransition (const Tstate initialState, const TransitionUnit &transition) |
| void | makeFinal (const Tstate state) |
| make a state final | |
| void | unMakeFinal (const Tstate state) |
| remove a state from the final states | |
| void | setDeterministic (const bool det) |
| set the flag indicating if the automaton is deterministic or not (does not make the automaton deterministic, just set the flag) | |
| Automaton | subsets () const |
| make deterministic automaton with the subsets method (does not change the current instance of the autmomaton) | |
| Automaton | reverse () const |
| build the automaton that will accept the reverse strings of the language (does not change the current instance of the autmomaton) | |
| Automaton | brzozowskiMinimize () const |
| Brzozowski's algorithm for minimization : double reverse and determinization (does not change the current instance of the autmomaton) | |
| void | initializeSearchStructures (MediaId language) |
| bool | getMatchingTransitions (const LinguisticAnalysisStructure::AnalysisGraph &graph, const LinguisticGraphVertex &vertex, AnalysisContent &analysis, const SearchGraph *searchGraph, const Tstate &state, std::vector< std::pair< std::deque< LinguisticGraphVertex >, const Transition * > > &matchingTransitions, const LinguisticGraphVertex &limit) const |
Protected Types | |
| typedef std::set< Tstate > | SubSet |
Protected Member Functions | |
| void | init () |
| profix of identifier of transition | |
| void | copy (const Automaton &a) |
| void | freeMem () |
| bool | testFromState (const Tstate firstState, const LinguisticAnalysisStructure::AnalysisGraph &graph, const LinguisticGraphVertex &begin, const LinguisticGraphVertex &limit, AnalysisContent &analysis, AutomatonMatchSet &results, ConstraintCheckList &checkList, DFSStack &stack, const AutomatonControlParams &controlParams) const |
| bool | existsEpsilonPathToFinal (const Tstate state) const |
| std::vector< TransitionUnit * > | collectTransitions () const |
| bool | isFinalSubset (const SubSet &v) const |
| void | reachableStates (const SubSet &states, const TransitionUnit &t, SubSet &reachable) const |
| void | reachableStates (const Tstate &state, const TransitionUnit &t, SubSet &reachable) const |
| std::string | subsetString (const SubSet &subset) const |
Protected Attributes | |
| Tstate | m_numberStates |
| number of states in the automaton | |
| std::vector< bool > | m_finalStates |
| which states are final states | |
| std::vector< std::vector< Transition > > | m_transitions |
| the transitions | |
| std::vector< TransitionSearchStructure< Transition > * > | m_searchStructures |
| bool | m_deterministic |
| a boolean flag indicating if the automaton is deterministic or not | |
| std::string | m_id |
Friends | |
| class | AutomatonReader |
| class | AutomatonWriter |
| LIMA_AUTOMATON_EXPORT std::ostream & | operator<< (std::ostream &os, const Automaton &a) |
| output operator << overloading | |
| LIMA_AUTOMATON_EXPORT QDebug & | operator<< (QDebug &os, const Automaton &a) |
| LIMA_AUTOMATON_EXPORT std::ostream & | operator<< (std::ostream &os, const DFSStack &x) |
| LIMA_AUTOMATON_EXPORT QDebug & | operator<< (QDebug &os, const DFSStack &x) |
␈rief A class for the description of automata
this class is used for the definition of the automata implementing local grammars:
Definition at line 86 of file automaton.h.
| typedef std::pair<RecognizerMatch,ConstraintCheckList> Lima::LinguisticProcessing::Automaton::Automaton::AutomatonMatch |
types defined to store the result (or results of the application of the automaton on a graph
Definition at line 196 of file automaton.h.
| typedef std::set<AutomatonMatch,CompareAutomatonMatch> Lima::LinguisticProcessing::Automaton::Automaton::AutomatonMatchSet |
Definition at line 203 of file automaton.h.
|
protected |
Definition at line 374 of file automaton.h.
| Lima::LinguisticProcessing::Automaton::Automaton::Automaton | ( | const std::string & | automId = "" | ) |
void constructor initializes an empty automaton (no state, no transition)
Definition at line 62 of file automaton.cpp.
| Lima::LinguisticProcessing::Automaton::Automaton::Automaton | ( | const Automaton & | a | ) |
copy constructor
Definition at line 82 of file automaton.cpp.
| Lima::LinguisticProcessing::Automaton::Automaton::Automaton | ( | const Tstate | nbStates | ) |
constructor: build an automaton with a predefined number of states, no indications of final states, no transitions
| nbStates | : the number of states to reserve |
Definition at line 72 of file automaton.cpp.
| Lima::LinguisticProcessing::Automaton::Automaton::~Automaton | ( | ) |
destructor
Definition at line 90 of file automaton.cpp.
| Tstate Lima::LinguisticProcessing::Automaton::Automaton::addState | ( | bool | is_final = false | ) |
add a state to the automaton
| is_final | indicates if the state must be initialized as a final state of the automaton or not |
Definition at line 984 of file automaton.cpp.
| bool Lima::LinguisticProcessing::Automaton::Automaton::addTransition | ( | Tstate | initialState, |
| Tstate | finalState, | ||
| TransitionUnit * | transition | ||
| ) |
add a transition between two states
| initialState | the initial state |
| finalState | the final state |
| transition | the transition unit leading from the initial state to the final state |
Definition at line 993 of file automaton.cpp.
| Automaton Lima::LinguisticProcessing::Automaton::Automaton::brzozowskiMinimize | ( | ) | const |
Brzozowski's algorithm for minimization : double reverse and determinization (does not change the current instance of the autmomaton)
Definition at line 1342 of file automaton.cpp.
|
protected |
Definition at line 1232 of file automaton.cpp.
|
protected |
Definition at line 117 of file automaton.cpp.
|
protected |
Definition at line 201 of file automaton.cpp.
| vector< Tstate > Lima::LinguisticProcessing::Automaton::Automaton::finalStates | ( | ) | const |
get the list of the final states of the automaton
Definition at line 173 of file automaton.cpp.
|
protected |
Definition at line 140 of file automaton.cpp.
| bool Lima::LinguisticProcessing::Automaton::Automaton::getAllMatches | ( | const LinguisticAnalysisStructure::AnalysisGraph & | graph, |
| const LinguisticGraphVertex & | begin, | ||
| const LinguisticGraphVertex & | limit, | ||
| AnalysisContent & | analysis, | ||
| AutomatonMatchSet & | allMatches, | ||
| ConstraintCheckList & | checkList, | ||
| ForwardSearch & | forward, | ||
| BackwardSearch & | backward, | ||
| const SearchGraphSense | sense, | ||
| const AutomatonControlParams & | controlParams | ||
| ) | const |
get all matches found between automaton and graph between two points (WARNING: in case of backward search, matches returned are reversed : to to reverse them if natural sense of the graph is needed)
| graph | the graph |
| begin | the first vertex |
| limit | the last possible vertex |
| analysis | the current content of the analysis |
| allMatches | the matches found |
| checkList | the current state for constraint checking |
| sense | the sense of search in the graph (FORWARD or BACKWARD) |
| controlParams | parameters to control the search (for robust treatment of complex graphs) |
Definition at line 708 of file automaton.cpp.
| bool Lima::LinguisticProcessing::Automaton::Automaton::getBestMatch | ( | const LinguisticAnalysisStructure::AnalysisGraph & | graph, |
| const LinguisticGraphVertex & | begin, | ||
| const LinguisticGraphVertex & | limit, | ||
| AnalysisContent & | analysis, | ||
| RecognizerMatch & | longestMatch, | ||
| ConstraintCheckList & | checkList, | ||
| const SearchGraphSense | sense, | ||
| const AutomatonControlParams & | controlParams | ||
| ) | const |
test if a text corresponds to the automaton : the text is represented as a LinguisticAnalysisStructure::AnalysisGraph
| text | the LinguisticAnalysisStructure::AnalysisGraph corresponding to the beginning of the text to be analyzed |
| longestMatch | the result |
| checkList | the current state for constraint checking |
| sense | the sense of search in the graph (FORWARD or BACKWARD) |
| controlParams | parameters to control the search (for robust treatment of complex graphs) |
Definition at line 655 of file automaton.cpp.
| bool Lima::LinguisticProcessing::Automaton::Automaton::getMatchingTransitions | ( | const LinguisticAnalysisStructure::AnalysisGraph & | graph, |
| const LinguisticGraphVertex & | vertex, | ||
| AnalysisContent & | analysis, | ||
| const SearchGraph * | searchGraph, | ||
| const Tstate & | state, | ||
| std::vector< std::pair< std::deque< LinguisticGraphVertex >, const Transition * > > & | matchingTransitions, | ||
| const LinguisticGraphVertex & | limit | ||
| ) | const |
Definition at line 232 of file automaton.cpp.
|
inline |
get the list of transitions leaving from a given state
| state | : the state to consider |
Definition at line 414 of file automaton.h.
| bool Lima::LinguisticProcessing::Automaton::Automaton::hasTransitionsState | ( | const Tstate | state | ) | const |
test if a state of the automaton has out transitions
Definition at line 183 of file automaton.cpp.
|
protected |
profix of identifier of transition
Definition at line 108 of file automaton.cpp.
| void Lima::LinguisticProcessing::Automaton::Automaton::initializeSearchStructures | ( | MediaId | language | ) |
Definition at line 214 of file automaton.cpp.
|
inline |
test if the automaton is deterministic or not
Definition at line 409 of file automaton.h.
|
inline |
test if a given state is a final state of the automaton
| state | : the state to test |
Definition at line 403 of file automaton.h.
|
protected |
Definition at line 1099 of file automaton.cpp.
| void Lima::LinguisticProcessing::Automaton::Automaton::makeFinal | ( | const Tstate | state | ) |
make a state final
| state | the state to make final |
Definition at line 1056 of file automaton.cpp.
|
inline |
find the nth transition leaving from a particular state
| state | : the state |
| n | : the index of the transition we search for |
Definition at line 398 of file automaton.h.
|
inline |
get the number of states of the automaton
Definition at line 390 of file automaton.h.
| uint64_t Lima::LinguisticProcessing::Automaton::Automaton::numberOfTransitions | ( | ) | const |
get the number of transitions in the automaton
Definition at line 165 of file automaton.cpp.
|
inline |
find the number of transitions leaving from the state indicated in argument
| state | the state to watch |
Definition at line 394 of file automaton.h.
assignment operator
Definition at line 97 of file automaton.cpp.
|
protected |
Definition at line 1258 of file automaton.cpp.
|
protected |
Definition at line 1270 of file automaton.cpp.
| void Lima::LinguisticProcessing::Automaton::Automaton::reinit | ( | ) |
reinitializes the automaton (no states, no transitions)
Definition at line 156 of file automaton.cpp.
| void Lima::LinguisticProcessing::Automaton::Automaton::removeState | ( | const Tstate | state | ) |
Definition at line 1040 of file automaton.cpp.
| void Lima::LinguisticProcessing::Automaton::Automaton::removeTransition | ( | const Tstate | initialState, |
| const TransitionUnit & | transition | ||
| ) |
Definition at line 1045 of file automaton.cpp.
| Automaton Lima::LinguisticProcessing::Automaton::Automaton::reverse | ( | ) | const |
build the automaton that will accept the reverse strings of the language (does not change the current instance of the autmomaton)
Definition at line 1294 of file automaton.cpp.
| void Lima::LinguisticProcessing::Automaton::Automaton::setActionHash | ( | const std::vector< std::pair< LimaString, Constraint > > & | actionsWithOneArgument | ) |
set a property hashcode to each transition which represent the constraint(s?) of type action attached to it
Definition at line 1190 of file automaton.cpp.
| void Lima::LinguisticProcessing::Automaton::Automaton::setDeterministic | ( | const bool | det | ) |
set the flag indicating if the automaton is deterministic or not (does not make the automaton deterministic, just set the flag)
| det | the value to set the flag with (true to say the automaton is deterministic, false to say it is not) |
Definition at line 1064 of file automaton.cpp.
| Automaton Lima::LinguisticProcessing::Automaton::Automaton::subsets | ( | ) | const |
make deterministic automaton with the subsets method (does not change the current instance of the autmomaton)
Definition at line 1111 of file automaton.cpp.
|
protected |
Definition at line 1073 of file automaton.cpp.
|
protected |
Definition at line 759 of file automaton.cpp.
| void Lima::LinguisticProcessing::Automaton::Automaton::unMakeFinal | ( | const Tstate | state | ) |
remove a state from the final states
| state | the state to remove |
Definition at line 1060 of file automaton.cpp.
|
friend |
Definition at line 88 of file automaton.h.
|
friend |
Definition at line 89 of file automaton.h.
|
friend |
Definition at line 1379 of file automaton.cpp.
|
friend |
Definition at line 473 of file automaton.cpp.
|
friend |
output operator << overloading
Definition at line 1360 of file automaton.cpp.
|
friend |
Definition at line 459 of file automaton.cpp.
|
protected |
a boolean flag indicating if the automaton is deterministic or not
Definition at line 346 of file automaton.h.
|
protected |
which states are final states
Definition at line 343 of file automaton.h.
|
protected |
Definition at line 348 of file automaton.h.
|
protected |
number of states in the automaton
Definition at line 342 of file automaton.h.
|
protected |
Definition at line 345 of file automaton.h.
|
protected |
the transitions
Definition at line 344 of file automaton.h.