/usr/include/libfolia/document.h is in libfolia-dev 0.10-4.2+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | /*
$Id: document.h 15909 2013-04-03 13:52:24Z sloot $
$URL: https://ilk.uvt.nl/svn/sources/libfolia/trunk/include/libfolia/document.h $
Copyright (c) 1998 - 2013
ILK - Tilburg University
CLiPS - University of Antwerp
This file is part of libfolia
libfolia is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
libfolia is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>.
For questions and suggestions, see:
http://ilk.uvt.nl/software.html
or send mail to:
timbl@uvt.nl
*/
#ifndef FOLIA_DOCUMENT_H
#define FOLIA_DOCUMENT_H
#include <list>
#include "unicode/unistr.h"
#include "unicode/regex.h"
#include "libxml/tree.h"
#include "libxml/xpath.h"
#include <ctime>
#include "libfolia/folia.h"
#include "libfolia/foliautils.h"
namespace folia {
extern const std::string NSFOLIA;
class Pattern {
friend std::ostream& operator<<( std::ostream&, const Pattern& );
public:
Pattern( const std::vector<std::string>&,
const ElementType = BASE,
const std::string& = "" );
Pattern( const std::vector<std::string>&,
const std::string& );
~Pattern();
bool match( const UnicodeString& , size_t&, int&, bool&, bool& ) const;
size_t size() const { return sequence.size(); };
void unsetwild();
bool variablesize() const;
std::set<int> variablewildcards() const;
ElementType matchannotation;
bool regexp;
private:
bool case_sensitive;
int maxgapsize;
std::vector<UnicodeString> sequence;
std::vector<RegexMatcher*> matchers;
std::string matchannotationset;
};
class FoliaElement;
class Word;
class Sentence;
class Paragraph;
class Document {
friend bool operator==( const Document&, const Document& );
friend std::ostream& operator<<( std::ostream&, const Document& );
public:
Document();
Document( const std::string& );
~Document();
void init();
bool readFromFile( const std::string& );
bool readFromString( const std::string& );
bool save( std::ostream&, const std::string&, bool = false );
bool save( std::ostream& os, bool kanon = false ){
return save( os, "", kanon );
}
bool save( const std::string&, const std::string&, bool = false );
bool save( const std::string& s, bool kanon = false ){
return save( s, "", kanon );
}
int size() const;
FoliaElement* doc() const { return foliadoc; }
FoliaElement* addNode( ElementType, const KWargs& );
void addStyle( const std::string&, const std::string& );
void replaceStyle( const std::string&, const std::string& );
std::vector<Paragraph*> paragraphs() const;
std::vector<Sentence*> sentences() const;
std::vector<Sentence*> sentenceParts() const;
std::vector<Word*> words() const;
std::vector<std::vector<Word*> > findwords( const Pattern&,
const std::string& ="" ) const;
std::vector<std::vector<Word*> > findwords( std::list<Pattern>&,
const std::string& = "" ) const;
Word *words( size_t ) const;
Word *rwords( size_t ) const;
Paragraph *paragraphs( size_t ) const;
Paragraph *rparagraphs( size_t ) const;
Sentence *sentences( size_t ) const;
Sentence *rsentences( size_t ) const;
std::string toXml( const std::string& ="", bool = false ) const;
MetaDataType metadatatype() const { return _metadatatype; };
std::string metadatafile() const { return _metadatafile; };
FoliaElement *append( FoliaElement* );
void addDocIndex( FoliaElement* el, const std::string& );
FoliaElement* operator []( size_t ) const; //select i'th element from data
FoliaElement *index( const std::string& ) const; //retrieve element with specified ID
FoliaElement* operator []( const std::string& ) const ; //index as operator
bool isDeclared( AnnotationType::AnnotationType,
const std::string&, const std::string&,
const std::string&, const std::string& );
bool isDeclared( AnnotationType::AnnotationType, const std::string& = "" );
std::string defaultset( AnnotationType::AnnotationType ) const;
std::string defaultannotator( AnnotationType::AnnotationType,
const std::string& ="" ) const;
std::string defaultannotatortype( AnnotationType::AnnotationType,
const std::string& ="" ) const;
std::string defaultdatetime( AnnotationType::AnnotationType,
const std::string& ="" ) const;
FoliaElement* parseXml( );
std::string id() const { return _id; };
void declare( AnnotationType::AnnotationType,
const std::string&,
const std::string& = "" );
void declare( AnnotationType::AnnotationType,
const std::string&, const std::string&,
const std::string&, const std::string& );
xmlDoc *XmlDoc() const { return xmldoc; };
xmlNs *foliaNs() const { return _foliaNsOut; };
void keepForDeletion( FoliaElement *p ) { delSet.insert( p ); };
int debug;
class at_t {
friend std::ostream& operator<<( std::ostream&, const at_t& );
public:
at_t( const std::string& _a, const std::string& _t, const std::string& _d ): a(_a),t(_t),d(_d){};
std::string a;
std::string t;
std::string d;
};
private:
std::map<AnnotationType::AnnotationType,std::multimap<std::string,at_t> > annotationdefaults;
FoliaElement* parseFoliaDoc( xmlNode * );
void setimdi( xmlNode * );
void setAttributes( const KWargs& );
void parseannotations( xmlNode * );
void getstyles();
void setannotations( xmlNode *) const;
void setmetadata( xmlNode * ) const;
void setstyles( xmlDoc* ) const;
std::map<std::string, FoliaElement* > sindex;
std::vector<FoliaElement* > iindex;
std::vector<FoliaElement*> data;
std::string _id;
std::set<FoliaElement *> delSet;
FoliaElement *foliadoc;
xmlDoc *xmldoc;
xmlNs *_foliaNsIn;
mutable xmlNs *_foliaNsOut;
MetaDataType _metadatatype;
xmlNode *metadata;
std::string _metadatafile;
std::string _title;
std::string _date;
std::string _language;
std::string _publisher;
std::string _license;
std::multimap<std::string,std::string> styles;
bool loadall;
std::string filename;
std::string version;
};
bool operator==( const Document&, const Document& );
inline bool operator!=( const Document& d1, const Document& d2 ){
return !( d1==d2 );
}
inline std::ostream& operator<<( std::ostream& os, const Document::at_t& at ){
os << "<" << at.a << "," << at.t << "," << at.d << ">";
return os;
}
} // namespace folia
#endif // FOLIA_DOCUMENT_H
|