Abstract Finite State Machine

Take a look on Wikipedia state machine description: http://en.wikipedia.org/wiki/Finite_state_machine

Any type of Transducers (Moore machine or Mealy machine) also may be implemented by using this abstract FSM. process() methods invokes a specified actions which may construct FSM output. Actions may be also used to signal, that we have reached Accept State

category Zend
package Zend_Search_Lucene
subpackage Search
copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
license New BSD License
inherited_from \Zend_Search_Lucene_FSM

 Methods

Parser constructor

__construct() 

$states is an array of integers or strings with a list of possible machine states constructor treats fist list element as a sturt state (assignes it to $_current state). It may be reassigned by setState() call. States list may be empty and can be extended later by addState() or addStates() calls.

$inputAphabet is the same as $states, but represents input alphabet it also may be extended later by addInputSymbols() or addInputSymbol() calls.

$rules parameter describes FSM transitions and has a structure: array( array(sourseState, input, targetState[, inputAction]), array(sourseState, input, targetState[, inputAction]), array(sourseState, input, targetState[, inputAction]), ... ) Rules also can be added later by addRules() and addRule() calls.

FSM actions are very flexible and may be defined by addEntryAction(), addExitAction(), addInputAction() and addTransitionAction() calls.

inherited_from \Zend_Search_Lucene_FSM::__construct()

Finite State machine constructor

