HumHub Documentation (unofficial)

BooleanExpressionRecognizer extends AbstractFSM
in package

Abstract Finite State Machine

Tags
category

Zend

subpackage

Search

Table of Contents

Constants

IN_AND_OPERATOR  = 2
IN_LITERAL  = 0
Input symbols
IN_NOT_OPERATOR  = 1
IN_OR_OPERATOR  = 3
ST_AND_OPERATOR  = 3
ST_LITERAL  = 1
ST_NOT_OPERATOR  = 2
ST_OR_OPERATOR  = 4
ST_START  = 0
State Machine states

Properties

$_conjunctions  : array<string|int, mixed>
Set of boolean query conjunctions
$_currentConjunction  : array<string|int, mixed>
Current conjuction
$_currentState  : int|string
Current state
$_entryActions  : array<string|int, mixed>
List of entry actions Each action executes when entering the state
$_exitActions  : array<string|int, mixed>
List of exit actions Each action executes when exiting the state
$_inputActions  : array<string|int, mixed>
List of input actions Each action executes when entering the state
$_inputAphabet  : array<string|int, mixed>
Input alphabet
$_literal  : mixed
Current literal
$_negativeLiteral  : bool
NOT operator signal
$_rules  : array<string|int, mixed>
State transition table
$_states  : array<string|int, mixed>
Machine States alphabet
$_transitionActions  : array<string|int, mixed>
List of input actions Each action executes when entering the state

Methods

__construct()  : mixed
Object constructor
addEntryAction()  : void
Add state entry action.
addExitAction()  : void
Add state exit action.
addInputAction()  : void
Add input action (defined by {state, input} pair).
addInputSymbol()  : void
Add symbol to the input alphabet
addInputSymbols()  : void
Add symbols to the input alphabet
addRule()  : void
Add symbol to the input alphabet
addRules()  : void
Add transition rules
addState()  : void
Add state to the state machine
addStates()  : void
Add states to the state machine
addTransitionAction()  : void
Add transition action (defined by {state, input} pair).
emptyNotOperatorAction()  : void
default (omitted) + NOT operator processing
emptyOperatorAction()  : void
default (omitted) operator processing
finishExpression()  : array<string|int, mixed>
Finish an expression and return result
getState()  : int|string
Get FSM state.
literalAction()  : void
Literal processing
notOperatorAction()  : void
NOT operator processing
orOperatorAction()  : void
OR operator processing Close current conjunction
process()  : void
Process an input
processLiteral()  : void
Process expression literal.
processOperator()  : void
Process next operator.
reset()  : void
setState()  : void
Set FSM state.

Constants

Properties

$_conjunctions

Set of boolean query conjunctions

private array<string|int, mixed> $_conjunctions = array()

Each conjunction is an array of conjunction elements Each conjunction element is presented with two-elements array: array(, <is_negative>)

So, it has a structure: array( array( array(, <is_negative>), // first literal of first conjuction array(, <is_negative>), // second literal of first conjuction ... array(, <is_negative>) ), // end of first conjuction array( array(, <is_negative>), // first literal of second conjuction array(, <is_negative>), // second literal of second conjuction ... array(, <is_negative>) ), // end of second conjuction ... ) // end of structure

$_currentState

Current state

private int|string $_currentState = null

$_entryActions

List of entry actions Each action executes when entering the state

private array<string|int, mixed> $_entryActions = array()

[state] => action

$_exitActions

List of exit actions Each action executes when exiting the state

private array<string|int, mixed> $_exitActions = array()

[state] => action

$_inputActions

List of input actions Each action executes when entering the state

private array<string|int, mixed> $_inputActions = array()

[state][input] => action

$_inputAphabet

Input alphabet

private array<string|int, mixed> $_inputAphabet = array()

$_rules

State transition table

private array<string|int, mixed> $_rules = array()

[sourceState][input] => targetState

$_states

Machine States alphabet

private array<string|int, mixed> $_states = array()

$_transitionActions

List of input actions Each action executes when entering the state

private array<string|int, mixed> $_transitionActions = array()

[state1][state2] => action

Methods

addEntryAction()

Add state entry action.

public addEntryAction(int|string $state, FSMAction $action) : void

Several entry actions are allowed. Action execution order is defined by addEntryAction() calls

Parameters
$state : int|string
$action : FSMAction
Tags
throws
InvalidArgumentException

addExitAction()

Add state exit action.

public addExitAction(int|string $state, FSMAction $action) : void

Several exit actions are allowed. Action execution order is defined by addEntryAction() calls

Parameters
$state : int|string
$action : FSMAction
Tags
throws
InvalidArgumentException

addInputAction()

Add input action (defined by {state, input} pair).

public addInputAction(int|string $state, int|string $inputSymbol, FSMAction $action) : void

Several input actions are allowed. Action execution order is defined by addInputAction() calls

Parameters
$state : int|string
$inputSymbol : int|string
$action : FSMAction
Tags
throws
InvalidArgumentException

addInputSymbol()

Add symbol to the input alphabet

public addInputSymbol(int|string $inputSymbol) : void
Parameters
$inputSymbol : int|string

addInputSymbols()

Add symbols to the input alphabet

public addInputSymbols(array<string|int, mixed> $inputAphabet) : void
Parameters
$inputAphabet : array<string|int, mixed>

addRule()

Add symbol to the input alphabet

public addRule(int|string $sourceState, int|string $input, int|string $targetState[, FSMAction|null $inputAction = null ]) : void
Parameters
$sourceState : int|string
$input : int|string
$targetState : int|string
$inputAction : FSMAction|null = null
Tags
throws
InvalidArgumentException
throws
RuntimeException

addRules()

Add transition rules

public addRules(array<string|int, mixed> $rules) : void

array structure: array( array(sourseState, input, targetState[, inputAction]), array(sourseState, input, targetState[, inputAction]), array(sourseState, input, targetState[, inputAction]), ... )

Parameters
$rules : array<string|int, mixed>

addState()

Add state to the state machine

public addState(int|string $state) : void
Parameters
$state : int|string

addStates()

Add states to the state machine

public addStates(array<string|int, mixed> $states) : void
Parameters
$states : array<string|int, mixed>

addTransitionAction()

Add transition action (defined by {state, input} pair).

public addTransitionAction(int|string $sourceState, int|string $targetState, FSMAction $action) : void

Several transition actions are allowed. Action execution order is defined by addTransitionAction() calls

Parameters
$sourceState : int|string
$targetState : int|string
$action : FSMAction
Tags
throws
InvalidArgumentException

finishExpression()

Finish an expression and return result

public finishExpression() : array<string|int, mixed>

Result is a set of boolean query conjunctions

Each conjunction is an array of conjunction elements Each conjunction element is presented with two-elements array: array(, <is_negative>)

So, it has a structure: array( array( array(, <is_negative>), // first literal of first conjuction array(, <is_negative>), // second literal of first conjuction ... array(, <is_negative>) ), // end of first conjuction array( array(, <is_negative>), // first literal of second conjuction array(, <is_negative>), // second literal of second conjuction ... array(, <is_negative>) ), // end of second conjuction ... ) // end of structure

Tags
throws
UnexpectedValueException
Return values
array<string|int, mixed>

getState()

Get FSM state.

public getState() : int|string
Return values
int|string

$state|null

processOperator()

Process next operator.

public processOperator(int $operator) : void

Operators are defined by class constants: IN_AND_OPERATOR, IN_OR_OPERATOR and IN_NOT_OPERATOR

Parameters
$operator : int

        
On this page

Search results