From: Kazuaki M. <ma...@un...> - 2002-04-26 15:22:43
|
Hello Margit, Thank you very much for trying out the AG toolkit. Assuming that you have python, I've written a simple example of using the AG library from python. The following python code uses the most basic functions in the AG library. For the explanations of all available functions in the API, please refer to the IDL API specification of the AG library: http://www.ldc.upenn.edu/AG/doc/idl/ag-1.0.idl. Also, there are some more examples (in C++, but the same things can be done in python) in the demo subdirectory of the aglib distribution. Regards, -Kazuaki Maeda # import the ag module import ag # create an AGSet, a timeline and an AG AGSetId = ag.CreateAGSet("sample") timelineId = ag.CreateTimeline(AGSetId) AGId = ag.CreateAG(AGSetId, timelineId) # create three anchors anchor1 = ag.CreateAnchor(AGId) anchor2 = ag.CreateAnchor(AGId) anchor3 = ag.CreateAnchor(AGId) # create three annotations annotation1 = ag.CreateAnnotation(AGId, anchor1, anchor2, "word") annotation2 = ag.CreateAnnotation(AGId, anchor2, anchor3, "word") annotation3 = ag.CreateAnnotation(AGId, anchor2, anchor3, "misc") # set offsets of some of the anchors ag.SetStartOffset(annotation1, 1.00) ag.SetEndOffset(annotation1, 2.00) # set features to an annotation ag.SetFeature(annotation1, "English", "cat") ag.SetFeature(annotation1, "Japanese", "neko") # examples of accessing & printing information in an AG print "The features associated with annotation1 are:", print ag.GetFeatureNames(annotation1) print print "The ID of the start anchor of annotation1 is:", print ag.GetStartAnchor(annotation1) print print "The IDs of annotations starting with the end anchor of annotation1 are:" print ag.GetOutgoingAnnotationSet(ag.GetEndAnchor(annotation1)) print print "An AIF file for the annotation graph above is:" print ag.toXML(AGId) From: "Gut, Margit" <gu...@so...> Subject: [agtk-devel] new on the list, I have a question Date: Fri, 26 Apr 2002 14:04:21 +0200 > Hi, all > I am a student of computerlinguistics in Stuttgart Germany. Some days ago I > met Annotation graph the first time. I try to learn python and I wish to ust > annotation Graph. So can you tell me a very simple example how to use > Annotation Graph? I tried to read the sources of tabletrans but it is too > hard for a beginner. > I would be very happy, if there exists a more simple example just to > understand how Annotation Graph works > many thanks to everyone > margit > > > _______________________________________________ > agtk-devel mailing list > agt...@li... > https://lists.sourceforge.net/lists/listinfo/agtk-devel > |