__construct(array $states = array(), array $inputAphabet = array(), array $rules = array()
Inherited

$states is an array of integers or strings with a list of possible machine states constructor treats fist list element as a sturt state (assignes it to $_current state). It may be reassigned by setState() call. States list may be empty and can be extended later by addState() or addStates() calls.

$inputAphabet is the same as $states, but represents input alphabet it also may be extended later by addInputSymbols() or addInputSymbol() calls.

$rules parameter describes FSM transitions and has a structure: array( array(sourseState, input, targetState[, inputAction]), array(sourseState, input, targetState[, inputAction]), array(sourseState, input, targetState[, inputAction]), ... ) Rules also can be added later by addRules() and addRule() calls.

FSM actions are very flexible and may be defined by addEntryAction(), addExitAction(), addInputAction() and addTransitionAction() calls.

Parameters

$states

array

$inputAphabet

array

$rules

array

Add state entry action.

addEntryAction(integer|string $state, \Zend_Search_Lucene_FSMAction $action) 
Inherited

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

Parameters

$state

integerstring

$action

\Zend_Search_Lucene_FSMAction

Add state exit action.

addExitAction(integer|string $state, \Zend_Search_Lucene_FSMAction $action) 
Inherited

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

Parameters

$state

integerstring

$action

\Zend_Search_Lucene_FSMAction

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

addInputAction(integer|string $state, $inputSymbol, \Zend_Search_Lucene_FSMAction $action) 
Inherited

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

Parameters

$state

integerstring

$inputSymbol

$action

\Zend_Search_Lucene_FSMAction

Add symbol to the input alphabet

addInputSymbol(integer|string $inputSymbol) 
Inherited

Parameters

$inputSymbol

integerstring

Add symbols to the input alphabet

addInputSymbols(array $inputAphabet) 
Inherited

Parameters

$inputAphabet

array

Add phrase to a query

addPhraseEntry() 

Add symbol to the input alphabet

addRule(integer|string $sourceState, integer|string $input, integer|string $targetState, \Zend_Search_Lucene_FSMAction|null $inputAction = null
Inherited

Parameters

$sourceState

integerstring

$input

integerstring

$targetState

integerstring

$inputAction

\Zend_Search_Lucene_FSMActionnull

Exceptions

\Zend_Search_Exception

Add transition rules

addRules(array $rules) 
Inherited

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

Parameters

$rules

array

Add state to the state machine

addState(integer|string $state) 
Inherited

Parameters

$state

integerstring

Add states to the state machine

addStates(array $states) 
Inherited

Parameters

$states

array

Add term to a query

addTermEntry() 

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

addTransitionAction(integer|string $sourceState, integer|string $targetState, \Zend_Search_Lucene_FSMAction $action) 
Inherited

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

Parameters

$sourceState

integerstring

$targetState

integerstring

$action

\Zend_Search_Lucene_FSMAction

Process first range query term (closed interval)

closedRQFirstTerm() 

Process last range query term (closed interval)

closedRQLastTerm() 

Exceptions

\Zend_Search_Lucene_Search_QueryParserException

Turn off 'suppress query parser exceptions' mode.

dontSuppressQueryParsingExceptions() 
Static

Escape keyword to force it to be parsed as one term

escape(string $keyword) : string
Static

Parameters

$keyword

string

Returns

string

Get query string default encoding

getDefaultEncoding() : string
Static

Returns

string

Get default boolean operator

getDefaultOperator() : integer
Static

Returns

integer

Get FSM state.

getState() : integer | string
Inherited

Returns

integerstring$state|null

Process logical operator

logicalOperator() 

Process first range query term (opened interval)

openedRQFirstTerm() 

Process last range query term (opened interval)

openedRQLastTerm() 

Exceptions

\Zend_Search_Lucene_Search_QueryParserException

Parses a query string

parse(string $strQuery, string $encoding = null) : \Zend_Search_Lucene_Search_Query
Static

Parameters

$strQuery

string

$encoding

string

Exceptions

\Zend_Search_Lucene_Search_QueryParserException

Returns

\Zend_Search_Lucene_Search_Query

Process an input

process(mixed $input) 
Inherited

Parameters

$input

mixed

Exceptions

\Zend_Search_Exception

Process fuzzy search/proximity modifier - '~'

processFuzzyProximityModifier() 

Process modifier parameter

processModifierParameter() 

Exceptions

\Zend_Search_Lucene_Exception

Check 'suppress query parser exceptions' mode.

queryParsingExceptionsSuppressed() : boolean
Static

Returns

boolean

reset()

reset() 
Inherited

Set query string default encoding

setDefaultEncoding(string $encoding) 
Static

Parameters

$encoding

string

Set default boolean operator

setDefaultOperator(integer $operator) 
Static

Parameters

$operator

integer

Set entry field

setField() 

Set entry sign

setSign() 

Set FSM state.

setState(integer|string $state) 
Inherited

No any action is invoked

Parameters

$state

integerstring

Exceptions

\Zend_Search_Exception

End subquery

subqueryEnd() 

Start subquery

subqueryStart() 

Turn on 'suppress query parser exceptions' mode.

suppressQueryParsingExceptions() 
Static

Get query parser instance

_getInstance() : \Zend_Search_Lucene_Search_QueryParser
Static

Returns

\Zend_Search_Lucene_Search_QueryParser

 Properties

 

Current query parser context

$_context : \Zend_Search_Lucene_Search_QueryParserContext

Default

 

Context stack

$_contextStack : array

Default

 

Current state

$_currentState : integer | string

Default

null
 

Current token

$_currentToken : integer | string

Default

 

Query string default encoding

$_defaultEncoding : string

Default

''
 

Default boolean queries operator

$_defaultOperator : integer

Default

self::B_OR
 

Query string encoding

$_encoding : string

Default

 

List of entry actions Each action executes when entering the state

$_entryActions : array

Default

array()

[state] => action

 

List of exit actions Each action executes when exiting the state

$_exitActions : array

Default

array()

[state] => action

 

List of input actions Each action executes when entering the state

$_inputActions : array

Default

array()

[state][input] => action

 

Input alphabet

$_inputAphabet : array

Default

array()
 

Parser instance

$_instance : \Zend_Search_Lucene_Search_QueryParser

Default

null
Static
 

Last token

$_lastToken : \Zend_Search_Lucene_Search_QueryToken

Default

null

It can be processed within FSM states, but this addirional state simplifies FSM

 

Query lexer

$_lexer : \Zend_Search_Lucene_Search_QueryLexer

Default

 

Range query first term

$_rqFirstTerm : string

Default

null
 

State transition table

$_rules : array

Default

array()

[sourceState][input] => targetState

 

Machine States alphabet

$_states : array

Default

array()
 

Defines query parsing mode.

$_suppressQueryParsingExceptions : boolean

Default

true

If this option is turned on, then query parser suppress query parser exceptions and constructs multi-term query using all words from a query.

That helps to avoid exceptions caused by queries, which don't conform to query language, but limits possibilities to check, that query entered by user has some inconsistencies.

Default is true.

Use \Zend_Search_Lucene::suppressQueryParsingExceptions(), \Zend_Search_Lucene::dontSuppressQueryParsingExceptions() and \Zend_Search_Lucene::checkQueryParsingExceptionsSuppressMode() to operate with this setting.

 

Tokens list Array of Zend_Search_Lucene_Search_QueryToken objects

$_tokens : array

Default

 

List of input actions Each action executes when entering the state

$_transitionActions : array

Default

array()

[state1][state2] => action

 Constants

 

B_AND

B_AND = 1 
 

Boolean operators constants

B_OR = 0 
 

ST_CLOSEDINT_RQ_END

ST_CLOSEDINT_RQ_END = 5 
 

ST_CLOSEDINT_RQ_FIRST_TERM

ST_CLOSEDINT_RQ_FIRST_TERM = 2 
 

ST_CLOSEDINT_RQ_LAST_TERM

ST_CLOSEDINT_RQ_LAST_TERM = 4 
 

ST_CLOSEDINT_RQ_START

ST_CLOSEDINT_RQ_START = 1 
 

ST_CLOSEDINT_RQ_TO_TERM

ST_CLOSEDINT_RQ_TO_TERM = 3 
 

Query parser State Machine states

ST_COMMON_QUERY_ELEMENT = 0 
 

ST_OPENEDINT_RQ_END

ST_OPENEDINT_RQ_END = 10 
 

ST_OPENEDINT_RQ_FIRST_TERM

ST_OPENEDINT_RQ_FIRST_TERM = 7 
 

ST_OPENEDINT_RQ_LAST_TERM

ST_OPENEDINT_RQ_LAST_TERM = 9 
 

ST_OPENEDINT_RQ_START

ST_OPENEDINT_RQ_START = 6 
 

ST_OPENEDINT_RQ_TO_TERM

ST_OPENEDINT_RQ_TO_TERM = 8