From: Matthias T. <th...@ei...> - 2003-05-07 12:22:26
|
Hello AGTK developers, in the new version of AGLIB, GetAnchorSet returns an unordered set of anchors, even if they are sortable through their offsets. Are there specific reasons preventing to return an ordered list? If not, I would appreciate if this could be changed, otherwise I would need to do the sorting outside AGLIB which would require some coding and runtime efforts. Regards. Matthias P.S. I am trying to do the changes myself, but missing the SWIG definition files... |
From: Haejoong L. <hae...@un...> - 2003-05-07 17:04:30
|
Hi Matthias, So you are looking for a function which returns a time-ordered anchor list? Then, you can use GetAnchorSetByOffset. By the way, I just found two problems with ...SetByOffset functions. (There are two ...SetByOffset functions: GetAnchorSetByOffset and GetAnnotationSetByOffset.) It would have been better if the name was ...ListByOffset. The real problem is that in C++ implementation they return set<...> instead of list<...>. This means what you get from these functions is actually a set of ids ordered by ids, not offsets! I've updated the CVS repository with the fixes; they return lists now. This change doesn't affects Python and Tcl interfaces. Thanks for making me realize those problems. Finally, the SWIG interface files are available from the CVS: $ cvs -d:pserver:ano...@cv...:/cvsroot/agtk login [return at the login prompt] $ cvs -d:pserver:ano...@cv...:/cvsroot/agtk co \ -r Toward-2_0 AGLIB/src/ag_wrapper Thanks, Haejoong Matthias Thomae wrote: > Hello AGTK developers, > > in the new version of AGLIB, GetAnchorSet returns an unordered set of > anchors, even if they are sortable through their offsets. > > Are there specific reasons preventing to return an ordered list? > > If not, I would appreciate if this could be changed, otherwise I would > need to do the sorting outside AGLIB which would require some coding > and runtime efforts. > > Regards. > Matthias > > P.S. I am trying to do the changes myself, but missing the SWIG > definition files... > > > > ------------------------------------------------------- > Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara > The only event dedicated to issues related to Linux enterprise solutions > www.enterpriselinuxforum.com > > _______________________________________________ > agtk-devel mailing list > agt...@li... > https://lists.sourceforge.net/lists/listinfo/agtk-devel > > |
From: Matthias T. <th...@ei...> - 2003-05-08 09:16:45
|
Hello Haejoong, I am a little confused :) Haejoong Lee wrote: > So you are looking for a function which returns a time-ordered anchor > list? Then, you can use GetAnchorSetByOffset. Well, but only if I set the epsilon parameter to infinity? ;) set<AnchorId> GetAnchorSetByOffset(AGId agId,Offset offset, double epsilon=0.0) I thought this function was to get the anchors at a certain offset and with epsilon distance around this offset, but not all anchors? However, in the implementation of GetAnchorSet in AGAPI.cc: set<AnchorId> GetAnchorSet(AGId agId) { try { AnchorSeq* aidset = Identifiers::getAGRef(agId)->getAnchorSet(); set<AnchorId> aids; for (AnchorSeq::iterator pos = aidset->begin(); pos != aidset->end(); ++pos) aids.insert((*pos)->getId()); return aids; } catch (AGException e) { logError("GetAnchorSet",e); } } the anchors are collected from getAnchorSet() in AG.h: /// Get the set of anchors, sorted by offsets. AnchorSeq* getAnchorSet() { return &I.anchorSet; } So this anchor *sequence* is already sorted by offsets and by ids iff offsets are the same, as seen in Anchor.h /** * Anchor compare function. * A function to compare anchors by first comparing their offsets, * then their ids if the offsets are the same. **/ class AnchorCompFunc { public: bool operator() (const Anchor* a1, const Anchor* a2) const { return *a1 < *a2; } }; /** * Anchor Seqquence. * a set of anchors sorted by AnchorCompFunc, i.e. offsets **/ typedef set<Anchor*,AnchorCompFunc> AnchorSeq; So everything is already there, only the API function in AGAPI.cc should return list<AnchorId> instead of set<AnchorId> > By the way, I just found two problems with ...SetByOffset functions. > (There are two ...SetByOffset functions: GetAnchorSetByOffset and > GetAnnotationSetByOffset.) It would have been better if the name was > ...ListByOffset. The real problem is that in C++ implementation they For GetAnnotationSet this is already there: set<AnnotationId> GetAnnotationSetByOffset(AGId agId,Offset offset, const AnnotationType& type=""); list<AnnotationId> GetAnnotationSeqByOffset(AGId agId, Offset begin=0.0, Offset end=0.0, const AnnotationType& type=""); So if you introduce a complementary ..Seq.. function for Anchors, I would also be happy. Still I think that GetAnchorSet should return a list (and maybe be renamed to GetAnchorSeq). > return set<...> instead of list<...>. This means what you get from > these functions is actually a set of ids ordered by ids, not offsets! Yes, that's exactly my problem ;) > I've updated the CVS repository with the fixes; they return lists now. I just checked out the Toward-2_0 branch, and cannot find the changes. In fact, I copied the above code from the sources just checked out. > This change doesn't affects Python and Tcl interfaces. Thanks for > making me realize those problems. You're welcome :) > Finally, the SWIG interface files are available from the CVS: > > $ cvs -d:pserver:ano...@cv...:/cvsroot/agtk login > [return at the login prompt] > $ cvs -d:pserver:ano...@cv...:/cvsroot/agtk co \ > -r Toward-2_0 AGLIB/src/ag_wrapper Thank you, I didn't realize that you made a branch and was already wondering if you stopped updating the CVS ;) Regards. Matthias P.S. By the way, I have submitted two "Bug reports". |
From: Haejoong L. <hae...@un...> - 2003-05-08 14:51:54
|
Matthias, Sorry for the confusion. I forgot the semantics of GetAnchorSetByOffset function in the previous post. Yes you are right -- there is no reason to prevent GetAnchorSet to return a time-ordered anchor list. GetAnchorSet now returns a list. Fixes are in the CVS. (I swear this time :-) Thanks, Haejoong Matthias Thomae wrote: > Hello Haejoong, > > I am a little confused :) > > Haejoong Lee wrote: > >> So you are looking for a function which returns a time-ordered anchor >> list? Then, you can use GetAnchorSetByOffset. > > > Well, but only if I set the epsilon parameter to infinity? ;) > > set<AnchorId> GetAnchorSetByOffset(AGId agId,Offset offset, double > epsilon=0.0) > > I thought this function was to get the anchors at a certain offset and > with epsilon distance around this offset, but not all anchors? > > > > However, in the implementation of GetAnchorSet in AGAPI.cc: > > set<AnchorId> > GetAnchorSet(AGId agId) > { > try { > AnchorSeq* aidset = Identifiers::getAGRef(agId)->getAnchorSet(); > set<AnchorId> aids; > > for (AnchorSeq::iterator pos = aidset->begin(); pos != > aidset->end(); ++pos) > aids.insert((*pos)->getId()); > return aids; > > } catch (AGException e) { > logError("GetAnchorSet",e); > } > } > > the anchors are collected from getAnchorSet() in AG.h: > > /// Get the set of anchors, sorted by offsets. > AnchorSeq* getAnchorSet() { return &I.anchorSet; } > > So this anchor *sequence* is already sorted by offsets and by ids iff > offsets are the same, as seen in Anchor.h > > /** > * Anchor compare function. > * A function to compare anchors by first comparing their offsets, > * then their ids if the offsets are the same. > **/ > class AnchorCompFunc { > public: > bool operator() (const Anchor* a1, const Anchor* a2) const { > return *a1 < *a2; > } > }; > > /** > * Anchor Seqquence. > * a set of anchors sorted by AnchorCompFunc, i.e. offsets > **/ > typedef set<Anchor*,AnchorCompFunc> AnchorSeq; > > > So everything is already there, only the API function in AGAPI.cc > should return list<AnchorId> instead of set<AnchorId> > > >> By the way, I just found two problems with ...SetByOffset functions. >> (There are two ...SetByOffset functions: GetAnchorSetByOffset and >> GetAnnotationSetByOffset.) It would have been better if the name was >> ...ListByOffset. The real problem is that in C++ implementation they > > > For GetAnnotationSet this is already there: > > set<AnnotationId> GetAnnotationSetByOffset(AGId agId,Offset offset, > const AnnotationType& type=""); > list<AnnotationId> GetAnnotationSeqByOffset(AGId agId, Offset > begin=0.0, Offset end=0.0, const AnnotationType& type=""); > > So if you introduce a complementary ..Seq.. function for Anchors, I > would also be happy. Still I think that GetAnchorSet should return a > list (and maybe be renamed to GetAnchorSeq). > >> return set<...> instead of list<...>. This means what you get from >> these functions is actually a set of ids ordered by ids, not offsets! > > > Yes, that's exactly my problem ;) > >> I've updated the CVS repository with the fixes; they return lists now. > > > I just checked out the Toward-2_0 branch, and cannot find the changes. > In fact, I copied the above code from the sources just checked out. > >> This change doesn't affects Python and Tcl interfaces. Thanks for >> making me realize those problems. > > > You're welcome :) > >> Finally, the SWIG interface files are available from the CVS: >> >> $ cvs -d:pserver:ano...@cv...:/cvsroot/agtk login >> [return at the login prompt] >> $ cvs -d:pserver:ano...@cv...:/cvsroot/agtk co \ >> -r Toward-2_0 AGLIB/src/ag_wrapper > > > Thank you, I didn't realize that you made a branch and was already > wondering if you stopped updating the CVS ;) > > Regards. > Matthias > > > P.S. By the way, I have submitted two "Bug reports". > > > > ------------------------------------------------------- > Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara > The only event dedicated to issues related to Linux enterprise solutions > www.enterpriselinuxforum.com > > _______________________________________________ > agtk-devel mailing list > agt...@li... > https://lists.sourceforge.net/lists/listinfo/agtk-devel > > |
From: Matthias T. <th...@ei...> - 2003-05-08 15:09:51
|
Hi Haejoong, Haejoong Lee wrote: > Sorry for the confusion. I forgot the semantics of GetAnchorSetByOffset > function in the previous post. Yes you are right -- there is no reason > to prevent GetAnchorSet to return a time-ordered anchor list. > GetAnchorSet now returns a list. Fixes are in the CVS. (I swear this > time :-) :) no problem, that's what mailing lists are for ;) Thanks for the quick fix Matthias |
From: Steven B. <sb...@cs...> - 2003-05-09 01:46:47
|
On Fri, 2003-05-09 at 00:51, Haejoong Lee wrote: > Matthias, > > Sorry for the confusion. I forgot the semantics of GetAnchorSetByOffset > function in the previous post. Yes you are right -- there is no reason > to prevent GetAnchorSet to return a time-ordered anchor list. > GetAnchorSet now returns a list. Fixes are in the CVS. (I swear this > time :-) Where do any untimed anchors end up in this list? -Steven Bird |
From: Haejoong L. <hae...@un...> - 2003-05-09 00:38:12
|
Steven, >>Sorry for the confusion. I forgot the semantics of GetAnchorSetByOffset >>function in the previous post. Yes you are right -- there is no reason >>to prevent GetAnchorSet to return a time-ordered anchor list. >>GetAnchorSet now returns a list. Fixes are in the CVS. (I swear this >>time :-) >> >> > >Where do any untimed anchors end up in this list? > > Here's how anchors are ordered: ------------------- bool operator < (const Anchor& a, const Anchor& b) { if (a.anchored && b.anchored && a.offset != b.offset) return a.offset < b.offset; else if (a.anchored && b.anchored && a.offset == b.offset) return a.id < b.id; else if (a.anchored && !b.anchored) return true; else if (!a.anchored && b.anchored) return false; else return a.id < b.id; } ---------------------- Haejoong |
From: Matthias T. <th...@ei...> - 2003-05-12 07:04:08
|
Hello Haejoong, Haejoong Lee wrote: > GetAnchorSet now returns a list. Fixes are in the CVS. (I swear this > time :-) There seems to be a little problem now, as you added GetRef to the latest src/ag_wrapper/AGAPI.i, but the implementation in AGAPI.cc is missing. Therefor, trying to use the scripting wrappers (I tried both Tcl and Python) results in: % ./agtest.py /usr2/tho/annotation/scripts/test.xml Traceback (most recent call last): File "./agtest.py", line 6, in ? import ag ImportError: /usr/local/lib/ag/python/ag.so: undefined symbol: _Z6GetRefSs Regards. Matthias |
From: Haejoong L. <hae...@un...> - 2003-05-12 13:24:29
|
Matthias, > There seems to be a little problem now, as you added GetRef to the > latest src/ag_wrapper/AGAPI.i, but the implementation in AGAPI.cc is > missing. Therefor, trying to use the scripting wrappers (I tried both > Tcl and Python) results in: > > % ./agtest.py /usr2/tho/annotation/scripts/test.xml > Traceback (most recent call last): > File "./agtest.py", line 6, in ? > import ag > ImportError: /usr/local/lib/ag/python/ag.so: undefined symbol: > _Z6GetRefSs Sorry, I forgot to remove it. I've updated the CVS with fixes. Please update src/ag_wrapper directory of your copy. Thanks, Haejoong |