39 const uint64_t position=0,
40 const uint64_t length=0,
44 const std::vector<uint64_t>& structure,
45 const std::vector<uint64_t>& relations,
61 std::vector<uint64_t> m_structure;
62 std::vector<uint64_t> m_relations;
66IndexElementPrivate::IndexElementPrivate():
83m_category(iep.m_category),
84m_position(iep.m_position),
85m_length(iep.m_length),
86m_neType(iep.m_neType),
87m_poslenlist(iep.m_poslenlist),
88m_structure(iep.m_structure),
89m_relations(iep.m_relations)
93IndexElementPrivate::IndexElementPrivate(
98 const uint64_t position,
99 const uint64_t length,
108m_poslenlist(1,
std::make_pair(
116IndexElementPrivate::IndexElementPrivate(
119 const std::vector<uint64_t>& structure,
120 const std::vector<uint64_t>& relations,
129m_structure(structure),
130m_relations(relations)
142 m_category = iep.m_category;
143 m_position = iep.m_position;
144 m_length = iep.m_length;
145 m_neType = iep.m_neType;
146 m_poslenlist = iep.m_poslenlist;
147 m_structure = iep.m_structure;
148 m_relations = iep.m_relations;
164 const uint64_t position,
165 const uint64_t length,
174 const std::vector<uint64_t>& structure,
175 const std::vector<uint64_t>& relations,
203 m_d->m_type==other.m_d->m_type &&
209 m_d->m_type==other.m_d->m_type &&
259 const std::vector<uint64_t>& r)
260 { m_d->m_structure=s; m_d->m_relations=r; }
263 { m_d->m_structure.push_back(
id); m_d->m_relations.push_back(rel); }
288 return ( ( (m_d->m_position<=other.
getPosition()) && (other.
getPosition() < m_d->m_position+m_d->m_length) )
300 Position posMin = pplIt->first;
301 Position posMax =
static_cast<Position
>(posMin + pplIt->second - 1);
304 if( pplIt->first < posMin )
306 posMin = pplIt->first;
308 if( (pplIt->first+pplIt->second - 1) > posMax )
310 posMax = pplIt->first+pplIt->second - 1;
317 Position otherPosMax =
static_cast<Position
>(otherPosMin +
getPositionLengthList().back().second - 1);
320 if( otherPplIt->first < otherPosMin )
322 otherPosMin = otherPplIt->first;
324 if( (otherPplIt->first+otherPplIt->second - 1) > otherPosMax )
326 otherPosMax = otherPplIt->first+otherPplIt->second - 1;
331 return( ( (posMin <= otherPosMin) && (otherPosMin < posMax) )
332 || ( (otherPosMin <= posMin) && (posMin < otherPosMax) ) );
339 os <<
"[IndexElement" << elt.m_d->m_id <<
"," << elt.m_d->m_type ;
343 if (elt.m_d->m_category !=
L_NONE)
345 os <<
"/" << elt.m_d->m_category.
toString();
347 os <<
"/" << elt.m_d->m_position;
348 os <<
"," << elt.m_d->m_length;
352 if (elt.m_d->m_structure.empty())
359 os <<
":" << elt.m_d->m_structure[i] <<
" RE(" << elt.m_d->m_relations[i] <<
")";
361 while (i<elt.m_d->m_structure.size())
363 os <<
"," << elt.m_d->m_structure[i] <<
" RE(" << elt.m_d->m_relations[i] <<
")";
368 ::operator<<(os,elt.m_d->m_poslenlist);
370 if (! elt.m_d->m_neType.
isNull())
380 os <<
"[IndexElement" << elt.m_d->m_id <<
"," << elt.m_d->m_type;
381 os <<
":" << elt.m_d->m_word;
382 if (elt.m_d->m_category !=
L_NONE)
384 os <<
"/" << elt.m_d->m_category.
toString();
386 os <<
"/" << elt.m_d->m_position;
387 os <<
"," << elt.m_d->m_length;
388 if (!elt.m_d->m_structure.empty())
391 os <<
":" << elt.m_d->m_structure[i] <<
" RE(" << elt.m_d->m_relations[i] <<
")";
393 while (i<elt.m_d->m_structure.size())
395 os <<
"," << elt.m_d->m_structure[i] <<
" RE(" << elt.m_d->m_relations[i] <<
")";
399 os <<
"/" << elt.m_d->m_poslenlist;
414 os <<
"[IndexElement" << elt.m_d->m_id <<
"," << elt.m_d->m_type;
417 os <<
":" << elt.m_d->m_word;
418 if (elt.m_d->m_category !=
L_NONE)
420 os <<
"/" << elt.m_d->m_category.
toString().c_str();
422 os <<
"/" << elt.m_d->m_position;
423 os <<
"," << elt.m_d->m_length;
427 if (elt.m_d->m_structure.empty())
431 if (!elt.m_d->m_structure.empty())
434 os <<
":" << elt.m_d->m_structure[i] <<
" RE(" << elt.m_d->m_relations[i] <<
")";
436 while (i<elt.m_d->m_structure.size())
438 os <<
"," << elt.m_d->m_structure[i] <<
" RE(" << elt.m_d->m_relations[i] <<
")";
443 ::operator<<(os,elt.m_d->m_poslenlist);
445 if (! elt.m_d->m_neType.
isNull())
friend std::ostream & operator<<(std::ostream &os, const IndexElement &elt)
Represent an element of an index If it is a predicate, its simple term is "PredicateElement" and its ...
uint64_t getLength() const
void addInStructure(uint64_t id, uint64_t rel)
uint64_t getPosition() const
bool operator==(const IndexElement &other) const
equality operator just compare content, not positions
Lima::Common::BagOfWords::BoWType getType() const
void setId(const uint64_t id)
const std::vector< uint64_t > & getStructure() const
void setCategory(LinguisticCode category)
void setSimpleTerm(const LimaString &t)
bool isNamedEntity() const
LinguisticCode getCategory() const
bool hasSamePosition(const IndexElement &other) const
compare position and length
bool isSimpleTerm() const
const std::vector< uint64_t > & getRelations() const
const LimaString & getSimpleTerm() const
bool hasNearlySamePosition(const IndexElement &other) const
compare position and length: thereis some intersaction in position
bool isComposedTerm() const
Lima::Common::Misc::PositionLengthList & getPositionLengthList()
const Common::MediaticData::EntityType & getNamedEntityType() const
IndexElement & operator=(const IndexElement &)
void setStructure(const std::vector< uint64_t > &s, const std::vector< uint64_t > &r)
std::string toString() const
static const MediaticData & single()
const singleton accessor
BoWType
enum to characterize the type of the AbstractBoWElement
@ BOW_NOTYPE
the AbstractBoWElement is an abstract one that should not be instanciated
@ BOW_TERM
the AbstractBoWElement is a multi-term
@ BOW_NAMEDENTITY
the AbstractBoWElement is a named entity
@ BOW_TOKEN
the AbstractBoWElement is a simple token
@ BOW_PREDICATE
the AbstractBoWElement is a predicate (n-ary relation, template or semantic frame
T & operator<<(T &qd, const BoWType &bt)
std::vector< std::pair< Position, Length > > PositionLengthList
std::string limastring2utf8stdstring(const Lima::LimaString &phrase, uint32_t size0)
Convert a wide string to a string , in dest up to size bytes.