00001 // -*- C++ -*- 00002 /* 00003 Phrasehunter - index and query text corpora 00004 Copyright (C) 2006 Torsten Marek (shlomme@gmx.de) & 00005 Armin Schmidt (armin.sch@gmail.com) 00006 00007 This program is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU General Public License 00009 as published by the Free Software Foundation; either version 2 00010 of the License, or (at your option) any later version. 00011 00012 This program is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program; if not, write to the Free Software 00019 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00020 */ 00021 00022 #ifndef TOKENCONTEXT_H 00023 #define TOKENCONTEXT_H TOKENCONTEXT_H 00024 00025 #include "ph_types.h" 00026 #include "support/unicodehelpers.h" 00027 00028 namespace PhraseHunter 00029 { 00030 //! Class that holds one specific context to a Token. 00031 class TokenContext 00032 { 00033 public: 00034 static TokenContextPtr emptyContext(DocID, IdxPos, size_t); 00035 00036 inline DocID docID() 00037 { 00038 return m_docID; 00039 } 00040 00041 inline void setDocID(DocID docID) 00042 { 00043 m_docID = docID; 00044 } 00045 inline void setPosition(IdxPos position) 00046 { 00047 m_position = position; 00048 } 00049 inline void setTokenLength(size_t tokenLength) 00050 { 00051 m_tokenLength = tokenLength; 00052 } 00053 inline IdxPos position() 00054 { 00055 return m_position; 00056 } 00057 inline size_t tokenLength() 00058 { 00059 return m_tokenLength; 00060 } 00061 00062 inline bool empty() 00063 { 00064 return m_leftContext.get() == NULL; 00065 } 00066 00067 void setLeftContext(schma::UnicodePtr leftContext) 00068 { 00069 m_leftContext = leftContext; 00070 } 00071 void setToken(schma::UnicodePtr token) 00072 { 00073 m_token = token; 00074 } 00075 void setRightContext(schma::UnicodePtr rightContext) 00076 { 00077 m_rightContext = rightContext; 00078 } 00079 00080 inline schma::UnicodePtr leftContext() 00081 { 00082 return m_leftContext; 00083 } 00084 inline schma::UnicodePtr rightContext() 00085 { 00086 return m_rightContext; 00087 } 00088 inline schma::UnicodePtr token() 00089 { 00090 return m_token; 00091 } 00092 00093 private: 00094 schma::UnicodePtr m_leftContext; 00095 schma::UnicodePtr m_token; 00096 schma::UnicodePtr m_rightContext; 00097 00098 DocID m_docID; 00099 IdxPos m_position; 00100 size_t m_tokenLength; 00101 00102 TokenContext() 00103 {} 00104 }; 00105 00106 00107 } // PhraseHunter 00108 00109 #endif // TOKENCONTEXT_H