// file: $isip/class/asr/AnnotationIndex/AnnotationIndex.h // version: $Id: AnnotationIndex.h 8665 2002-09-01 18:42:02Z alphonso $ // // make sure definitions are only made once // #ifndef ISIP_ANNOTATION_INDEX #define ISIP_ANNOTATION_INDEX #ifndef ISIP_STRING #include #endif #ifndef ISIP_HASH_TABLE #include #endif #ifndef ISIP_HASH_KEY #include #endif #ifndef ISIP_DOUBLE_LINKED_LIST #include #endif #ifndef ISIP_ANNOTATION #include #endif #ifndef ISIP_ANCHOR #include #endif // AnnotationIndex: a class used for quick access to annotations and anchors // // 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 AnnotationIndex { //-------------------------------------------------------------------------- // // public constants // //-------------------------------------------------------------------------- public: // define the class name // static const String CLASS_NAME; // i/o related constants // static const String DEF_PARAM; //--------------------------------------------------------------------------- // // protected data // //--------------------------------------------------------------------------- protected: // define a list to store the set of anchors // DoubleLinkedList ancrset_d; // define the anchors indexed by identifiers // HashTable ancr_by_id_d; // define the anchor set indexed by the offset // HashTable > ancrset_by_offset_d; // define the annotations indexed by identifiers // HashTable anno_by_id_d; // define the annotations indexed by type // HashTable > anno_by_type_d; // define annotations indexed by the offset of start anchor // HashTable > start_by_offset_d; // define annotations indexed by the offset of end anchor // HashTable > end_by_offset_d; // define annotations indexed by their end anchor // HashTable, DoubleLinkedList > incoming_d; // define annotations indexed by their start anchor // HashTable, DoubleLinkedList > outgoing_d; // define annotations indexed by their feature // HashTable > by_feature_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 // ~AnnotationIndex(); // method: default constructor // AnnotationIndex(); // method: copy constructor // AnnotationIndex(const AnnotationIndex& arg) { assign(arg); } // method: assign // bool8 assign(const AnnotationIndex& arg); // method: sofSize // int32 sofSize() const { return 0; } // method: read // bool8 read(Sof& sof, int32 tag) { return read(sof, tag, name()); } // method: read // bool8 read(Sof& sof, int32 tag, const String& name) { return true; } // method: readData // bool8 readData(Sof& sof, const String& pname = DEF_PARAM, int32 size = SofParser::FULL_OBJECT, bool8 param = true, bool8 nested = false) { return true; } // method: write // bool8 write(Sof& sof, int32 tag) const { return write(sof, tag, name()); } // method: write // bool8 write(Sof& sof, int32 tag, const String& name) const { return true; } // method: writeData // bool8 writeData(Sof& sof, const String& pname = DEF_PARAM) const { return true; } // method: eq // bool8 eq(const AnnotationIndex& 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 to add an annotation to the indexes // bool8 add(Annotation* a); // method to delete an annotation from the indexes // bool8 deleteAnnotation(Annotation* anno); // method to check if the specified annotation exists // bool8 existsAnnotation(const String& id); // method to check if the specified anchor exists // bool8 existsAnchor(const String& id); // method to get the nearest used offset to the specified offset // float32 getNearestOffset(float32 offset); // method that gets the annotations that overlap a particular time offset. // gets all annotations whose start anchor offset is smaller than or // equal to the given offset AND end anchor offset is greater than // or equal to the given offet // bool8 getByOffset(float32 offset, DoubleLinkedList& list); // method get one of the annotations which overlap a particular time offset. // same as getByOffset except that getAnnotationByOffset returns only // one qualified annotation while getByOffset returns all of them // Annotation* getAnnotationByOffset(float32 offset); // method to add a feature to the indexes // bool8 addFeature(Annotation* anno, const String& feature, const String& value); // method to delete a feature from the indexes // bool8 deleteFeature(Annotation* anno, const String& feature); // method to check if the feature-value pait exists // bool8 existsFeature(const String& feature, const String& value); //--------------------------------------------------------------------------- // // private methods // //--------------------------------------------------------------------------- private: // friend class // friend class AnnotationGraph; // method to add an anchor to the indexes // bool8 addAnchor(Anchor* ancr); // method to delete an anchor from the indexes // bool8 deleteAnchor(Anchor*ancr); }; //end of include file // #endif