Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
SequenceMatchingAutomaton.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <automaton/FSM/NFA.h>
9#include <string/LinearString.h>
10
11namespace stringology {
12
13namespace matching {
14
16public:
21 template < class SymbolType >
23};
24
25template < class SymbolType >
28 result.setInputAlphabet(pattern.getAlphabet());
29
30 for ( const SymbolType & symbol: pattern.getAlphabet()) {
31 result.addTransition(0, symbol, 0);
32 }
33
34 for ( unsigned int i=0; i<pattern.getContent().size(); i++) {
35 auto from = i;
36 auto to = i+1;
37
38 result.addState(to);
39 result.addTransition(from, pattern.getContent()[i], to);
40
41 for( const SymbolType & symbol: pattern.getAlphabet()) {
42 if (symbol != pattern.getContent()[i]) {
43 result.addTransition(from, symbol, from);
44 }
45 }
46 }
47
48 result.addFinalState(pattern.getContent().size());
49
50 return result;
51}
52
53} /* namespace matching */
54
55} /* namespace stringology */
56
Nondeterministic finite automaton. Accepts regular languages.
Definition: NFA.h:66
Linear string.
Definition: LinearString.h:57
const ext::set< SymbolType > & getAlphabet() const &
Definition: LinearString.h:103
const ext::vector< SymbolType > & getContent() const &
Definition: LinearString.h:238
Definition: SequenceMatchingAutomaton.h:15
static automaton::NFA< SymbolType, unsigned int > construct(const string::LinearString< SymbolType > &pattern)
Definition: SequenceMatchingAutomaton.h:26
int i
Definition: AllEpsilonClosure.h:118
typename T::SymbolType SymbolType
Definition: ReachableStates.h:176
for(const StateType &state :fsm.getStates()) renamingData.insert(std Rename::RenamedAutomaton< T > result(renamingData.at(fsm.getInitialState()))
Definition: Rename.h:253
Definition: ArithmeticCompression.h:18