word_db.h
上传用户:psq1974
上传日期:2007-01-06
资源大小:1195k
文件大小:2k
- /* 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 _word_db_h_
- #define _word_db_h_
- #include <glib.h>
- #include <string>
- #include <map>
- #include <vector>
- #include "vs_types.h"
- #include "string_of_text.h"
- /**
- */
- class WordTreeNode {
- public:
- typedef map< int, WordTreeNode * > childrensT;
- protected:
- /** index of child nodes. Case INsensetive */
- childrensT childrens;
- /** list of places, where this word happens to be */
- WordOccurencesT WordOccurences;
- public:
- WordTreeNode() {}
-
- WordTreeNode *get_child( int ch );
- const WordTreeNode *get_child( int ch ) const {
- return ((WordTreeNode *)this)->get_child( ch );
- }
- const childrensT &get_all_childrens() const {
- return childrens;
- }
- void register_word( int movieId, int strIdx, int posInLine );
- const WordOccurencesT &get_word_occurences() const {
- return WordOccurences;
- }
- };
- /**
- */
- class WordDb {
- /** text string by string */
- AllTextsMapT allTextsMap;
- /** the head of the tree */
- WordTreeNode parentNode;
- static const string spaces;
- public:
- WordDb() {}
- const TextOfMovieT *get_movie_text( int movieId );
- const StringOfText *get_string_of_text( int movieId, int linenum ) const;
- void add_new_movie_text( int id, TextOfMovieT *tom );
- void insert_new_string_in_search_tree( const string &str, int movieId,
- int strIdx );
- void insert_new_word_in_search_tree( const string &w, int movieId,
- int strIdx, int posInLine );
- const WordOccurencesT &find_word( const string &w ) const;
- void find_similar_words( const string &word, GList *&similar ) const;
- /** add to GList all reasonable words which are located
- somehow near reference word */
- void find_hint_words( const string &word, GList *&similar ) const;
- WordOccurencesT merge_and( const WordOccurencesT &left,
- const WordOccurencesT &right ) const;
- WordOccurencesT merge_and_not( const WordOccurencesT &left,
- const WordOccurencesT &right ) const;
- WordOccurencesT merge_or( const WordOccurencesT &left,
- const WordOccurencesT &right ) const;
- };
- #endif _word_db_h_