strusAnalyzer  0.17
Public Types | Public Member Functions | Static Public Member Functions | List of all members
strus::PatternMatcherInstanceInterface Class Referenceabstract

Interface for building the automaton for detecting patterns in text. More...

#include <patternMatcherInstanceInterface.hpp>

Public Types

enum  JoinOperation {
  OpSequence, OpSequenceImm, OpSequenceStruct, OpWithin,
  OpWithinStruct, OpAny, OpAnd
}
 Join operations (similar meaning as in query evaluation) More...
 

Public Member Functions

virtual ~PatternMatcherInstanceInterface ()
 Destructor. More...
 
virtual void defineOption (const std::string &name, double value)=0
 Define an option value for the compilation. More...
 
virtual void defineTermFrequency (unsigned int termid, double df)=0
 Define a relative document term frequency used for optimization of the automaton. More...
 
virtual void pushTerm (unsigned int termid)=0
 Push a term on the stack. More...
 
virtual void pushExpression (JoinOperation operation, std::size_t argc, unsigned int range, unsigned int cardinality)=0
 Take the topmost elements from the stack, build an expression out of them and replace the argument elements with the created element on the stack. More...
 
virtual void pushPattern (const std::string &name)=0
 Push a reference to a pattern on the stack. More...
 
virtual void attachVariable (const std::string &name)=0
 Attaches a variable to the top expression or term on the stack. More...
 
virtual void definePattern (const std::string &name, const std::string &formatstring, bool visible)=0
 Create a pattern that can be referenced by the given name and can be declared as part of the result. More...
 
virtual bool compile ()=0
 Compile all patterns defined. More...
 
virtual
PatternMatcherContextInterface
createContext () const =0
 Create the context to process a document with the pattern matcher. More...
 
virtual analyzer::FunctionView view () const =0
 Get the definition of the function as structure for introspection. More...
 

Static Public Member Functions

static const char * joinOperationName (JoinOperation op)
 

Detailed Description

Interface for building the automaton for detecting patterns in text.

Member Enumeration Documentation

Join operations (similar meaning as in query evaluation)

Enumerator
OpSequence 

The argument patterns must appear in the specified (strict) order (ordinal span) within a specified proximity range of ordinal positions for the completion of the rule.

OpSequenceImm 

Same as OpSequence, but does not allow any gap in between the elements.

OpSequenceStruct 

The argument patterns must appear in the specified (strict) order (ordinal span) within a specified proximity range of ordinal positions for the completion of the rule without a structure element appearing before the last argument pattern needed for then completion of the rule.

OpWithin 

The argument patterns must appear within a specified proximity range of ordinal positions without overlapping ordinal spans for the completion of the rule.

OpWithinStruct 

The argument patterns must appear within a specified proximity range of ordinal positions without overlapping ordinal spans for the completion of the rule without a structure element appearing before the last element for then completion of the rule.

OpAny 

At least one of the argument patterns must appear for the completion of the rule.

OpAnd 

All of the argument patterns must appear for the completion of the rule at the same ordinal position.

Constructor & Destructor Documentation

virtual strus::PatternMatcherInstanceInterface::~PatternMatcherInstanceInterface ( )
inlinevirtual

Destructor.

Member Function Documentation

virtual void strus::PatternMatcherInstanceInterface::attachVariable ( const std::string &  name)
pure virtual

Attaches a variable to the top expression or term on the stack.

Parameters
[in]namename of the variable attached
Remarks
The stack is not changed
virtual bool strus::PatternMatcherInstanceInterface::compile ( )
pure virtual

Compile all patterns defined.

Parameters
[in]optoptimization options
Note
Tries to optimize the program if possible by setting initial key events of the programs to events that are relative rare
virtual PatternMatcherContextInterface* strus::PatternMatcherInstanceInterface::createContext ( ) const
pure virtual

Create the context to process a document with the pattern matcher.

Returns
the pattern matcher context
Remarks
The context cannot be reset. So the context has to be recreated for every processed unit (document)
virtual void strus::PatternMatcherInstanceInterface::defineOption ( const std::string &  name,
double  value 
)
pure virtual

Define an option value for the compilation.

Parameters
[in]nameoption name
[in]valueoption value
virtual void strus::PatternMatcherInstanceInterface::definePattern ( const std::string &  name,
const std::string &  formatstring,
bool  visible 
)
pure virtual

Create a pattern that can be referenced by the given name and can be declared as part of the result.

Parameters
[in]namename of the pattern and the result if declared as visible
[in]formatstringformat string for the value associated with the pattern (empty if undefined). The formatstring contains variable references to pattern parts in curly brackets '{' '}'. A variable reference is an identifier optionally followed by an or '|' and a separator value used for separate multiple occurrencies of the referenced variable.
[in]visibletrue, if the pattern result should be exported (be visible in the final result)
virtual void strus::PatternMatcherInstanceInterface::defineTermFrequency ( unsigned int  termid,
double  df 
)
pure virtual

Define a relative document term frequency used for optimization of the automaton.

Parameters
[in]termidterm identifier
[in]dfdocument frequency (only compared relatively, value between 0 and a virtual collection size)
static const char* strus::PatternMatcherInstanceInterface::joinOperationName ( JoinOperation  op)
inlinestatic
virtual void strus::PatternMatcherInstanceInterface::pushExpression ( JoinOperation  operation,
std::size_t  argc,
unsigned int  range,
unsigned int  cardinality 
)
pure virtual

Take the topmost elements from the stack, build an expression out of them and replace the argument elements with the created element on the stack.

Parameters
[in]operationidentifier of the operation to perform as string
[in]argcnumber of arguments of this operation
[in]rangeposition proximity range of the expression
[in]cardinalityspecifies a result dimension requirement (e.g. minimum number of elements of any input subset selection that builds a result) (0 for use default). Interpretation depends on operation, but in most cases it specifies the required size for a valid result.
Note
The operation identifiers should if possible correspond to the names used for the standard posting join operators in the query evaluation of the strus core.
virtual void strus::PatternMatcherInstanceInterface::pushPattern ( const std::string &  name)
pure virtual

Push a reference to a pattern on the stack.

Parameters
[in]namename of the referenced pattern
virtual void strus::PatternMatcherInstanceInterface::pushTerm ( unsigned int  termid)
pure virtual

Push a term on the stack.

Parameters
[in]termidterm identifier
virtual analyzer::FunctionView strus::PatternMatcherInstanceInterface::view ( ) const
pure virtual

Get the definition of the function as structure for introspection.

Returns
structure for introspection

The documentation for this class was generated from the following file: