- /* Copyright (C) 1998, 1999 State University of New York at Stony Brook
- Author: Andrew V. Shuvalov ( andrew@ecsl.cs.sunysb.edu )
- Software license is located in file "COPYING"
- */
- #ifndef _string_of_text_h_
- #define _string_of_text_h_
- #include <vector>
- #include <string>
- #include <time.h>
- /**
- */
- class StringOfText {
- string text;
- struct tm _time;
- /** just the same time as time_t */
- time_t _time_t;
- public:
- StringOfText() {}
- StringOfText( const StringOfText &s ) {
- *this = s;
- }
- const StringOfText &operator =( const StringOfText &s ) {
- if( this != &s ) {
- text = s.text;
- _time = s._time;
- _time_t = s._time_t;
- }
- return *this;
- }
- void set( const string &t, const struct tm &tim ) {
- text = t;
- _time = tim;
- _time_t = mktime( ( struct tm *) &tim );
- }
- const string &get_text() const { return text; }
- const struct tm &get_time() const { return _time; }
- time_t get_time_t() const { return _time_t; }
- };
- /** item for list of all places where the word occured
- */
- class WordOccurence {
- unsigned int movieId;
- unsigned int textLine;
- unsigned int posInLine;
- public:
- WordOccurence() {}
- WordOccurence( unsigned int mId, unsigned int tl, unsigned int pil )
- : movieId( mId ), textLine( tl ), posInLine( pil ) {}
- WordOccurence( const WordOccurence &w ) {
- *this = w;
- }
- const WordOccurence & operator =( const WordOccurence &w ) {
- if( this != &w ) {
- movieId = w.movieId;
- textLine = w.textLine;
- posInLine = w.posInLine;
- }
- return *this;
- }
- /** sometimes we need to sort them */
- bool operator <( const WordOccurence &w ) const
- {
- if( movieId < w.movieId )
- return true;
- if( movieId > w.movieId )
- return false;
- if( textLine < w.textLine )
- return true;
- if( textLine > w.textLine )
- return false;
- if( posInLine < w.posInLine )
- return true;
- if( posInLine > w.posInLine )
- return false;
- return true;
- }
- bool is_near( const WordOccurence &w ) const
- {
- if( movieId != w.movieId )
- return false;
- if( textLine + 5 < w.textLine )
- return false;
- if( textLine - 5 > w.textLine )
- return false;
- return true;
- }
- unsigned int get_movie_id() const { return movieId; }
- unsigned int get_text_line() const { return textLine; }
- };
- /** list of word occurencies */
- typedef vector< WordOccurence > WordOccurencesT;
- #endif // _string_of_text_h_
English
