SEGMENTLIST(3SP)

NAME
ReadSegmentList, ReadSegmentListAndHeader, WriteSegmentList, WriteSegmentListAndHeader, NewSegmentList, FreeSegmentList, AddSegment, DeleteSegment, FindLastSegment, FindSegment, LabelSegment, SegmentListHead, FindNearestSegment - routines to manipulate segment list.

SYNOPSIS

#include <speech.h>

int ReadSegmentList (char *file, SegmentList **seg, float *ms)

int WriteSegmentList (char *file, SegmentList *seg, float ms)

int ReadSegmentListAndHeader(char *file, SegmentList **seg, AsciiHddr *hdr)

int WriteSegmentListAndHeader(char *file, SegmentList *seg, AsciiHdr *hdr)

SegmentList *NewSegmentList()

void FreeSegmentList (SegmentList *seg)

int AddSegment (SegmentList *seg, int begin, int end, char *label)

void DeleteSegment (SegmentList *seg)

SegmentList *FindLastSegment (SegmentList *seg)

int LabelSegment (SegmentList *seg, char *label)

SegmentList *SegmentListHead (SegmentList *seg)

SegmentList *FindSegment (SegmentList *seg, int begin)

SegmentList *FindNearestSegment (SegmentList *seg, int frame)

DESCRIPTION

These routines are used to manipulate segment lists.

ReadSegmentList() is used to read the Lola file file into memory. The space for the segment list is allocated with malloc (3). The address of the head of the segment list is placed in seg and ms is set to the milliseconds per frame. The segment list should be freed using FreeSegmentList().

WriteSegmentList() is used to write segment list seg to file with a milliseconds per frame of ms.

ReadSegmentListAndHeader() is the same as ReadSegmentList() except that the entire header for the segment file is returned in hdr. WriteSegmentListAndHeader() is the same as WriteSegmentList() except that the header for the segment file is passed to hdr.

NewSegmentList() is used to create a new segment list in memory. NewSegmentList() returns a pointer to a SegementList. A SegmentList is

    struct segmentlist {
        char *sl_label; /* lola label */
        int sl_begin; /* begin frame index */
        int sl_end; /* end frame index */
        struct segmentlist *sl_forward; /* forward pointer */
        struct segmentlist *sl_backward; /* backward pointer*/
    };
    typedef struct segmentlist SegmentList;

A segment list is a linked list, linked both forward and backward. The head of the list has the label "HEAD"; begin and end points of -1 and a NULL sl_backward pointer. The sl_forward pointer points to the first node to contain data in the list. The end of the list is reached when sl_forward is equal to NULL (0). AddSegment() is used to add a new segment to an existing segment list. seg is a pointer to the head of the segment, begin, and end are the begining and ending frame numbers of the new segment and label is the label for the segment. AddSegment() maintains the segment list in ascending order by the beginning frame number.

DeleteSegment() deletes the segment pointed to by seg.

FindLastSegment() returns a pointer to the last segment in the segment list seg.

LabelSegement() sets the label to label of the segment pointed to by seg.

SegmentListHead() given any segment seg in a segment list, returns the head of the list.

FindSegment() searches the segment list seg for the last segment which satisfies the condition:
    begin < seg->sl_begin

FindNearestSegment() searches the segment list seg for the nearest seg to frame. The nearest segment is the one which has the closest sl_begin or sl_end to frame.

FreeSegmentList() frees the memory used by seg.

EXAMPLES

DIAGNOSTICS

Functions that return an int return a negative number on error and sets ErrorString. Functions that return a pointer return a NULL on error and sets ErrorString.

SEE ALSO
ErrorString(3SP), malloc(3), free(3),

BUGS

AUTHORS
Center for Spoken Language Understanding
Department of Computer Science and Engineering
Oregon Graduate Institute of Science & Technology