// file: $isip/class/mmedia/Annotation/Annotation.h // version: $Id: Annotation.h 8830 2002-11-24 16:43:55Z gao $ // // make sure definitions are only made once // #ifndef ISIP_ANNOTATION #define ISIP_ANNOTATION #ifndef ISIP_STRING #include #endif #ifndef ISIP_HASH_TABLE #include #endif #ifndef ISIP_ANCHOR #include #endif // Annotation: a class used to represent an annotation // // Reference: // // [1] S. Bird, M. Liberman, A Formal Framework for Linguistic Annotation, // Linguistic Data Consortium, University of Pennsylvania, Philadelphia, // Pennsylvania, USA, 2000. // // [2] K. Maeda, X. Ma, H. Lee, S. Bird, The Annotation Graph Toolkit: // Application Developer's Manual (Draft), Linguistic Data Consortium, // University of Pennsylvania, Philadelphia, Pennsylvania, USA, 2001. // class Annotation { //-------------------------------------------------------------------------- // // public constants // //-------------------------------------------------------------------------- public: // define the class name // static const String CLASS_NAME; // i/o related constants // static const String DEF_PARAM; static const String PARAM_ID; static const String PARAM_TYPE; static const String PARAM_START; static const String PARAM_END; static const String PARAM_FEATURES; static const String PARAM_CHANNEL_INDEX; // define default values // static const int32 DEF_CHANNEL_INDEX = 0; //--------------------------------------------------------------------------- // // protected data // //--------------------------------------------------------------------------- protected: // declare the annotation id // String id_d; // declare the annotation type // String type_d; // declare the start anchor // Anchor* start_d; // declare the end anchor // Anchor* end_d; // declare the channel index // Long channel_index_d; // declare the annotation feature map // HashTable feature_map_d; // declare a static debug level for all class instantiations // static Integral::DEBUG debug_level_d; // a static memory manager // static MemoryManager mgr_d; //--------------------------------------------------------------------------- // // required public methods // //--------------------------------------------------------------------------- public: // method: name // static const String& name() { return CLASS_NAME; } static bool8 diagnose(Integral::DEBUG debug_level); // debug methods // bool8 debug(const unichar* msg) const; // method: setDebug // static bool8 setDebug(Integral::DEBUG arg) { debug_level_d = arg; return true; } // method: destructor // ~Annotation(); // method: default constructor // Annotation(); // method: copy constructor // Annotation(const Annotation& arg) { assign(arg); } // method: assign // bool8 assign(const Annotation& arg); // method: sofSize // int32 sofSize() const; // method: read // bool8 read(Sof& sof, int32 tag) { return read(sof, tag, name()); } // other read methods // bool8 read(Sof& sof, int32 tag, const String& name); bool8 readData(Sof& sof, const String& pname = DEF_PARAM, int32 size = SofParser::FULL_OBJECT, bool8 param = true, bool8 nested = false); // method: write // bool8 write(Sof& sof, int32 tag) const { return write(sof, tag, name()); } // other write methods // bool8 write(Sof& sof, int32 tag, const String& name) const; bool8 writeData(Sof& sof, const String& pname = DEF_PARAM) const; // method: eq // bool8 eq(const Annotation& arg) const; // method: new // static void* operator new(size_t arg) { return mgr_d.get(); } // method: new[] // static void* operator new[](size_t arg) { return mgr_d.getBlock(arg); } // method: delete // static void operator delete(void* arg) { mgr_d.release(arg); } // method: delete[] // static void operator delete[](void* arg) { mgr_d.releaseBlock(arg); } // method: setGrowSize // static bool8 setGrowSize(int32 arg) { return mgr_d.setGrow(arg); } // method: clear // bool8 clear(Integral::CMODE cmode = Integral::DEF_CMODE); //--------------------------------------------------------------------------- // // class-specific public methods // //--------------------------------------------------------------------------- // method: constructor // Annotation(String& id, const Annotation* arg); // method: constructor // Annotation(String& id, Anchor* start, Anchor* end, String& type, int32 channel_index = DEF_CHANNEL_INDEX); /// method: getId // String getId() const { return id_d; } // method: setStartAnchor // bool8 setStartAnchor(Anchor* arg) { start_d = arg; return true; } // method: setEndAnchor // bool8 setEndAnchor(Anchor* arg) { end_d = arg; return true; } // method: setChannel // bool8 setChannel(int32 arg) { channel_index_d = arg; return true; } // method: getStartAnchor // Anchor* getStartAnchor() const { return start_d; } // method: getEndAnchor // Anchor* getEndAnchor() const { return end_d; } // method: getType // String getType() const { return type_d; } // method: getChannel // Long getChannel() const { return channel_index_d; } // method: getFeatureMap // HashTable& getFeatureMap() { return feature_map_d; } // method: setFeatureMap // bool8 setFeatureMap(HashTable& arg) { feature_map_d.assign(arg); return true; } // method: existsFeature // bool8 existsFeature(const String& feature) { return feature_map_d.containsKey(feature); } // method: deleteFeature // bool8 deleteFeature(const String& feature) { return feature_map_d.remove(feature); } // method: setFeature // bool8 setFeature(String& feature, String& value) { return feature_map_d.insert(feature, &value); } // method to get the specified feature of the annotation // String getFeature(const String& feature); // method to return a vector of all feature names // bool8 getFeatureNames(Vector& features); // method to set all the features to an empty string // bool8 unsetFeatures(); //--------------------------------------------------------------------------- // // private methods // //--------------------------------------------------------------------------- private: // method to compare // bool8 compare(const String& arg1, const String& arg2) const; // friend class // friend class AnnotationGraph; }; //end of include file // #endif