Search/Lucene/Search/BooleanExpressionRecognizer.php
Zend Framework
LICENSE
This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to [email protected] so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Search_Lucene
- Subpackage
- Search
- Version
- $Id: BooleanExpressionRecognizer.php 24593 2012-01-05 20:35:02Z matthew $
\Zend_Search_Lucene_Search_BooleanExpressionRecognizer
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
- Parent(s)
- \Zend_Search_Lucene_FSM
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Constants
Properties

array $_conjunctions = array()Set of boolean query conjunctions
Each conjunction is an array of conjunction elements
Each conjunction element is presented with two-elements array:
array(
So, it has a structure:
array( array( array(
array()Details- Type
- array

integer|string $_currentState = null
nullDetails- Type
- integer | string
- Inherited_from
- \Zend_Search_Lucene_FSM::$$_currentState

array $_entryActions = array()List of entry actions Each action executes when entering the state
Inherited from: \Zend_Search_Lucene_FSM::$$_entryActions[state] => action
array()Details- Type
- array
- Inherited_from
- \Zend_Search_Lucene_FSM::$$_entryActions

array $_exitActions = array()List of exit actions Each action executes when exiting the state
Inherited from: \Zend_Search_Lucene_FSM::$$_exitActions[state] => action
array()Details- Type
- array
- Inherited_from
- \Zend_Search_Lucene_FSM::$$_exitActions

array $_inputActions = array()List of input actions Each action executes when entering the state
Inherited from: \Zend_Search_Lucene_FSM::$$_inputActions[state][input] => action
array()Details- Type
- array
- Inherited_from
- \Zend_Search_Lucene_FSM::$$_inputActions

array $_inputAphabet = array()
array()Details- Type
- array
- Inherited_from
- \Zend_Search_Lucene_FSM::$$_inputAphabet

array $_rules = array()
[sourceState][input] => targetState
array()Details- Type
- array
- Inherited_from
- \Zend_Search_Lucene_FSM::$$_rules

array $_states = array()
array()Details- Type
- array
- Inherited_from
- \Zend_Search_Lucene_FSM::$$_states

array $_transitionActions = array()List of input actions Each action executes when entering the state
Inherited from: \Zend_Search_Lucene_FSM::$$_transitionActions[state1][state2] => action
array()Details- Type
- array
- Inherited_from
- \Zend_Search_Lucene_FSM::$$_transitionActions
Methods

__construct() : voidObject constructor
$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.

addEntryAction(integer | string $state, \Zend_Search_Lucene_FSMAction $action) : void
Several entry actions are allowed. Action execution order is defined by addEntryAction() calls
| Name | Type | Description |
|---|---|---|
| $state | integer | string | |
| $action | \Zend_Search_Lucene_FSMAction |

addExitAction(integer | string $state, \Zend_Search_Lucene_FSMAction $action) : void
Several exit actions are allowed. Action execution order is defined by addEntryAction() calls
| Name | Type | Description |
|---|---|---|
| $state | integer | string | |
| $action | \Zend_Search_Lucene_FSMAction |

addInputAction(integer | string $state, $inputSymbol, \Zend_Search_Lucene_FSMAction $action) : voidAdd input action (defined by {state, input} pair).
Inherited from: \Zend_Search_Lucene_FSM::addInputAction()Several input actions are allowed. Action execution order is defined by addInputAction() calls
| Name | Type | Description |
|---|---|---|
| $state | integer | string | |
| $inputSymbol | ||
| $action | \Zend_Search_Lucene_FSMAction |

addInputSymbol(integer | string $inputSymbol) : void
| Name | Type | Description |
|---|---|---|
| $inputSymbol | integer | string |

addInputSymbols(array $inputAphabet) : voidAdd symbols to the input alphabet
Inherited from: \Zend_Search_Lucene_FSM::addInputSymbols()| Name | Type | Description |
|---|---|---|
| $inputAphabet | array |

addRule(integer | string $sourceState, integer | string $input, integer | string $targetState, \Zend_Search_Lucene_FSMAction | null $inputAction = null) : void
| Name | Type | Description |
|---|---|---|
| $sourceState | integer | string | |
| $input | integer | string | |
| $targetState | integer | string | |
| $inputAction | \Zend_Search_Lucene_FSMAction | null |
| Exception | Description |
|---|---|
| \Zend_Search_Exception |

addRules(array $rules) : void
array structure: array( array(sourseState, input, targetState[, inputAction]), array(sourseState, input, targetState[, inputAction]), array(sourseState, input, targetState[, inputAction]), ... )
| Name | Type | Description |
|---|---|---|
| $rules | array |

addTransitionAction(integer | string $sourceState, integer | string $targetState, \Zend_Search_Lucene_FSMAction $action) : voidAdd transition action (defined by {state, input} pair).
Inherited from: \Zend_Search_Lucene_FSM::addTransitionAction()Several transition actions are allowed. Action execution order is defined by addTransitionAction() calls
| Name | Type | Description |
|---|---|---|
| $sourceState | integer | string | |
| $targetState | integer | string | |
| $action | \Zend_Search_Lucene_FSMAction |

finishExpression() : arrayFinish an expression and return result
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(
So, it has a structure:
array( array( array(
| Type | Description |
|---|---|
| array |
| Exception | Description |
|---|---|
| \Zend_Search_Lucene_Exception |

process(mixed $input) : void
| Name | Type | Description |
|---|---|---|
| $input | mixed |
| Exception | Description |
|---|---|
| \Zend_Search_Exception |

processLiteral( $literal) : voidProcess expression literal.
| Name | Type | Description |
|---|---|---|
| $literal |

processOperator(integer $operator) : voidProcess next operator.
Operators are defined by class constants: IN_AND_OPERATOR, IN_OR_OPERATOR and IN_NOT_OPERATOR
| Name | Type | Description |
|---|---|---|
| $operator | integer |

setState(integer | string $state) : void
No any action is invoked
| Name | Type | Description |
|---|---|---|
| $state | integer | string |
| Exception | Description |
|---|---|
| \Zend_Search_Exception |