edu.ucsb.nmsl.tools
Class Caption

java.lang.Object
  extended by edu.ucsb.nmsl.tools.Caption

public class Caption
extends java.lang.Object

This class represents the basic components of a Transcritp, captions. For the purposes of AutoCap, a caption is defined as a segment of a transcript that has a time-stamp. The purpose of this time stamp is to mark the point in time that the beginning of a caption was spoken. Furthermore, these captions may represent different levels of organization within the transcript. For example, the transcripts for QAD Inc.'s media materials represented groups of related sentences. The number of these sentences is usually between two and three. Other levels of organization are also possible to use such as sentences or parts of sentences. It is not the responsibility of the Caption or Transcript classes to segment the transcripts. The organization of transcripts is expressed within the transcript files themselves.

Each Caption object is responsible for storing and providing acess to both the text of the caption and a time-stamp. Each caption is further broken into caption chunks. The size of these chunks is one word per chunk. Furthermore, each chunk keeps the time-stamp of when the word begins and ends withing the media file. This organization of captions allows for the user of the class to iterate through each word of the caption which facilitates the estimation phase of the AutoCap process. Specialized instances of this class may choose a different level of organization.

see edu.ucsb.nmsl.tools.Transcript Transcript

Version:
1.0
Author:
Allan Knight

Nested Class Summary
 class Caption.CaptionChunk
          This inner class is responsible for storing the individual caption chunks that make up a caption.
 
Field Summary
protected  java.lang.StringBuffer caption
          The entire text of the caption.
protected  java.util.LinkedList captions
          A list of each caption chunk that makes up the entire caption
protected static double[] factors
          Multiplication factors for parsing a time from a string.
 
Constructor Summary
Caption()
          This default contructor creates a default instance of a caption with the start and finish time-stamps set to -1 and the caption text set to the empty string.
Caption(double s, double f, java.lang.String c)
          This constructor creates an instance with the given caption text, given start time-stamp and given finish time-stamp.
Caption(double t, java.lang.String c)
          This constructor creates an instance with the given caption text and given start time-stamp.
Caption(java.lang.String t, java.lang.String c)
          This contructor creates an instance with the given caption text and given start time-stamp, which is in string form.
Caption(java.lang.String s, java.lang.String f, java.lang.String c)
          This contructor creates an instance with the given caption text, given start and finish time-stamps, which are in string form.
 
Method Summary
 void appendCaption(double s, double f, java.lang.String c)
          This method appends another caption chunk on the end of a Caption with the given start and finish time-stamps.
 java.lang.String getCaption()
          This accessor method returns the all the caption chunks as a String.
 double getFinishTime()
          This mutator method sets the finish time-stamp for the caption.
 Caption.CaptionChunk getFirstChunk()
          This accessor method returns the first caption chunk, which should be a word of the caption.
 Caption.CaptionChunk getLastChunk()
          This accessor method returns the last caption chunk, which should be a word of the caption.
 double getMaxError()
          This accessor function returns the maximum caption error associated with the start time-stamp of the caption.
 double getTime()
          This accessor method returns the start time-stamp for the caption.
 java.util.Iterator iterator()
          This method returns an Iterator that allows for the sequential access to each chunk of the caption.
 java.util.ListIterator listIterator(int idx)
          This method returns an Iterator that allows for the sequential access to each chunk of the caption.
protected  double parseTime(java.lang.String t)
          This method is a helper function that parses a time-stamp of the form "HH:MM:SS" from a string and returns the number of seconds rempresented by the string.
 void setFinishTime(double time)
          This accessor method returns the finish time-stamp for the caption.
 void setMaxError(double d)
          This mutator method sets the maximum error associated with the caption.
 void setStartTime(double time)
          This mutator method sets the start time-stamp for the caption.
 int size()
          This method returns the number of chunks, or words in the caption.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

caption

protected java.lang.StringBuffer caption
The entire text of the caption. This parameter is for speed up when returning the caption text.


captions

protected java.util.LinkedList captions
A list of each caption chunk that makes up the entire caption


factors

protected static final double[] factors
Multiplication factors for parsing a time from a string.

Constructor Detail

Caption

public Caption()
This default contructor creates a default instance of a caption with the start and finish time-stamps set to -1 and the caption text set to the empty string.


