strusAnalyzer  0.17
patternMatcherInstanceInterface.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 Patrick P. Frey
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7  */
10 #ifndef _STRUS_ANALYZER_PATTERN_MATCHER_INSTANCE_INTERFACE_HPP_INCLUDED
11 #define _STRUS_ANALYZER_PATTERN_MATCHER_INSTANCE_INTERFACE_HPP_INCLUDED
13 #include <string>
14 
15 namespace strus
16 {
17 
19 class PatternMatcherContextInterface;
20 
23 {
24 public:
27 
31  virtual void defineOption( const std::string& name, double value)=0;
32 
36  virtual void defineTermFrequency( unsigned int termid, double df)=0;
37 
40  virtual void pushTerm( unsigned int termid)=0;
41 
44  {
52  };
53  static const char* joinOperationName( JoinOperation op)
54  {
55  static const char* ar[] = {"sequence","sequence_imm","sequence_struct","within","within_struct","any","and",0};
56  return ar[ op];
57  }
58 
65  virtual void pushExpression(
66  JoinOperation operation,
67  std::size_t argc, unsigned int range, unsigned int cardinality)=0;
68 
71  virtual void pushPattern( const std::string& name)=0;
72 
76  virtual void attachVariable( const std::string& name)=0;
77 
85  virtual void definePattern( const std::string& name, const std::string& formatstring, bool visible)=0;
86 
90  virtual bool compile()=0;
91 
96 
99  virtual analyzer::FunctionView view() const=0;
100 };
101 
102 } //namespace
103 #endif
104 
105 
At least one of the argument patterns must appear for the completion of the rule. ...
Definition: patternMatcherInstanceInterface.hpp:50
JoinOperation
Join operations (similar meaning as in query evaluation)
Definition: patternMatcherInstanceInterface.hpp:43
Structure describing the internal representation of a normalizer/tokenizer/aggregator function in the...
Interface for building the automaton for detecting patterns in text.
Definition: patternMatcherInstanceInterface.hpp:22
virtual void defineTermFrequency(unsigned int termid, double df)=0
Define a relative document term frequency used for optimization of the automaton. ...
The argument patterns must appear in the specified (strict) order (ordinal span) within a specified p...
Definition: patternMatcherInstanceInterface.hpp:45
Structure describing the internal representation of a normalizer/tokenizer/aggregator function in the...
Definition: functionView.hpp:29
static const char * joinOperationName(JoinOperation op)
Definition: patternMatcherInstanceInterface.hpp:53
The argument patterns must appear within a specified proximity range of ordinal positions without ove...
Definition: patternMatcherInstanceInterface.hpp:48
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...
The argument patterns must appear within a specified proximity range of ordinal positions without ove...
Definition: patternMatcherInstanceInterface.hpp:49
virtual PatternMatcherContextInterface * createContext() const =0
Create the context to process a document with the pattern matcher.
All of the argument patterns must appear for the completion of the rule at the same ordinal position...
Definition: patternMatcherInstanceInterface.hpp:51
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 el...
The argument patterns must appear in the specified (strict) order (ordinal span) within a specified p...
Definition: patternMatcherInstanceInterface.hpp:47
virtual void defineOption(const std::string &name, double value)=0
Define an option value for the compilation.
Same as OpSequence, but does not allow any gap in between the elements.
Definition: patternMatcherInstanceInterface.hpp:46
virtual ~PatternMatcherInstanceInterface()
Destructor.
Definition: patternMatcherInstanceInterface.hpp:26
Interface for detecting patterns (structures formed by atomic tokens) in one document.
Definition: patternMatcherContextInterface.hpp:21
virtual analyzer::FunctionView view() const =0
Get the definition of the function as structure for introspection.
virtual void pushTerm(unsigned int termid)=0
Push a term on the stack.
virtual void pushPattern(const std::string &name)=0
Push a reference to a pattern on the stack.
virtual void attachVariable(const std::string &name)=0
Attaches a variable to the top expression or term on the stack.
virtual bool compile()=0
Compile all patterns defined.