Search/Lucene/Search/BooleanExpressionRecognizer.php

Show: inherited
Table of Contents

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

Package: Zend\Search\Lucene\Search

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

Constant  ST_START = 0

State Machine states

Constant  ST_LITERAL = 1
Constant  ST_NOT_OPERATOR = 2
Constant  ST_AND_OPERATOR = 3
Constant  ST_OR_OPERATOR = 4
Constant  IN_LITERAL = 0

Input symbols

Constant  IN_NOT_OPERATOR = 1
Constant  IN_AND_OPERATOR = 2
Constant  IN_OR_OPERATOR = 3

Properties

Propertyprivatearray $_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(, ), // first literal of first conjuction array(, ), // second literal of first conjuction ... array(, ) ), // end of first conjuction array( array(, ), // first literal of second conjuction array(, ), // second literal of second conjuction ... array(, ) ), // end of second conjuction ... ) // end of structure

Default valuearray()Details
Type
array
Propertyprivatearray $_currentConjunction = array()

Current conjuction

Default valuearray()Details
Type
array
Propertyprivateinteger|string $_currentState = null
inherited

Current state

Inherited from: \Zend_Search_Lucene_FSM::$$_currentState
Default valuenullDetails
Type
integer | string
Inherited_from
\Zend_Search_Lucene_FSM::$$_currentState  
Propertyprivatearray $_entryActions = array()
inherited

List of entry actions Each action executes when entering the state

Inherited from: \Zend_Search_Lucene_FSM::$$_entryActions

[state] => action

Default valuearray()Details
Type
array
Inherited_from
\Zend_Search_Lucene_FSM::$$_entryActions  
Propertyprivatearray $_exitActions = array()
inherited

List of exit actions Each action executes when exiting the state

Inherited from: \Zend_Search_Lucene_FSM::$$_exitActions

[state] => action

Default valuearray()Details
Type
array
Inherited_from
\Zend_Search_Lucene_FSM::$$_exitActions  
Propertyprivatearray $_inputActions = array()
inherited

List of input actions Each action executes when entering the state

Inherited from: \Zend_Search_Lucene_FSM::$$_inputActions

[state][input] => action

Default valuearray()Details
Type
array
Inherited_from
\Zend_Search_Lucene_FSM::$$_inputActions  
Propertyprivatearray $_inputAphabet = array()
inherited

Input alphabet

Inherited from: \Zend_Search_Lucene_FSM::$$_inputAphabet
Default valuearray()Details
Type
array
Inherited_from
\Zend_Search_Lucene_FSM::$$_inputAphabet  
Propertyprivatemixed $_literal =

Current literal

Details
Type
mixed
Propertyprivateboolean $_negativeLiteral = false

NOT operator signal

Default valuefalseDetails
Type
boolean
Propertyprivatearray $_rules = array()
inherited

State transition table

Inherited from: \Zend_Search_Lucene_FSM::$$_rules

[sourceState][input] => targetState

Default valuearray()Details
Type
array
Inherited_from
\Zend_Search_Lucene_FSM::$$_rules  
Propertyprivatearray $_states = array()
inherited

Machine States alphabet

Inherited from: \Zend_Search_Lucene_FSM::$$_states
Default valuearray()Details
Type
array
Inherited_from
\Zend_Search_Lucene_FSM::$$_states  
Propertyprivatearray $_transitionActions = array()
inherited

List of input actions Each action executes when entering the state

Inherited from: \Zend_Search_Lucene_FSM::$$_transitionActions

[state1][state2] => action

Default valuearray()Details
Type
array
Inherited_from
\Zend_Search_Lucene_FSM::$$_transitionActions  

Methods

methodpublic__construct() : void

Object 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.

methodpublicaddEntryAction(integer | string $state, \Zend_Search_Lucene_FSMAction $action) : void
inherited

Add state entry action.

Inherited from: \Zend_Search_Lucene_FSM::addEntryAction()

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

Parameters
Name Type Description
$state integer | string
$action \Zend_Search_Lucene_FSMAction
methodpublicaddExitAction(integer | string $state, \Zend_Search_Lucene_FSMAction $action) : void
inherited

Add state exit action.

Inherited from: \Zend_Search_Lucene_FSM::addExitAction()

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

Parameters
Name Type Description
$state integer | string
$action \Zend_Search_Lucene_FSMAction
methodpublicaddInputAction(integer | string $state,  $inputSymbol, \Zend_Search_Lucene_FSMAction $action) : void
inherited

Add 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

Parameters
Name Type Description
$state integer | string
$inputSymbol
$action \Zend_Search_Lucene_FSMAction
methodpublicaddInputSymbol(integer | string $inputSymbol) : void
inherited

Add symbol to the input alphabet

Inherited from: \Zend_Search_Lucene_FSM::addInputSymbol()
Parameters
Name Type Description
$inputSymbol integer | string
methodpublicaddInputSymbols(array $inputAphabet) : void
inherited

Add symbols to the input alphabet

Inherited from: \Zend_Search_Lucene_FSM::addInputSymbols()
Parameters
Name Type Description
$inputAphabet array
methodpublicaddRule(integer | string $sourceState, integer | string $input, integer | string $targetState, \Zend_Search_Lucene_FSMAction | null $inputAction = null) : void
inherited

Add symbol to the input alphabet

Inherited from: \Zend_Search_Lucene_FSM::addRule()
Parameters
Name Type Description
$sourceState integer | string
$input integer | string
$targetState integer | string
$inputAction \Zend_Search_Lucene_FSMAction | null
Throws
Exception Description
\Zend_Search_Exception
methodpublicaddRules(array $rules) : void
inherited

Add transition rules

Inherited from: \Zend_Search_Lucene_FSM::addRules()

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

Parameters
Name Type Description
$rules array
methodpublicaddState(integer | string $state) : void
inherited

Add state to the state machine

Inherited from: \Zend_Search_Lucene_FSM::addState()
Parameters
Name Type Description
$state integer | string
methodpublicaddStates(array $states) : void
inherited

Add states to the state machine

Inherited from: \Zend_Search_Lucene_FSM::addStates()
Parameters
Name Type Description
$states array
methodpublicaddTransitionAction(integer | string $sourceState, integer | string $targetState, \Zend_Search_Lucene_FSMAction $action) : void
inherited

Add 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

Parameters
Name Type Description
$sourceState integer | string
$targetState integer | string
$action \Zend_Search_Lucene_FSMAction
methodpublicemptyNotOperatorAction() : void

default (omitted) + NOT operator processing

methodpublicemptyOperatorAction() : void

default (omitted) operator processing

methodpublicfinishExpression() : array

Finish 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(, ), // first literal of first conjuction array(, ), // second literal of first conjuction ... array(, ) ), // end of first conjuction array( array(, ), // first literal of second conjuction array(, ), // second literal of second conjuction ... array(, ) ), // end of second conjuction ... ) // end of structure

Returns
Type Description
array
Throws
Exception Description
\Zend_Search_Lucene_Exception
methodpublicgetState() : integer | string
inherited

Get FSM state.

Inherited from: \Zend_Search_Lucene_FSM::getState()
Returns
Type Description
integer | string $state|null
methodpublicliteralAction() : void

Literal processing

methodpublicnotOperatorAction() : void

NOT operator processing

methodpublicorOperatorAction() : void

OR operator processing Close current conjunction

methodpublicprocess(mixed $input) : void
inherited

Process an input

Inherited from: \Zend_Search_Lucene_FSM::process()
Parameters
Name Type Description
$input mixed
Throws
Exception Description
\Zend_Search_Exception
methodpublicprocessLiteral( $literal) : void

Process expression literal.

Parameters
Name Type Description
$literal
methodpublicprocessOperator(integer $operator) : void

Process next operator.

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

Parameters
Name Type Description
$operator integer
methodpublicreset() : void
inherited

Inherited from: \Zend_Search_Lucene_FSM::reset()
methodpublicsetState(integer | string $state) : void
inherited

Set FSM state.

Inherited from: \Zend_Search_Lucene_FSM::setState()

No any action is invoked

Parameters
Name Type Description
$state integer | string
Throws
Exception Description
\Zend_Search_Exception
Documentation was generated by phpDocumentor 2.0.0a8.