|
FreeLing
3.0
|
Abstract class to implement a Finite-State Automaton which is used by modules recognizing multiwords (dates, numbers, quantities, ...). More...
#include <automat.h>


Public Member Functions | |
| automat () | |
| Constructor. | |
| virtual | ~automat () |
| Destructor. | |
| bool | matching (sentence &, sentence::iterator &) |
| Detect patterns starting at a specific word. | |
| void | analyze (sentence &) |
| Detect patterns in sentence. | |
| void | analyze (std::list< sentence > &) |
| Detect patterns in sentences. | |
| sentence | analyze (const sentence &) |
| analyze sentence, return analyzed copy | |
| std::list< sentence > | analyze (const std::list< sentence > &) |
| analyze sentences, return analyzed copy | |
Protected Attributes | |
| int | initialState |
| state code of initial state | |
| int | stopState |
| state code for stop State | |
| int | trans [MAX_STATES][MAX_TOKENS] |
| Transition tables. | |
| std::set< int > | Final |
| set of final states | |
| int | shiftbegin |
Private Member Functions | |
| virtual int | ComputeToken (int, sentence::iterator &, sentence &)=0 |
| pure virtual function to be provided by the child class. | |
| virtual void | ResetActions ()=0 |
| pure virtual function to be provided by the child class . | |
| virtual void | StateActions (int, int, int, sentence::const_iterator)=0 |
| pure virtual function to be provided by the child class. | |
| virtual void | SetMultiwordAnalysis (sentence::iterator, int)=0 |
| pure virtual function to be provided by the child class. | |
| virtual bool | ValidMultiWord (const word &) |
| virtual function (true by default). | |
| virtual sentence::iterator | BuildMultiword (sentence &, sentence::iterator, sentence::iterator, int, bool &) |
| Private function to re-arrange sentence when match found. | |
Abstract class to implement a Finite-State Automaton which is used by modules recognizing multiwords (dates, numbers, quantities, ...).
Details:
Child classes must provide a constructor that:
Child classes must provide the virtual functions:
Child classes must declare and manage any private attribute or function they may need to perform the expected computations
| automat::automat | ( | ) |
Constructor.
Create an instance of the class, initializing options member.
Since automat is an abstract class, this is called always from child constructors.
| virtual automat::~automat | ( | ) | [inline, virtual] |
Destructor.
| void automat::analyze | ( | sentence & | se | ) | [virtual] |
Detect patterns in sentence.
Check each word in sentece as a possible pattern start.
Recognize the longest pattern starting at first possible start found. Repeat the process starting from first word after recognized pattern, until sentence ends.
Implements processor.
Reimplemented in bioner.
References sentence::rebuild_word_index(), TRACE, and TRACE_SENTENCE.
Referenced by maco::analyze().
| void automat::analyze | ( | std::list< sentence > & | ) |
| sentence automat::analyze | ( | const sentence & | s | ) |
analyze sentence, return analyzed copy
Check for patterns in given sentence.
Return copy
Reimplemented from processor.
Reimplemented in bioner.
References processor::analyze().
| std::list<sentence> automat::analyze | ( | const std::list< sentence > & | ) |
| sentence::iterator automat::BuildMultiword | ( | sentence & | se, |
| sentence::iterator | start, | ||
| sentence::iterator | end, | ||
| int | fs, | ||
| bool & | built | ||
| ) | [private, virtual] |
Private function to re-arrange sentence when match found.
Arrange the sentence grouping all words from start to end in a multiword.
Reimplemented in ner_module.
References TRACE.
| virtual int automat::ComputeToken | ( | int | , |
| sentence::iterator & | , | ||
| sentence & | |||
| ) | [private, pure virtual] |
pure virtual function to be provided by the child class.
Computes token code for current word in current state.
Implemented in dates_ru, dates_en, numbers_ru, dates_pt, numbers_en, dates_gl, quantities_ru, numbers_it, dates_ca, quantities_en, numbers_pt, dates_es, quantities_pt, numbers_gl, dates_default, quantities_gl, numbers_ca, quantities_ca, numbers_es, quantities_es, numbers_default, quantities_default, np, ner_module, and locutions.
| bool automat::matching | ( | sentence & | se, |
| sentence::iterator & | i | ||
| ) |
Detect patterns starting at a specific word.
Check given word in sentece as a possible pattern start.
Recognize the longest pattern.
References TRACE, and TRACE_SENTENCE.
| virtual void automat::ResetActions | ( | ) | [private, pure virtual] |
pure virtual function to be provided by the child class .
Resets automaton internal variables when a new search is started.
Implemented in numbers_it, dates_module, numbers_module, np, ner_module, locutions, and quantities_module.
| virtual void automat::SetMultiwordAnalysis | ( | sentence::iterator | , |
| int | |||
| ) | [private, pure virtual] |
pure virtual function to be provided by the child class.
Sets analysis for pattern identified as a multiword.
Implemented in dates_ru, dates_en, numbers_ru, dates_pt, numbers_en, dates_gl, numbers_it, dates_ca, numbers_pt, dates_es, numbers_gl, dates_default, numbers_ca, numbers_es, numbers_default, np, ner_module, locutions, and quantities_module.
| virtual void automat::StateActions | ( | int | , |
| int | , | ||
| int | , | ||
| sentence::const_iterator | |||
| ) | [private, pure virtual] |
pure virtual function to be provided by the child class.
Performs appropriate internal actions, given origin and destinanation states, token code and word.
Implemented in dates_ru, dates_en, numbers_ru, dates_pt, numbers_en, dates_gl, quantities_ru, numbers_it, dates_ca, quantities_en, numbers_pt, dates_es, quantities_pt, numbers_gl, dates_default, quantities_gl, numbers_ca, quantities_ca, numbers_es, quantities_es, numbers_default, quantities_default, np, ner_module, and locutions.
| bool automat::ValidMultiWord | ( | const word & | w | ) | [private, virtual] |
virtual function (true by default).
Perform last minute validation before effectively building multiword.
Allows the child class to perform a last-minute check before effectively building the multiword.
Child classes can redefine this function to perform desired checks.
Reimplemented in ner_module, and locutions.
std::set<int> automat::Final [protected] |
set of final states
Referenced by locutions::locutions(), and np::np().
int automat::initialState [protected] |
state code of initial state
Referenced by locutions::locutions(), and np::np().
int automat::shiftbegin [protected] |
int automat::stopState [protected] |
state code for stop State
Referenced by locutions::locutions(), and np::np().
int automat::trans[MAX_STATES][MAX_TOKENS] [protected] |
Transition tables.
Referenced by locutions::locutions(), and np::np().
1.7.6.1