![]() |
LIMA
Libre Multilingual Analyzer — C++ API
|
␈rief a class for the definition of a complete recognizer More...
#include <linguisticProcessing/core/Automaton/recognizer.h>
Classes | |
| class | CompareTriggerRule |
| class | TriggerRule |
Public Member Functions | |
| Recognizer () | |
| Recognizer (const Recognizer &) | |
| virtual | ~Recognizer () |
| Recognizer & | operator= (const Recognizer &) |
| void | init (Common::XMLConfigurationFiles::GroupConfigurationStructure &unitConfiguration, Manager *manager) override |
| initialize with parameters from configuration file. | |
| uint64_t | numberOfRules () const |
| uint64_t | addRuleInStorage (Rule *rule) |
| add a rule in the storage zone | |
| uint64_t | addRule (TransitionUnit *trigger, Rule *rule) |
| add a rule in the recognizer : add the rule in the storage zone, and associate the trigger to the rule find if the trigger already exists in the trigger list : if it is the case, add the rule in rules associated to this trigger, else add a new trigger (copy of the one in argument) and associate the rule to it. | |
| void | addRule (TransitionUnit *trigger, const uint64_t index) |
| associate a known rule to a trigger (the rule is identified by its index in the storage zone) | |
| uint64_t | apply (const LinguisticAnalysisStructure::AnalysisGraph &graph, const LinguisticGraphVertex &begin, const LinguisticGraphVertex &end, AnalysisContent &analysis, std::vector< RecognizerMatch > &result, bool testAllVertices=false, bool stopAtFirstSuccess=true, bool onlyOneSuccessPerType=false, bool returnAtFirstSuccess=false, bool applySameRuleWhileSuccess=false) const |
| apply the recognizer on a graph | |
| uint64_t | apply (const LinguisticAnalysisStructure::AnalysisGraph &graph, const LinguisticGraphVertex &begin, const LinguisticGraphVertex &end, const LinguisticGraphVertex &upstreamBound, const LinguisticGraphVertex &downstreamBound, AnalysisContent &analysis, std::vector< RecognizerMatch > &result, bool testAllVertices, bool stopAtFirstSuccess, bool onlyOneSuccessPerType, bool returnAtFirstSuccess, bool applySameRuleWhileSuccess) const |
| apply the recognizer on a graph between two nodes and search between two others. | |
| uint64_t | testOnVertex (const LinguisticAnalysisStructure::AnalysisGraph &graph, LinguisticGraphVertex ¤t, const LinguisticGraphVertex &begin, const LinguisticGraphVertex &end, AnalysisContent &analysis, std::vector< RecognizerMatch > &result, bool stopAtFirstSuccess=true, bool onlyOneSuccessPerType=false, bool applySameRuleWhileSuccess=false) const |
| test the recognizer on a given vertex : check if this vertex is a trigger and if a rule applies, add the result to the vector given as parameter (takes the first rule which gives a match) | |
| uint64_t | resolveOverlappingEntities (std::vector< RecognizerMatch > &listEntities, const OverlapResolutionStrategy &strategy=DEFAULT_OVERLAP_STRATEGY) const |
| resolve the problem of overlapping entities in the list of entities : when two entities are overlaping, only one is kept | |
| uint64_t | testSetOfRules (const TransitionUnit &trigger, const SetOfRules &rules, const LinguisticAnalysisStructure::AnalysisGraph &graph, const LinguisticGraphVertex &position, const LinguisticGraphVertex &begin, const LinguisticGraphVertex &end, AnalysisContent &analysis, std::vector< RecognizerMatch > &match, std::set< Common::MediaticData::EntityType > *forbiddenTypes=0, bool stopAtFirstSuccess=true, bool onlyOneSuccessPerType=false, bool applySameRuleWhileSuccess=false) const |
| TODO: toBeDeleted Parse tokens paths from the trigger point. | |
| void | listTriggers () const |
| void | initializeSearchStructure () |
Public Member Functions inherited from Lima::LinguisticProcessing::AbstractResource | |
| AbstractResource (QObject *parent=0) | |
| virtual | ~AbstractResource () |
| AbstractResource (const AbstractResource &) | |
Public Member Functions inherited from Lima::LinguisticProcessing::AbstractResourceBase | |
| AbstractResourceBase (QObject *parent=0) | |
| virtual | ~AbstractResourceBase () |
| AbstractResourceBase (const AbstractResourceBase &) | |
| QString | getResourceFileName (const QString ¶mName) |
Public Member Functions inherited from Lima::InitializableObject< AbstractResource, ResourceInitializationParameters > | |
| InitializableObject () | |
| InitializableObject (const InitializableObject &object) | |
| InitializableObject & | operator= (const InitializableObject &object) |
| virtual | ~InitializableObject () |
| const std::string & | getId () const |
| get the object id | |
| void | setId (const std::string &id) |
| set the object id | |
Protected Member Functions | |
| void | clearSearchStructure () |
| void | findNextSetOfRules (const LinguisticAnalysisStructure::AnalysisGraph &graph, LinguisticGraphVertex &vertex, AnalysisContent &analysis, const LinguisticAnalysisStructure::Token *token, const LinguisticAnalysisStructure::MorphoSyntacticData *data, std::vector< TriggerRule * > &matchingSetOfRules) const |
| void | init () |
| void | copy (const Recognizer &a) |
| void | freeMem () |
| void | setNormalizedForm (const LimaString &norm, RecognizerMatch &match) const |
| uint64_t | findRuleIndex (Rule *) const |
Protected Member Functions inherited from Lima::LinguisticProcessing::AbstractResourceBase | |
| LimaFileSystemWatcher & | resourceFileWatcher () |
| Accessor to the file watcher used to register resource files to be watched for changes. | |
Protected Attributes | |
| std::vector< TriggerRule > | m_rules |
| SetOfRules | m_ruleStorage |
| MediaId | m_language |
| AutomatonControlParams | m_automatonControlParams |
| parameters to control the search of the automaton | |
| std::string | m_filename |
| TransitionSearchStructure< TriggerRule > | m_searchStructure |
Protected Attributes inherited from Lima::LinguisticProcessing::AbstractResourceBase | |
| AbstractResourceBasePrivate * | m_d |
Protected Attributes inherited from Lima::InitializableObject< AbstractResource, ResourceInitializationParameters > | |
| std::string | m_id |
Friends | |
| class | AutomatonReader |
| class | AutomatonWriter |
| LIMA_AUTOMATON_EXPORT std::ostream & | operator<< (std::ostream &, const Recognizer &) |
Additional Inherited Members | |
Public Types inherited from Lima::InitializableObject< AbstractResource, ResourceInitializationParameters > | |
| typedef InitializableObjectManager< AbstractResource, ResourceInitializationParameters > | Manager |
| Manager is the type of the Manager associated to the initializableObject. | |
| typedef InitializableObjectFactory< AbstractResource > | Factory |
| Factory is the type of the Factory associated to the initializableObject. | |
Signals inherited from Lima::LinguisticProcessing::AbstractResourceBase | |
| void | resourceFileChanged (const QString &path) |
| Signal triggered whenever one of the registered files changes on disk. | |
␈rief a class for the definition of a complete recognizer
this class is used for the description of a complete recognizer, i.e. a set of rules
Definition at line 77 of file recognizer.h.
| Lima::LinguisticProcessing::Automaton::Recognizer::Recognizer | ( | ) |
Definition at line 71 of file recognizer.cpp.
| Lima::LinguisticProcessing::Automaton::Recognizer::Recognizer | ( | const Recognizer & | r | ) |
Definition at line 82 of file recognizer.cpp.
|
virtual |
Definition at line 99 of file recognizer.cpp.
| void Lima::LinguisticProcessing::Automaton::Recognizer::addRule | ( | TransitionUnit * | trigger, |
| const uint64_t | index | ||
| ) |
associate a known rule to a trigger (the rule is identified by its index in the storage zone)
| trigger | the trigger |
| index | the index of the rule in the storage zone |
Definition at line 1062 of file recognizer.cpp.
| uint64_t Lima::LinguisticProcessing::Automaton::Recognizer::addRule | ( | TransitionUnit * | trigger, |
| Rule * | rule | ||
| ) |
add a rule in the recognizer : add the rule in the storage zone, and associate the trigger to the rule find if the trigger already exists in the trigger list : if it is the case, add the rule in rules associated to this trigger, else add a new trigger (copy of the one in argument) and associate the rule to it.
| trigger | the trigger of the rule |
| rule | the rule |
Definition at line 1043 of file recognizer.cpp.
| uint64_t Lima::LinguisticProcessing::Automaton::Recognizer::addRuleInStorage | ( | Rule * | rule | ) |
add a rule in the storage zone
| rule | the rule to add |
Definition at line 1035 of file recognizer.cpp.
| uint64_t Lima::LinguisticProcessing::Automaton::Recognizer::apply | ( | const LinguisticAnalysisStructure::AnalysisGraph & | graph, |
| const LinguisticGraphVertex & | begin, | ||
| const LinguisticGraphVertex & | end, | ||
| AnalysisContent & | analysis, | ||
| std::vector< RecognizerMatch > & | result, | ||
| bool | testAllVertices = false, |
||
| bool | stopAtFirstSuccess = true, |
||
| bool | onlyOneSuccessPerType = false, |
||
| bool | returnAtFirstSuccess = false, |
||
| bool | applySameRuleWhileSuccess = false |
||
| ) | const |
apply the recognizer on a graph
| graph | the graph |
| begin | the first node to test (is also limit of the left context) |
| end | the last node to test (is also limit of the right context) |
| analysis | the content of the analysis (may be modified) |
| result | the results |
| testAllVertices | if true, test all vertices, otherwise, skip recognized expressions |
| stopAtFirstSuccess | if true, stop testing rules on the current node after one rule succeeded |
| onlyOneSuccessPerType | if true, stop testing rules with same type as a previously successful rule (only used if stopAtFirstSuccess is false) |
| returnAtFirstSuccess | if true, abort the search as soon a rule is successful (if true, stopAtFirstSuccess will be set to true) |
| applySameRuleWhileSuccess | if true, when a rule succeeds, retry to apply it on same vertex until the rule does not apply (use with care: setting this argument to true may cause loops if* rules are not well written). Will not apply if stopAtFirstSuccess. |
Definition at line 615 of file recognizer.cpp.
| uint64_t Lima::LinguisticProcessing::Automaton::Recognizer::apply | ( | const LinguisticAnalysisStructure::AnalysisGraph & | graph, |
| const LinguisticGraphVertex & | begin, | ||
| const LinguisticGraphVertex & | end, | ||
| const LinguisticGraphVertex & | upstreamBound, | ||
| const LinguisticGraphVertex & | downstreamBound, | ||
| AnalysisContent & | analysis, | ||
| std::vector< RecognizerMatch > & | result, | ||
| bool | testAllVertices, | ||
| bool | stopAtFirstSuccess, | ||
| bool | onlyOneSuccessPerType, | ||
| bool | returnAtFirstSuccess, | ||
| bool | applySameRuleWhileSuccess | ||
| ) | const |
apply the recognizer on a graph between two nodes and search between two others.
precondition: [begin, end] included in [upstreamBound,downstreamBound]
| graph | the graph |
| begin | the first node to test (is not the limit of the left context) |
| end | the last node to test (is not the limit of the right context) |
| upstreamBound | the limit of the left context) |
| downstreamBound | the limit of the right context) |
| analysis | the content of the analysis (may be modified) |
| result | the results |
| testAllVertices | if true, test all vertices, otherwise, skip recognized expressions |
| stopAtFirstSuccess | if true, stop testing rules after one rule succeeded |
| onlyOneSuccessPerType | if true, stop testing rules with same type as a previously successful rule (only used if stopAtFirstSuccess is false) |
| returnAtFirstSuccess | if true, abort the search as soon a rule is successful (if true, stopAtFirstSuccess will be set to true) |
| applySameRuleWhileSuccess | if true, when a rule succeeds, retry to apply it on same vertex until the rule does not apply (use with care: setting this argument to true may cause loops if* rules are not well written). Will not apply if stopAtFirstSuccess. |
Definition at line 643 of file recognizer.cpp.
|
protected |
Definition at line 1028 of file recognizer.cpp.
|
protected |
Definition at line 250 of file recognizer.cpp.
|
protected |
Definition at line 972 of file recognizer.cpp.
|
protected |
Definition at line 1086 of file recognizer.cpp.
|
protected |
Definition at line 276 of file recognizer.cpp.
|
protected |
Definition at line 242 of file recognizer.cpp.
|
overridevirtual |
initialize with parameters from configuration file.
| unitConfiguration | @IN : <group> tag in xml configuration file that contains parameters to initialize the object. |
| manager | @IN : manager that asked for initialization and carries parameters. |
| InvalidConfiguration | when parameters are invalids. |
Implements Lima::LinguisticProcessing::AbstractResource.
| void Lima::LinguisticProcessing::Automaton::Recognizer::initializeSearchStructure | ( | ) |
Definition at line 1018 of file recognizer.cpp.
| void Lima::LinguisticProcessing::Automaton::Recognizer::listTriggers | ( | ) | const |
Definition at line 1101 of file recognizer.cpp.
|
inline |
Definition at line 373 of file recognizer.h.
| Recognizer & Lima::LinguisticProcessing::Automaton::Recognizer::operator= | ( | const Recognizer & | r | ) |
Definition at line 108 of file recognizer.cpp.
| uint64_t Lima::LinguisticProcessing::Automaton::Recognizer::resolveOverlappingEntities | ( | std::vector< RecognizerMatch > & | listEntities, |
| const OverlapResolutionStrategy & | strategy = DEFAULT_OVERLAP_STRATEGY |
||
| ) | const |
resolve the problem of overlapping entities in the list of entities : when two entities are overlaping, only one is kept
| strategy | the strategy to use : IGNORE_FIRST will simply ignore the first entity IGNORE_SECOND will simply ignore the second entity IGNORE_SMALLEST will ignore the entity that covers the less words |
Definition at line 890 of file recognizer.cpp.
|
protected |
Definition at line 594 of file recognizer.cpp.
| uint64_t Lima::LinguisticProcessing::Automaton::Recognizer::testOnVertex | ( | const LinguisticAnalysisStructure::AnalysisGraph & | graph, |
| LinguisticGraphVertex & | current, | ||
| const LinguisticGraphVertex & | begin, | ||
| const LinguisticGraphVertex & | end, | ||
| AnalysisContent & | analysis, | ||
| std::vector< RecognizerMatch > & | result, | ||
| bool | stopAtFirstSuccess = true, |
||
| bool | onlyOneSuccessPerType = false, |
||
| bool | applySameRuleWhileSuccess = false |
||
| ) | const |
test the recognizer on a given vertex : check if this vertex is a trigger and if a rule applies, add the result to the vector given as parameter (takes the first rule which gives a match)
| graph | the graph |
| current | the current vertex to test |
| begin | the limit on the left of the current vertex |
| end | the limit on the right of the current vertex |
| result | the vector in which the result is stored |
Definition at line 814 of file recognizer.cpp.
| uint64_t Lima::LinguisticProcessing::Automaton::Recognizer::testSetOfRules | ( | const TransitionUnit & | trigger, |
| const SetOfRules & | rules, | ||
| const LinguisticAnalysisStructure::AnalysisGraph & | graph, | ||
| const LinguisticGraphVertex & | position, | ||
| const LinguisticGraphVertex & | begin, | ||
| const LinguisticGraphVertex & | end, | ||
| AnalysisContent & | analysis, | ||
| std::vector< RecognizerMatch > & | match, | ||
| std::set< Common::MediaticData::EntityType > * | forbiddenTypes = 0, |
||
| bool | stopAtFirstSuccess = true, |
||
| bool | onlyOneSuccessPerType = false, |
||
| bool | applySameRuleWhileSuccess = false |
||
| ) | const |
TODO: toBeDeleted Parse tokens paths from the trigger point.
| triggerToken | : the token that triggered the rules |
| graph | : the graph of the analysis |
| current | : the vertex in the graph corresponding to the trigger |
| offset | : the offset of the set of rules to test |
| results | : the output |
| trigger | the TransitionUnit corresponding to the trigger |
| rules | the set of rules to test |
| position | the position in the text from with to test |
| match | the resulting match (if success) |
| forbiddenTypes | if not 0, contains the types currently not permitted for the current trigger (in case of negative rules); updated when leaving the function |
| stopAtFirstSuccess | if true, stop testing rules after one rule succeeded |
| applySameRuleWhileSuccess | if true, when a rule succeeds, retry to apply it on same vertex until the rule does not apply (use with care: setting this argument to true may cause loops if* rules are not well written). Will not apply if stopAtFirstSuccess. |
Definition at line 325 of file recognizer.cpp.
|
friend |
Definition at line 81 of file recognizer.h.
|
friend |
Definition at line 82 of file recognizer.h.
|
friend |
Definition at line 1113 of file recognizer.cpp.
|
protected |
parameters to control the search of the automaton
Definition at line 337 of file recognizer.h.
|
protected |
Definition at line 340 of file recognizer.h.
|
protected |
Definition at line 334 of file recognizer.h.
|
protected |
Definition at line 330 of file recognizer.h.
|
protected |
Definition at line 331 of file recognizer.h.
|
protected |
Definition at line 344 of file recognizer.h.