Skip to content
Snippets Groups Projects
Commit 8deb0f86 authored by Jan Trávníček's avatar Jan Trávníček
Browse files

normalize tree automata

parent d66ae442
No related branches found
No related tags found
No related merge requests found
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "../AutomatonBase.h" #include "../AutomatonBase.h"
#include "../common/AutomatonFromXMLParser.h" #include "../common/AutomatonFromXMLParser.h"
#include "../common/AutomatonToXMLComposer.h" #include "../common/AutomatonToXMLComposer.h"
#include "../common/AutomatonNormalize.h"
   
namespace automaton { namespace automaton {
   
...@@ -147,6 +148,24 @@ public: ...@@ -147,6 +148,24 @@ public:
void composeTransitions ( std::deque < sax::Token > & out ) const; void composeTransitions ( std::deque < sax::Token > & out ) const;
   
virtual alib::ObjectBase * inc ( ) &&; virtual alib::ObjectBase * inc ( ) &&;
virtual AutomatonBase * normalize ( ) && {
std::set < std::ranked_symbol < DefaultSymbolType > > alphabet = AutomatonNormalize::normalizeRankedAlphabet ( std::move ( this->template accessComponent < InputAlphabet > ( ).get ( ) ) );
std::set < DefaultStateType > states = AutomatonNormalize::normalizeStates ( std::move ( this->template accessComponent < States > ( ).get ( ) ) );
std::set < DefaultStateType > finalStates = AutomatonNormalize::normalizeStates ( std::move ( this->template accessComponent < FinalStates > ( ).get ( ) ) );
DFTA < > * res = new DFTA < > ( std::move ( states ), std::move ( alphabet ), std::move ( finalStates ) );
for ( std::pair < std::pair < std::ranked_symbol < SymbolType, RankType >, std::vector < StateType > >, StateType > && transition : std::make_moveable_map ( transitions ) ) {
std::ranked_symbol < DefaultSymbolType, DefaultRankType > input = AutomatonNormalize::normalizeRankedSymbol ( std::move ( transition.first.first ) );
std::vector < DefaultStateType > from = AutomatonNormalize::normalizeStates ( std::move ( transition.first.second ) );
DefaultStateType to = AutomatonNormalize::normalizeState ( std::move ( transition.second ) );
res->addTransition ( std::move ( input ), std::move ( from ), std::move ( to ) );
}
return res;
}
}; };
   
} /* namespace automaton */ } /* namespace automaton */
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "../AutomatonException.h" #include "../AutomatonException.h"
#include "../common/AutomatonFromXMLParser.h" #include "../common/AutomatonFromXMLParser.h"
#include "../common/AutomatonToXMLComposer.h" #include "../common/AutomatonToXMLComposer.h"
#include "../common/AutomatonNormalize.h"
   
namespace automaton { namespace automaton {
   
...@@ -165,6 +166,24 @@ public: ...@@ -165,6 +166,24 @@ public:
void composeTransitions ( std::deque < sax::Token > & out ) const; void composeTransitions ( std::deque < sax::Token > & out ) const;
   
virtual alib::ObjectBase * inc ( ) &&; virtual alib::ObjectBase * inc ( ) &&;
virtual AutomatonBase * normalize ( ) && {
std::set < std::ranked_symbol < DefaultSymbolType > > alphabet = AutomatonNormalize::normalizeRankedAlphabet ( std::move ( this->template accessComponent < InputAlphabet > ( ).get ( ) ) );
std::set < DefaultStateType > states = AutomatonNormalize::normalizeStates ( std::move ( this->template accessComponent < States > ( ).get ( ) ) );
std::set < DefaultStateType > finalStates = AutomatonNormalize::normalizeStates ( std::move ( this->template accessComponent < FinalStates > ( ).get ( ) ) );
NFTA < > * res = new NFTA < > ( std::move ( states ), std::move ( alphabet ), std::move ( finalStates ) );
for ( std::pair < std::pair < std::ranked_symbol < SymbolType, RankType >, std::vector < StateType > >, std::set < StateType > > && transition : std::make_moveable_map ( transitions ) ) {
std::ranked_symbol < DefaultSymbolType, DefaultRankType > input = AutomatonNormalize::normalizeRankedSymbol ( std::move ( transition.first.first ) );
std::vector < DefaultStateType > from = AutomatonNormalize::normalizeStates ( std::move ( transition.first.second ) );
std::set < DefaultStateType > to = AutomatonNormalize::normalizeStates ( std::move ( transition.second ) );
res->addTransitions ( std::move ( input ), std::move ( from ), std::move ( to ) );
}
return res;
}
}; };
   
} /* namespace automaton */ } /* namespace automaton */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment