Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

RGF.h

Go to the documentation of this file.
00001 
00002 //
00003 //    FreeLing - Open Source Language Analyzers
00004 //
00005 //    Copyright (C) 2004   TALP Research Center
00006 //                         Universitat Politecnica de Catalunya
00007 //
00008 //    This library is free software; you can redistribute it and/or
00009 //    modify it under the terms of the GNU Lesser General Public
00010 //    License as published by the Free Software Foundation; either
00011 //    version 2.1 of the License, or (at your option) any later version.
00012 //
00013 //    This library is distributed in the hope that it will be useful,
00014 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016 //    Lesser General Public License for more details.
00017 //
00018 //    You should have received a copy of the GNU Lesser General Public
00019 //    License along with this library; if not, write to the Free Software
00020 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00021 //
00022 //    contact: Lluis Padro (padro@lsi.upc.es)
00023 //             TALP Research Center
00024 //             despatx C6.212 - Campus Nord UPC
00025 //             08034 Barcelona.  SPAIN
00026 //
00028 
00029 //===========================================================
00030 //=                                                         =
00031 //=   This module is based on FEX project developed         =
00032 //=   at U.Illinois, and distributed under LGPL             =
00033 //=   with the permission of its authors                    =
00034 //=                                                         =
00035 //=   For info about original version, visit                =
00036 //=      http://l2r.cs.uiuc.edu/~cogcomp/                   =
00037 //=   or contact                                            =
00038 //=      University of Illinois at Urbana/Champaign         =
00039 //=      Department of Computer Science                     =
00040 //=      Dr. Dan Roth - Cognitive Computation Group         =
00041 //=                                                         =
00042 //===========================================================
00043 
00044 #ifndef _RGF
00045 #define _RGF
00046 
00047 #include <string>
00048 #include <vector>
00049 #include <set>
00050 #include "language.h"
00051 #include "sensor.h"
00052 
00053 using namespace std;
00054 
00055 struct RGF;
00056 
00057 typedef enum {EXTRACT_LABEL, EXTRACT_CONJ, EXTRACT_DISJ, EXTRACT_COLOC,
00058                 EXTRACT_SCOLOC, EXTRACT_LINK, EXTRACT_SENSOR, 
00059                 EXTRACT_NOT, EXTRACT_CONJUNCT } ExtractMode;
00060 
00061 typedef enum {TARGET_NULL = -2, TARGET_ALL = -1} TargetConstants;
00062 const int RANGE_ALL = 1000000;
00063 
00064 typedef vector<RGF> SubRGF;
00065 
00066 struct RGF
00067 {
00068 public:
00069    // default constructor
00070    RGF();
00071    RGF(char* sensorName, char* p1, char* p2, char* p3, char* dpath);
00072 
00073    // constructor for sensors
00074    RGF(char* sensorName);
00075 
00076    // constructor for complex relations
00077    RGF( SubRGF& subR );
00078 
00079    // destructor for RGF
00080    ~RGF();
00081 
00082         // These are bogus prototypes (no implementation exists) because the
00083         // Visual C++ 5.0 STL implelmentation is broken.
00084         bool                  operator==( const RGF& rhs ) const;
00085         bool                  operator<=( const RGF& rhs ) const;
00086         bool                  operator<( const RGF& rhs ) const;
00087         bool                  operator>( const RGF& rhs ) const;
00088         bool                  operator>=( const RGF& rhs ) const;
00089 
00090    set<string>  Extract( const sentence& sent, int targIndex );
00091    // New Extract used for phrase case
00092    // Added by Scott Yih, 09/25/01
00093    set<string>  Extract( const sentence& sent, int targIndex, int targLength );
00094    // Another new Extract; used for ER:Relation case
00095    // Added by Scott Yih, 01/09/02
00096   //   set<string>  ExtractRelation ( sentence& sent, RelationInSentence& relSent, int posArg1, int posArg2 );
00097 
00098    int            TargetIndex() { return targetIndex; }
00099    void           Target(char* targ);                     // set target
00100    const char*    Target() const { return target; }       // return target
00101    void           IncludeLocation(bool val);
00102    void           LocationOffset(int val);
00103    int            LocationOffset() const { return locationOffset; }
00104    void           LeftOffset(int val) { leftOffset = val; }
00105    int            LeftOffset() const { return leftOffset; }
00106    void           RightOffset(int val);
00107    int            RightOffset() const { return rightOffset; }
00108    void           IncludeTarget(bool val);
00109    bool           IncludeTarget() const { return includeTarget; }
00110    void           IncludeMark(bool val);
00111    bool           IncludeMark() const { return includeMark; }
00112    void           Mode(ExtractMode mode);
00113    ExtractMode    Mode()                 { return extractMode; }
00114    void           Mask(char* val) { mask = val; }
00115    char*          Mask() { return mask; }
00116    void           Param(char* val);
00117    const char*    Param() {return optParam;}
00118    void           GenFeature(bool val) { genFeature = val; }
00119    void           Insert(RGF rel) { subRGFs.push_back(rel); }
00120 
00121    // Show internal state of RGF
00122         void                  Show();
00123 
00124 protected:
00125   SubRGF             subRGFs;
00126   char*              optParam;
00127   bool               includeTarget;
00128   bool includeMark;
00129   int                     targetIndex;
00130   int                     leftOffset;
00131   int                     rightOffset;
00132   int                     locationOffset;
00133   ExtractMode          extractMode;
00134   char*                        target;
00135   char*              mask;
00136   bool               genFeature;
00137   Sensor             *pSensor;
00138 
00139   // Feature extraction functions
00140   set<string> Process( const sentence& sent,
00141                          int rec,
00142                          int targIndex,
00143                          int start,
00144                          int end);
00145 
00146 };
00147 
00148 #endif
00149 

Generated on Wed Apr 26 12:55:30 2006 for FreeLing by  doxygen 1.4.4