32 #ifndef MOOT_TOKEN_XML_DOC_IO_H 35 #ifdef MOOT_LIBXML_ENABLED 37 #warning "libxml2 support for mootToken is (and always has been) BROKEN: prefer expat" 54 class TokenXmlDoc :
public mootXmlDoc,
public TokenReader,
public TokenWriter
78 const static int defaultParserOptions
100 mootXPathQuery xpqSentence;
108 mootXPathQuery xpqToken;
118 mootXPathQuery xpqText;
127 mootXPathQuery xpqBesttag;
138 mootXPathQuery xpqAnalysis;
147 mootXPathQuery xpqPostag;
155 mootToken::Analysis curanal;
172 std::string outputRootName;
178 xmlNodePtr outputNode;
196 xpqSentence(
"//s",true),
197 xpqToken(
"./w",true),
198 xpqText(
"./text/text()",true),
199 xpqBesttag(
"./moot.tag/text()",true),
200 xpqAnalysis(
".//analysis",true),
201 xpqPostag(
"./@pos",true),
207 outputRootName(
"doc"),
212 tw_format = tr_format = fmt;
216 tr_sentence = &cursent;
219 xml_options = defaultParserOptions;
221 xml_options |= XML_PARSE_NOBLANKS;
227 virtual ~TokenXmlDoc(
void)
238 virtual void reset(
void)
263 virtual void sourceName(
const std::string &myname) { srcname = myname; };
269 virtual void fromFile(FILE *file)
271 TokenReader::fromFile(file);
272 loadFile(file,NULL,NULL,srcname);
279 virtual void fromString(
const char *s)
281 TokenReader::fromString(s);
282 loadBuffer(s, strlen(s), NULL, NULL, srcname);
298 virtual void carp(
const char *fmt, ...);
313 virtual void toString(std::string &s)
315 TokenWriter::toString(s);
325 virtual void toFile(FILE *file)
327 tw_format |= tiofFile;
328 tw_format &= ~tiofString;
346 virtual void put_token(
const mootToken &token);
352 virtual void put_sentence(
const mootSentence &sentence);
355 void put_token_local(
const mootToken &token);
358 void put_token_nonlocal(
const mootToken &token);
375 virtual bool _post_load_hook(
void);
378 bool evalQuery(mootXPathQuery &query, xmlNodePtr xml_ctx=NULL);
386 inline bool is_local_token(
const mootToken &token)
const 388 return (token.toktype() == TokTypeXML
390 ((
const xmlNodePtr)(token.user_data))->doc == xml_doc);
399 inline bool is_local_sentence(
const mootSentence &sentence)
const 401 for (mootSentence::const_iterator si = sentence.begin();
402 si != sentence.end();
405 if (!is_local_token(*si))
return false;
static const int tiofWellDone
Definition: mootTokenIO.h:79
mootTokenTypeE mootTokenType
Definition: mootToken.h:85
classes and utilities for tokens and associated analyses
Pretty-print (XML only)
Definition: mootTokenIO.h:56
XML format.
Definition: mootTokenIO.h:54
C++ wrapper class for libxml2 tree-mode XML documents (optional)
list< mootToken > mootSentence
Definition: mootToken.h:630
Abstract and native classes for I/O of moot::mootToken objects.
Common typedefs and constants.