Caption

public Caption(double t,
               java.lang.String c)
This constructor creates an instance with the given caption text and given start time-stamp.

Parameters:
t - The start time-stamp associated with the caption.
c - The caption text as a String. This caption chunk should be a word.

Caption

public Caption(double s,
               double f,
               java.lang.String c)
This constructor creates an instance with the given caption text, given start time-stamp and given finish time-stamp.

Parameters:
s - The start time-stamp associated with the caption.
f - The finish time-stamp associated with the caption.
c - The caption text as a String. This caption chunk should be a word.

Caption

public Caption(java.lang.String t,
               java.lang.String c)
This contructor creates an instance with the given caption text and given start time-stamp, which is in string form. This constructor is helpful when reading the captions from a file.

Parameters:
t - The start time-stamp of the caption given as a string.
c - The caption text as a String. This caption chunk should be a word.

Caption

public Caption(java.lang.String s,
               java.lang.String f,
               java.lang.String c)
This contructor creates an instance with the given caption text, given start and finish time-stamps, which are in string form. This constructor is helpful when reading the captions from a file.

Parameters:
s - The start time-stamp of the caption given as a string.
f - The finish time-stamp of the caption given as a string.
c - The caption text as a String. This caption chunk should be a word.
Method Detail

parseTime

protected double parseTime(java.lang.String t)
This method is a helper function that parses a time-stamp of the form "HH:MM:SS" from a string and returns the number of seconds rempresented by the string.

Parameters:
t - The time-stamp string as read from a file.
Returns:
The number of seconds rrepresented by the time string.

appendCaption

public void appendCaption(double s,
                          double f,
                          java.lang.String c)
This method appends another caption chunk on the end of a Caption with the given start and finish time-stamps.

Parameters:
s - The start time-stamp associated with the caption.
f - The finish time-stamp associated with the caption.
c - The caption text as a String. This caption chunk should be a word.

getTime

public double getTime()
This accessor method returns the start time-stamp for the caption. This time-stamp represents the start of the caption being spoken in the media.

Returns:
The start time-stamp of the caption in seconds.

setStartTime

public void setStartTime(double time)
This mutator method sets the start time-stamp for the caption. This time-stamp represents the start of the caption being spoken in the media.

Parameters:
time - The start time-stamp of the caption in seconds.

setFinishTime

public void setFinishTime(double time)
This accessor method returns the finish time-stamp for the caption. This time-stamp represents the end of the caption being spoken in the media.

Parameters:
time - The finish time-stamp of the caption in seconds.

getFinishTime

public double getFinishTime()
This mutator method sets the finish time-stamp for the caption. This time-stamp represents the end of the caption being spoken in the media.

Returns:
The finish time-stamp of the caption in seconds.

getMaxError

public double getMaxError()
This accessor function returns the maximum caption error associated with the start time-stamp of the caption.

Returns:
The maximum caption error in seconds.

setMaxError

public void setMaxError(double d)
This mutator method sets the maximum error associated with the caption.

Parameters:
d - The maximum caption error in seconds.

getFirstChunk

public Caption.CaptionChunk getFirstChunk()
This accessor method returns the first caption chunk, which should be a word of the caption.

Returns:
The first caption chunk of the caption.

getLastChunk

public Caption.CaptionChunk getLastChunk()
This accessor method returns the last caption chunk, which should be a word of the caption.

Returns:
The last caption chunk of the caption.

getCaption

public java.lang.String getCaption()
This accessor method returns the all the caption chunks as a String.

Returns:
The text of the caption.

iterator

public java.util.Iterator iterator()
This method returns an Iterator that allows for the sequential access to each chunk of the caption. Since each chunk is a word, this iterator allows the caller to iterate through each word of the caption.

Returns:
An Iterator for sequential sequential access to each caption chunk.

listIterator

public java.util.ListIterator listIterator(int idx)
This method returns an Iterator that allows for the sequential access to each chunk of the caption. Since each chunk is a word, this iterator allows the caller to iterate through each word of the caption.

Returns:
An Iterator for sequential sequential access to each caption chunk.

size

public int size()
This method returns the number of chunks, or words in the caption.

Returns:
The number of chunks in the caption.