strusAnalyzer  0.17
document.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Patrick P. Frey
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7  */
10 #ifndef _STRUS_ANALYZER_DOCUMENT_HPP_INCLUDED
11 #define _STRUS_ANALYZER_DOCUMENT_HPP_INCLUDED
12 #include "strus/numericVariant.hpp"
16 #include <string>
17 #include <vector>
18 
20 namespace strus {
22 namespace analyzer {
23 
25 class Document
26 {
27 public:
31 #if __cplusplus >= 201103L
32  Document( Document&& ) = default;
33  Document( const Document& ) = default;
34  Document& operator= ( Document&& ) = default;
35  Document& operator= ( const Document& ) = default;
36 #else
37  Document( const Document& o)
38  :m_subdoctypename(o.m_subdoctypename)
39  ,m_metadata(o.m_metadata)
40  ,m_attributes(o.m_attributes)
41  ,m_searchIndexTerms(o.m_searchIndexTerms)
42  ,m_forwardIndexTerms(o.m_forwardIndexTerms){}
43 #endif
44 
46  const std::string& subDocumentTypeName() const {return m_subdoctypename;}
48  const std::vector<DocumentAttribute>& attributes() const {return m_attributes;}
50  const std::vector<DocumentMetaData>& metadata() const {return m_metadata;}
52  const std::vector<DocumentTerm>& searchIndexTerms() const {return m_searchIndexTerms;}
54  const std::vector<DocumentTerm>& forwardIndexTerms() const {return m_forwardIndexTerms;}
55 
57  void setSubDocumentTypeName( const std::string& n)
58  {
59  m_subdoctypename = n;
60  }
62  void setAttribute( const std::string& t, const std::string& v)
63  {
64  m_attributes.push_back( DocumentAttribute( t,v));
65  }
66 
70  void setMetaData( const std::string& t, const NumericVariant& v)
71  {
72  m_metadata.push_back( DocumentMetaData( t,v));
73  }
74 
79  void addSearchIndexTerm( const std::string& t, const std::string& v, unsigned int p)
80  {
81  m_searchIndexTerms.push_back( DocumentTerm( t, v, p));
82  }
83 
86  void addSearchIndexTerms( const std::vector<DocumentTerm>& terms)
87  {
88  m_searchIndexTerms.insert( m_searchIndexTerms.end(), terms.begin(), terms.end());
89  }
90 
95  void addForwardIndexTerm( const std::string& t, const std::string& v, unsigned int p)
96  {
97  m_forwardIndexTerms.push_back( DocumentTerm( t, v, p));
98  }
99 
102  void addForwardIndexTerms( const std::vector<DocumentTerm>& terms)
103  {
104  m_forwardIndexTerms.insert( m_forwardIndexTerms.end(), terms.begin(), terms.end());
105  }
106 
108  void clear()
109  {
110  m_subdoctypename.clear();
111  m_metadata.clear();
112  m_attributes.clear();
113  m_searchIndexTerms.clear();
114  m_forwardIndexTerms.clear();
115  }
116 
118  void swap( Document& o)
119  {
120  m_subdoctypename.swap(o.m_subdoctypename);
121  m_metadata.swap(o.m_metadata);
122  m_attributes.swap(o.m_attributes);
123  m_searchIndexTerms.swap(o.m_searchIndexTerms);
124  m_forwardIndexTerms.swap(o.m_forwardIndexTerms);
125  }
126 
127 private:
128  std::string m_subdoctypename;
129  std::vector<DocumentMetaData> m_metadata;
130  std::vector<DocumentAttribute> m_attributes;
131  std::vector<DocumentTerm> m_searchIndexTerms;
132  std::vector<DocumentTerm> m_forwardIndexTerms;
133 };
134 
135 }}//namespace
136 #endif
137 
const std::vector< DocumentTerm > & forwardIndexTerms() const
Get the list of the forward index terms defined in this document.
Definition: document.hpp:54
void swap(Document &o)
Swap a document structure with another.
Definition: document.hpp:118
void addForwardIndexTerm(const std::string &t, const std::string &v, unsigned int p)
Define a forward index term of the document.
Definition: document.hpp:95
Structure describing a document meta data element.
void clear()
Clear the document content.
Definition: document.hpp:108
const std::vector< DocumentTerm > & searchIndexTerms() const
Get the list of the search index terms defined in this document.
Definition: document.hpp:52
const std::string & subDocumentTypeName() const
Get the sub document type name.
Definition: document.hpp:46
Document(const Document &o)
Copy constructor.
Definition: document.hpp:37
void addForwardIndexTerms(const std::vector< DocumentTerm > &terms)
Define a list of forward index terms of the document.
Definition: document.hpp:102
void addSearchIndexTerms(const std::vector< DocumentTerm > &terms)
Define a list of search index terms of the document.
Definition: document.hpp:86
const std::vector< DocumentMetaData > & metadata() const
Get the list of the metadata defined in this document.
Definition: document.hpp:50
Structure describing a document attribute.
Definition: documentAttribute.hpp:20
Structure describing a typed document term.
const std::vector< DocumentAttribute > & attributes() const
Get the list of the attributes defined in this document.
Definition: document.hpp:48
Document()
Default constructor.
Definition: document.hpp:29
Structure describing a document meta data element.
Definition: documentMetaData.hpp:21
void setMetaData(const std::string &t, const NumericVariant &v)
Define a meta data element of the document.
Definition: document.hpp:70
void setSubDocumentTypeName(const std::string &n)
Set the name of the sub document type as declared in the document analyzer (empty for the main docume...
Definition: document.hpp:57
void setAttribute(const std::string &t, const std::string &v)
Define an attribute of the document.
Definition: document.hpp:62
Structure describing a typed document term.
Definition: documentTerm.hpp:21
void addSearchIndexTerm(const std::string &t, const std::string &v, unsigned int p)
Define a search index term of the document.
Definition: document.hpp:79
Structure describing a document attribute.
Structure of a document created as result of a document analysis.
Definition: document.hpp:25