Brevity Document Summarizer Toolkit
Main Functions Types Errors Demos Home

brGetOffsets

Gets the a list of offsets into the file or buffer you summarized. Each offset is a sentence that Brevity feels partially represents the document or which expresses a significant thought in the document. You can specify the maximum number of sentences Brevity returns. When the function is called this variable will hold the actual number of sentences Brevity found. This value may be less than the number you specified. Note that you must allocate the space for the sentences.

The sentences are stored in an array of structs of type SentenceListT. This structure contains the offsets to the beginning of each sentence and then the length of that sentence. Note that these offsets and lengths are in characters based upon the buffer you passed to Brevity.

While Brevity returns the number of significant sentences it found, the array Sentences actually contains one extra element. This element has 0 for the values of start and length. This provides a second way of checking for the end of the sentence array when you are iterating through it. This means that if you create an array of 6 elements the largest number of returned sentences Brevity will generate is 5. See the sample code for more discussion of this.

Synopsis

void brGetOffsets( SumManagerT Summarizer, int *NumSentences, SentenceListT *Sentences )

Arguments

Summarizer The Brevity summarizer object returned by brCreateSummarizer.
NumSentences A pointer to an integer. When you call brGetOffsets this integer should be the number of elements in the array you pass to brGetOffsets. You can actually make this value anything you wish. It must be at least 1 larger than the maximum number of sentences you want returned. When brGetOffsets returns this integer will contain the actual number of valid sentences in the array.
Sentences An array of structs of type SentenceListT.

Returns

Nothing.

Related Functions

brGetSummary

Example

// We assume you've already summarized a buffer or file





SentenceListT   sentences[11];

int             num_sentences = 11;  // the number of elements in our array

int             count;



ixGetOffsets( Brevity, &num_sentences, sentences );



// at this stage num_sentences will be equal to 10, NOT 11.  The 11th element

// of sentences will be {0,0}



for( count = 0; count < num_sentences; count++ ) {



  printf("Sentence %d start: %d", sentences[ count ], sentences[ count ].start );

  printf("Sentence %d length: %d", sentences[ count ], sentences[ count ].length );



  // some function you could write to print the sentence, highlight it or do something 

  // else to it

  printsentence( databuffer, sentences[ count ].start, sentences[ count ].length );



}



// we could have written the above as follows instead



count = 0;

while( sentences[ count ].length != 0 ) {



  printf("Sentence %d start: %d", sentences[ count ], sentences[ count ].start );

  printf("Sentence %d length: %d", sentences[ count ], sentences[ count ].length );



  // some function you could write to print the sentence, highlight it or do something 

  // else to it

  printsentence( databuffer, sentences[ count ].start, sentences[ count ].length );



}

  

 

Previous Main Next Home

Copyright 2000 Lextek International