LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
contentDocument.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2022 CEA LIST <gael.de-chalendar@cea.fr>
2//
3// SPDX-License-Identifier: MIT
4
5/************************************************************************
6 * @file contentDocument.cpp
7 * @author Besancon Romaric
8 * @date Wed Oct 29 13:31:44 2003
9 *
10 *
11 ***********************************************************************/
12
13#include "DocumentElements.h"
14
16#include "contentDocument.h"
17
18#include <fstream>
19#include <string>
20#include <deque>
21#include <boost/lexical_cast.hpp>
22
24
25using namespace std;
26using namespace Lima;
27using namespace Lima::Common;
28using namespace Lima::Common::Misc;
29 // to handle dates (parsing)
30
31namespace Lima {
32namespace DocumentsReader {
33
35#ifdef DEBUG_LP
37#endif
38 unsigned int result = 0;
39 if( !empty() ) {
40 result = back()->getOffset();
41 }
42#ifdef DEBUG_LP
43 LDEBUG << "ContentStructuredDocument::getOffset = " << result;
44#endif
45 return result;
46}
47
49 const unsigned int offset ) {
50 back()->addPart(text,offset);
51}
52
54 const QString& elementName, unsigned int parserOffset, const DocumentPropertyType& type ) {
55#ifdef DEBUG_LP
57 LDEBUG << "ContentStructuredDocument::addPropertyChild" << elementName << "for property" << type.getId();
58#endif
60 result = new DocumentPropertyElement(elementName, parserOffset, type);
61 push_back(result);
62 return result;
63}
64
66 const QString& elementName, unsigned int parserOffset,
67 const DocumentPropertyType& propType )
68{
69#ifdef DEBUG_LP
71 LDEBUG << "ContentStructuredDocument::pushHierarchyChild" << elementName << parserOffset;
72 if( propType.getValueCardinality() != CARDINALITY_NONE ) {
73 StorageType storageType = propType.getStorageType();
74 LDEBUG << "and with property: id=" << propType.getId() << ", storageType=" << Lima::DocumentsReader::storageTypeTag[storageType];
75 }
76 else {
77 LDEBUG << "and without property";
78 }
79#else
80 LIMA_UNUSED(propType);
81#endif
82 HierarchyDocumentElement* result = nullptr;
83 if( empty() ) {
84#ifdef DEBUG_LP
85 LDEBUG << "empty";
86#endif
87 const PropagatedProperties emptyPropagated;
88 result = new HierarchyDocumentElement(elementName, parserOffset, emptyPropagated);
89 }
90 else {
91#ifdef DEBUG_LP
92 LDEBUG << "not empty";
93#endif
94 AbstractStructuredDocumentElement* lastElement = back();
95 HierarchyDocumentElement* hierarchyElement = dynamic_cast<HierarchyDocumentElement*>(lastElement);
96#ifdef DEBUG_LP
97 LDEBUG << "structuredElement:" << hierarchyElement;
98#endif
99 if( hierarchyElement != 0 ) {
100 result = new HierarchyDocumentElement(elementName, parserOffset, hierarchyElement->getPropertyList());
101 }
102 }
103 if (result) {
104 result->GenericDocumentProperties::setIntValue("offBegPrpty", parserOffset);
105 }
106 else {
107 DRLOGINIT;
108 LWARN << "ContentStructuredDocument::pushHierarchyChild: result was not initialized";
109 }
110
111 push_back(result);
112#ifdef DEBUG_LP
113 LDEBUG << "ContentStructuredDocument::pushHierarchyChild: end";
114#endif
115 return result;
116}
117
119 const QString& elementName, unsigned int parserOffset,
120 const DocumentPropertyType& propType )
121{
122
123#ifdef DEBUG_LP
124 DRLOGINIT;
125 LDEBUG << "ContentStructuredDocument::pushIndexingChild" << elementName<< parserOffset;
126 if( propType.getValueCardinality() != CARDINALITY_NONE ) {
127 StorageType storageType = propType.getStorageType();
128 LDEBUG << "and with property: id=" << propType.getId() << ", storageType=" << Lima::DocumentsReader::storageTypeTag[storageType];
129 }
130 else {
131 LDEBUG << "and without property";
132 }
133#endif
134 IndexingDocumentElement* result = 0;
135 assert( !empty() ) ;
136 AbstractStructuredDocumentElement* lastElement = back();
137 HierarchyDocumentElement* hierarchyElement = dynamic_cast<HierarchyDocumentElement*>(lastElement);
138#ifdef DEBUG_LP
139 LDEBUG << "structuredElement:" << hierarchyElement;
140#endif
141 if( hierarchyElement != 0 )
142 {
143 result = new IndexingDocumentElement(elementName, parserOffset, propType, hierarchyElement->getPropertyList());
144 }
145 else
146 {
147 // Can have only hierarchy parent
148 return 0;
149 }
150 result->GenericDocumentProperties::setIntValue("offBegPrpty", parserOffset);
151
152 push_back(result);
153#ifdef DEBUG_LP
154 LDEBUG << "ContentStructuredDocument::pushIndexingChild: end";
155#endif
156 return result;
157}
158
160 const QString& elementName, unsigned int parserOffset, const DocumentPropertyType& propType )
161{
162
163#ifdef DEBUG_LP
164 DRLOGINIT;
165 LDEBUG << "ContentStructuredDocument::pushIgnoredChild" << elementName<< parserOffset;
166 if( propType.getValueCardinality() != CARDINALITY_NONE ) {
167 StorageType storageType = propType.getStorageType();
168 LDEBUG << "and with property: id=" << propType.getId() << ", storageType=" << Lima::DocumentsReader::storageTypeTag[storageType];
169 }
170 else {
171 LDEBUG << "and without property";
172 }
173#endif
174
175 AbstractStructuredDocumentElement* lastElement = back();
177 IgnoredDocumentElement* result = new IgnoredDocumentElement(elementName, parserOffset, propType, propertiesElement->getPropertyList());
178#ifdef DEBUG_LP
179 assert( !empty() ) ;
180#endif
181
182 push_back(result );
183#ifdef DEBUG_LP
184 LDEBUG << "ContentStructuredDocument::pushIgnoredChild: end";
185#endif
186 return result;
187}
188
190 const QString& elementName, unsigned int parserOffset )
191{
192#ifdef DEBUG_LP
193 DRLOGINIT;
194 LDEBUG << "ContentStructuredDocument::addDiscardableChild" << elementName << parserOffset;
195#endif
197 result = new DiscardableDocumentElement(elementName, parserOffset );
198 push_back(result);
199 return result;
200}
201
203 const QString& elementName, unsigned int parserOffset )
204{
205#ifdef DEBUG_LP
206 DRLOGINIT;
207 LDEBUG << "ContentStructuredDocument::pushPresentationChild" << elementName << parserOffset <<back()->getOffset();
208#endif
209
211#ifdef DEBUG_LP
212 assert( !empty() );
213#endif
214 IndexingDocumentElement* structuredElement = dynamic_cast<IndexingDocumentElement*>(back());
215 if( structuredElement != 0 )
216 {
217 result = new PresentationDocumentElement(elementName, parserOffset, structuredElement->getPropertyList() );
218 result->addSpaces(parserOffset-back()->getOffset());
219 }
220 else
221 {
222 const PropagatedProperties emptyPropagated;
223 result = new PresentationDocumentElement(elementName, parserOffset, emptyPropagated );
224 result->addSpaces(parserOffset-back()->getOffset());
225 }
226
227 push_back(result);
228 return result;
229}
230
232 for( deque<AbstractStructuredDocumentElement*>::iterator cIt = begin() ; cIt != end() ; cIt++ ) {
233 delete *cIt;
234 }
235}
236
238{
239#ifdef DEBUG_LP
240 DRLOGINIT;
241 LDEBUG << "ContentStructuredDocument::popDiscardableElement" << parserOffset;
242#endif
243 AbstractStructuredDocumentElement* currentElement = back();
244#ifdef DEBUG_LP
245 assert( currentElement->nodeType() == NODE_DISCARDABLE );
246#endif
247 pop_back();
248#ifdef DEBUG_LP
249 assert( size() != 0 );
250#endif
251
252 if (!empty())
253 {
254 AbstractStructuredDocumentElement* newCurrent = back();
255 newCurrent->addToCurrentOffset(QString(parserOffset-newCurrent->getOffset(),' '));
256 newCurrent->setOffset(parserOffset);
257 }
258 delete currentElement;
259}
260
262{
263#ifdef DEBUG_LP
264 DRLOGINIT;
265 LDEBUG << "ContentStructuredDocument::popPropertyElement" << parserOffset;
266#endif
267 AbstractStructuredDocumentElement* currentElement = back();
268#ifdef DEBUG_LP
269 assert( currentElement->nodeType() == NODE_PROPERTY );
270#endif
271 pop_back();
272#ifdef DEBUG_LP
273 assert( size() != 0 );
274#endif
275 AbstractStructuredDocumentElement* parentElement = back();
276 // TODO Handle property element specifics
277 parentElement->setOffset(parserOffset);
278 delete currentElement;
279}
280
281void ContentStructuredDocument::popPresentationElement( unsigned int parserOffset ) {
282#ifdef DEBUG_LP
283 DRLOGINIT;
284 LDEBUG << "ContentStructuredDocument::popPresentationElement" << parserOffset;
285#endif
286 PresentationDocumentElement* currentElement = dynamic_cast<PresentationDocumentElement*>(back());
287 currentElement->back()->addText(QString(parserOffset-currentElement->getOffset(),' '));
288#ifdef DEBUG_LP
289 assert( currentElement != 0 );
290#endif
291 pop_back();
292 if (!empty())
293 {
294 AbstractStructuredDocumentElement* newCurrent = back();
295#ifdef DEBUG_LP
296 LDEBUG << "ContentStructuredDocument::popPresentationElement new current element is" <<newCurrent->getElementName();
297#endif
298 HierarchyDocumentElement* hierNewCurrent = dynamic_cast<HierarchyDocumentElement*>(newCurrent);
299 if (hierNewCurrent !=0)
300 {
301#ifdef DEBUG_LP
302 LDEBUG << "ContentStructuredDocument::popPresentationElement propagating properties from" <<currentElement->getElementName() <<"to"<<newCurrent->getElementName();
303#endif
304 hierNewCurrent->setPropagatedValue(currentElement->getPropertyList());
305 }
306 newCurrent->back()->addText(currentElement->back()->getText());
307 newCurrent->setOffset(parserOffset);
308 }
309 delete currentElement;
310}
311
313{
314#ifdef DEBUG_LP
315 DRLOGINIT;
316 LDEBUG << "ContentStructuredDocument::popIndexingElement" << parserOffset;
317#endif
318 IndexingDocumentElement* currentElement = dynamic_cast<IndexingDocumentElement*>(back());
319#ifdef DEBUG_LP
320 assert( currentElement != 0 );
321#endif
322 pop_back();
323 if (currentElement->hasPropType() && !currentElement->getPropType().getId().empty())
324 {
325 currentElement->addProperty(currentElement->getPropType(), currentElement->back()->getText().toUtf8().constData());
326 }
327 if (!empty())
328 {
329 AbstractStructuredDocumentElement* newCurrent = back();
330#ifdef DEBUG_LP
331 LDEBUG << "ContentStructuredDocument::popIndexingElement new current element is" <<newCurrent->getElementName();
332#endif
333 HierarchyDocumentElement* hierNewCurrent = dynamic_cast<HierarchyDocumentElement*>(newCurrent);
334 if ( hierNewCurrent !=0)
335 {
336#ifdef DEBUG_LP
337 LDEBUG << "ContentStructuredDocument::popIndexingElement propagating properties from" <<currentElement->getElementName() <<"to"<<newCurrent->getElementName();
338#endif
339 hierNewCurrent->setPropagatedValue(currentElement->getPropertyList());
340 }
341 newCurrent->setOffset(parserOffset);
342
343 }
344 delete currentElement;
345}
346
347void ContentStructuredDocument::popIgnoredElement(unsigned int parserOffset)
348{
349#ifdef DEBUG_LP
350 DRLOGINIT;
351#endif
352 IgnoredDocumentElement* currentElement = dynamic_cast<IgnoredDocumentElement*>(back());
353#ifdef DEBUG_LP
354 assert( currentElement != 0 );
355 LDEBUG << "ContentStructuredDocument::popIgnoredElement poping" <<currentElement->getElementName() << "at" << parserOffset;
356#endif
357 pop_back();
358 if (!empty())
359 {
360 AbstractStructuredDocumentElement* newCurrent = back();
361#ifdef DEBUG_LP
362 LDEBUG << "ContentStructuredDocument::popIgnoredElement new current element is" <<newCurrent->getElementName();
363#endif
364 HierarchyDocumentElement* hierNewCurrent = dynamic_cast<HierarchyDocumentElement*>(newCurrent);
365 if ( hierNewCurrent !=0 )
366 {
367#ifdef DEBUG_LP
368 LDEBUG << "ContentStructuredDocument::popIgnoredElement propagating properties from" <<currentElement->getElementName() <<"to"<<newCurrent->getElementName();
369#endif
370 hierNewCurrent->setPropagatedValue(currentElement->getPropertyList());
371 }
372 newCurrent->setOffset(parserOffset);
373 }
374 delete currentElement;
375}
376
377// Cas des unit hierarchie
379{
380#ifdef DEBUG_LP
381 DRLOGINIT;
382 LDEBUG << "ContentStructuredDocument::popHierarchyElement" << parserOffset;
383#endif
384 HierarchyDocumentElement* currentElement = dynamic_cast<HierarchyDocumentElement*>(back());
385#ifdef DEBUG_LP
386 assert( currentElement != 0 );
387#endif
388 pop_back();
389 if (!empty())
390 {
391 AbstractStructuredDocumentElement* newCurrent = back();
392#ifdef DEBUG_LP
393 LDEBUG << "ContentStructuredDocument::popHierarchyElement new current element is" <<newCurrent->getElementName();
394#endif
395 HierarchyDocumentElement* hierNewCurrent = dynamic_cast<HierarchyDocumentElement*>(newCurrent);
396 if ( hierNewCurrent != 0 )
397 {
398#ifdef DEBUG_LP
399 LDEBUG << "ContentStructuredDocument::popHierarchyElement propagating properties from" <<currentElement->getElementName() <<"to"<<newCurrent->getElementName();
400#endif
401 auto identPrpty = currentElement->getStringValue("identPrpty");
402 if(identPrpty.second && identPrpty.first!="")
403 {
404#ifdef DEBUG_LP
405 LDEBUG << "ContentStructuredDocument::popHierarchyElement no dot propagate since current identPrpty is not empty:" << identPrpty.first;
406#endif
407 }
408 else {
409 hierNewCurrent->setPropagatedValue(currentElement->getPropertyList());
410 }
411
412 }
413 newCurrent->setOffset(parserOffset);
414 }
415 delete currentElement;
416}
417
419#ifdef DEBUG_LP
420 DRLOGINIT;
421#endif
422 ContentStructuredDocument::reverse_iterator rIt = rbegin();
423 AbstractStructuredDocumentElement* currentElement = *rIt;
424 const DocumentPropertyType& propType = currentElement->getPropType();
425 //assert( currentElement->size() == 1 );
426 const Lima::LimaString text = currentElement->getPropertyValue();
427 std::string utf8text = Misc::limastring2utf8stdstring(text);
428#ifdef DEBUG_LP
429 LDEBUG << "ContentStructuredDocument::setDataToPreviousElement: set property "
430 << propType.getId() << " to " << utf8text;
431#endif
432 rIt++;
433#ifdef DEBUG_LP
434 assert(rIt != rend());
435#endif
436 AbstractStructuredDocumentElement* parentElement = *rIt;
437 setDataToElement( parentElement, propType, utf8text, processor );
438}
439
441 const std::string& data, StructuredXmlDocumentHandler* processor ) {
442 AbstractStructuredDocumentElement* absElement = back();
443 setDataToElement( absElement, property, data, processor );
444}
445
447 const DocumentPropertyType& property, const std::string& data,
448 StructuredXmlDocumentHandler* processor ) {
449#ifdef DEBUG_LP
450 DRLOGINIT;
451 LDEBUG << "ContentStructuredDocument::setDataToElement" << absElement->getElementName()
452 << property.getId() << property.getStorageType() << property.getValueCardinality() << "'" << data << "'";
453#endif
454 if(property.getId().empty()) {
455 DRLOGINIT;
456 LWARN << "ContentStructuredDocument::setDataToElement: property id is empty. Do not use it" << absElement->getElementName();
457 return;
458 }
460
461 if( element == 0 )
462 {
463 DRLOGINIT;
464 LWARN << "ContentStructuredDocument::setDataToElement: element is not a AbstractStructuredDocumentElementWithProperties" << absElement->getElementName();
465 return;
466 }
467
468 switch (property.getStorageType()) {
469
470 case STORAGE_DATE: {
471 QDate dateBegin;
472 QDate dateEnd;
473 parseDate(data,dateBegin,dateEnd);
474 element->setDateValue(property.getId(), dateBegin);
475#ifdef DEBUG_LP
476 LDEBUG << "ContentStructuredDocument::setDataToElement setDateValue : " << property.getId() << " => "<< dateBegin;
477#endif
478 if(dateBegin != dateEnd) {
479 element->setDateValue("date_begin", dateBegin);
480 element->setDateValue("date_end", dateEnd);
481#ifdef DEBUG_LP
482 LDEBUG << "ContentStructuredDocument::setDataToElement setDateIntervalValue : " << property.getId() << " => "<< dateBegin << "-" << dateEnd;
483#endif
484 element->setDateIntervalValue(property.getId(), make_pair(dateBegin,dateEnd) );
485 }
486 }
487 break;
488 case STORAGE_UTF8_STRING: {
489 if( property.getValueCardinality() == CARDINALITY_MULTIPLE) {
490#ifdef DEBUG_LP
491 LDEBUG << "ContentStructuredDocument::setDataToElement addStringValue : " << property.getId() << " => "<< data;
492#endif
493 element->addStringValue(property.getId(), data);
494 } else {
495#ifdef DEBUG_LP
496 LDEBUG << "ContentStructuredDocument::setDataToElement setStringValue : " << property.getId() << " => "<< data;
497#endif
498 element->setStringValue(property.getId(), data);
499 }
500 }
501 break;
502 case STORAGE_INTEGER: {
503#ifdef DEBUG_LP
504 LDEBUG << "ContentStructuredDocument::setDataToElement setIntValue : " << property.getId() << " => "<< atoi(data.c_str());
505#endif
506 element->setIntValue(property.getId(), atoi(data.c_str()));
507 }
508 break;
510 std::string val;
511 float score;
512 parseWeightedValue(data, val, score);
513#ifdef DEBUG_LP
514 LDEBUG << "ContentStructuredDocument::setDataToElement addWeightedPropValue : " << property.getId() << " => "<< val<< "="<<score;
515#endif
516 element->addWeightedPropValue( property.getId(), make_pair(val,score));
517 }
518 break;
519 default:
520 break;
521 }
522 // ajout a la liste des proprietes a propager
523 element->addProperty( property, data );
524 processor->handleProperty( property, data);
525
526#ifdef DEBUG_LP
527 LDEBUG << "ContentStructuredDocument::setDataToElement" << element->getElementName() <<"field(" << property.getId() << ")=["<< data <<"]" << element->getStringValue(property.getId()).first << (*element->getPropertyList().find(property)).second;
528#endif
529}
530
531
532void ContentStructuredDocument::parseWeightedValue(const string& weightedValueStr,
533 std::string& value,
534 float& score)
535{
536#ifdef DEBUG_LP
537 DRLOGINIT;
538 LDEBUG << "ContentStructuredDocument::parseWeightedValue" << weightedValueStr;
539#endif
540
541 char sep1('=');
542 std::string::size_type firstSep;
543
544 try {
545 if ( (firstSep=weightedValueStr.find(sep1)) != string::npos ) {
546 string val(weightedValueStr,0,firstSep);
547 string sco(weightedValueStr,firstSep+1);
548
549 // Try to read the float before.
550 // hence, the in/out variables value and score won't be modified in case of error
551 score = atof(sco.c_str());
552 value = val;
553 }
554 }
555 //catch (boost::bad_lexical_cast& e) {
556 catch (std::exception& e) {
557 DRLOGINIT;
558 LWARN << "Warning: " << e.what();
559 }
560 #ifdef DEBUG_LP
561 LDEBUG << "ContentStructuredDocument::parseWeightedValue" << weightedValueStr << "=>" << value << "-" << score;
562 #endif
563
564}
565
566
567void ContentStructuredDocument::parseDate(const string& dateStr,
568 QDate& dateBegin,
569 QDate& dateEnd)
570{
571#ifdef DEBUG_LP
572 DRLOGINIT;
573 LDEBUG << "ContentStructuredDocument::parseDate" << dateStr;
574#endif
575
576 dateBegin=QDate();
577 dateEnd=QDate();
578
579 char sep1('/');
580 char sep2('-');
581
582 //uint64_t firstSep,secondSep; portage 32 64
583 std::string::size_type firstSep,secondSep;
584 try {
585 if ( (firstSep=dateStr.find(sep1)) != string::npos ) {
586 if ( (secondSep=dateStr.find(sep1,firstSep+1)) != string::npos ) {
587 // suppose day/month/year
588
589 // from_uk_string only defined in recent versions of boost
590// dateBegin=boost::gregorian::from_uk_string(dateStr);
591// dateEnd=boost::gregorian::from_uk_string(dateStr);
592 // current version knows only year/month/day
593
594 string day(dateStr,0,firstSep);
595 string month(dateStr,firstSep+1,secondSep-firstSep);
596 string year(dateStr,secondSep+1);
597 string newDateStr=year+'/'+month+'/'+day;
598 dateBegin=QDate::fromString(newDateStr.c_str());
599 dateEnd=QDate::fromString(newDateStr.c_str());
600 }
601 else {
602 // one separator : suppose month/year
603 // find end of month
604 string month(dateStr,0,firstSep);
605 string year(dateStr,firstSep+1);
606 unsigned short monthNum=atoi(month.c_str());
607 unsigned short yearNum=atoi(year.c_str());
608 dateBegin=QDate(yearNum,monthNum,1);
609 dateEnd=dateBegin.addMonths(1).addDays(-1);
610 }
611 }
612 else if ( (firstSep=dateStr.find(sep2)) != string::npos ) {
613 if ( (secondSep=dateStr.find(sep2,firstSep+1)) != string::npos ) {
614 // suppose year-month-day
615 dateBegin=QDate::fromString(dateStr.c_str(), Qt::ISODate);
616 dateEnd=QDate::fromString(dateStr.c_str(), Qt::ISODate);
617 }
618 else {
619 // one separator : suppose year-month
620 // find end of month
621 string year(dateStr,0,firstSep);
622 string month(dateStr,firstSep+1);
623 unsigned short monthNum=atoi(month.c_str());
624 unsigned short yearNum=atoi(year.c_str());
625 dateBegin=QDate(yearNum,monthNum,1);
626 dateEnd=dateBegin.addMonths(1).addDays(-1);
627 }
628 }
629 else if (! dateStr.empty()) {
630 // no separator : suppose year only
631 unsigned short yearNum=atoi(dateStr.c_str());
632 dateBegin=QDate(yearNum,01,01);
633 dateEnd=QDate(yearNum,12,31);
634 }
635 }
636 //catch (boost::bad_lexical_cast& e) {
637 catch (std::exception& e) {
638 DRLOGINIT;
639 LWARN << "Warning: " << e.what();
640 LWARN << "Failed parsing of date [" << dateStr << "]";
641 // do nothing, keep not_a_date_time as default value
642 }
643#ifdef DEBUG_LP
644 LDEBUG << "ContentStructuredDocument::parseDate" << dateStr << "=>" << dateBegin << "-" << dateEnd;
645#endif
646}
647
648
649} // namespace DocumentsReader
650}
651
#define LWARN
Definition LimaCommon.h:160
#define LIMA_UNUSED(x)
Definition LimaCommon.h:224
#define LDEBUG
Definition LimaCommon.h:157
#define DRLOGINIT
void addWeightedPropValue(const std::string &propName, const std::pair< std::string, float > &str)
std::pair< std::string, bool > getStringValue(std::string propName) const
void setStringValue(const std::string &propName, const std::string &val)
void addStringValue(const std::string &propName, const std::string &str)
void setDateIntervalValue(const std::string &propName, const std::pair< QDate, QDate > &val)
void setDateValue(const std::string &propName, const QDate &val)
void setIntValue(const std::string &propName, const uint64_t &val)
void addProperty(const DocumentPropertyType &propType, const std::string &value)
void setPropagatedValue(const PropagatedProperties &toBePropagated)
virtual void addToCurrentOffset(const Lima::LimaString &value)
virtual const Lima::LimaString & getPropertyValue() const
virtual const DocumentPropertyType & getPropType()
void popDiscardableElement(unsigned int parserOffset)
void setDataToPreviousElement(StructuredXmlDocumentHandler *processor)
static void parseDate(const std::string &dateStr, QDate &dateBegin, QDate &dateEnd)
void addPart(const Lima::LimaString &text, const unsigned int offset)
Ajoute un couple (texte,offset) au dernier element.
IndexingDocumentElement * pushIndexingChild(const QString &elementName, unsigned int parserOffset, const DocumentPropertyType &propType)
void popIgnoredElement(unsigned int parserOffset)
void popIndexingElement(unsigned int parserOffset)
void setDataToElement(AbstractStructuredDocumentElement *absElement, const DocumentPropertyType &property, const std::string &data, StructuredXmlDocumentHandler *processor)
void popHierarchyElement(unsigned int parserOffset)
PresentationDocumentElement * pushPresentationChild(const QString &elementName, unsigned int parserOffset)
Ajoute un element a la pile de type presentation.
DocumentPropertyElement * addPropertyChild(const QString &elementName, unsigned int parserOffset, const DocumentPropertyType &type)
Ajoute un element a la pile de type propriete du noeud fils.
DiscardableDocumentElement * pushDiscardableChild(const QString &elementName, unsigned int parserOffset)
Ajoute un element a la pile de type noeud discardable.
static void parseWeightedValue(const std::string &weightedValueStr, std::string &value, float &score)
unsigned int getOffset()
retourne la position courante byte du dernier element, pour initialiser le suivant
IgnoredDocumentElement * pushIgnoredChild(const QString &elementName, unsigned int parserOffset, const DocumentPropertyType &propType)
void setDataToLastElement(const DocumentPropertyType &property, const std::string &data, StructuredXmlDocumentHandler *processor)
void popPresentationElement(unsigned int parserOffset)
HierarchyDocumentElement * pushHierarchyChild(const QString &elementName, unsigned int parserOffset, const DocumentPropertyType &propType)
Ajoute un element a la pile de type hierarchy.
void popPropertyElement(unsigned int parserOffset)
Element d'un document Xml discardable Exemple <USELESS>private comment</USELESS> => " ...
Element d'un document XML definissant une propriete du noeud pere Exemple <filename>d1....
const CardinalityType & getValueCardinality() const
Element d'un document XML dont content est indexee Exemple <section lang="fre">yeah</section> Il peut...
Element d'un document XML de presentation Exemple <BOLD>important</BOLD> => " important " ...
const std::string & getId() const
get the object id
Handler pour les elements de parsing de document structure.
virtual void handleProperty(const DocumentsReader::DocumentPropertyType &property, const std::string &data)=0
std::string limastring2utf8stdstring(const Lima::LimaString &phrase, uint32_t size0)
Convert a wide string to a string , in dest up to size bytes.
StorageType
a type meaning the storage type of an attribute
static const QString storageTypeTag[MAX_STORAGE_TYPE]
@ NODE_DISCARDABLE
root of XML file
@ NODE_PROPERTY
nodes which are not children of hierarchy nodes are ignored
NAUTITIA.
QString LimaString
Definition LimaString.h:33
STL namespace.