LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
SegmentationData.h
Go to the documentation of this file.
1// Copyright 2002-2020 CEA LIST
2// SPDX-FileCopyrightText: 2022 CEA LIST <gael.de-chalendar@cea.fr>
3//
4// SPDX-License-Identifier: MIT
5
6/************************************************************************
7 * @author besancon (besanconr@zoe.cea.fr)
8 * @date Tue Jan 18 2011
9 * @brief this class contains information about text segmentation
10 ***********************************************************************/
11
12#ifndef SEGMENTATIONDATA_H
13#define SEGMENTATIONDATA_H
14
18
19namespace Lima {
20namespace LinguisticProcessing {
21
23{
24public:
25 /* Segment(); */
26 explicit Segment(const std::string& type);
27
28 /* smart constructors: give them part of the information, and they complete it using the graph */
29 Segment(const std::string& type,
33 /* Segment(const std::string& type, */
34 /* uint64_t posBegin, */
35 /* uint64_t length, */
36 /* LinguisticAnalysisStructure::AnalysisGraph* graph); */
38 bool operator<(const Segment& s) const;
39
40 void addSegment(const Segment& s);
41
42 void setVerticesFromPositions(uint64_t posBegin,
43 uint64_t length,
45
46 /* no setters : use constructors */
49 /* void setPosBegin(uint64_t p) { m_posBegin=p; } */
50 void setLength(uint64_t l) { m_length=l; }
51 void setType(const std::string& type) { m_type=type; }
52
53 LinguisticGraphVertex getFirstVertex() const { return m_begin; }
54 LinguisticGraphVertex getLastVertex() const { return m_end; }
55 uint64_t getPosBegin() const { return m_posBegin; }
56 uint64_t getPosEnd() const { return m_posBegin+m_length; }
57 uint64_t getLength() const { return m_length; }
58 const std::string& getType() const { return m_type; }
59
60 LIMA_TEXTSEGMENTATION_EXPORT friend std::ostream& operator<<(std::ostream& os, const Segment& seg);
61 LIMA_TEXTSEGMENTATION_EXPORT friend QDebug& operator<<(QDebug& os, const Segment& seg);
62
63private:
64 LinguisticGraphVertex m_begin; /*< the vertex before the first vertex of the segment */
65 LinguisticGraphVertex m_end; /*< the vertex after the last vertex of the segment */
66 uint64_t m_posBegin;
67 uint64_t m_length;
68 std::string m_type;
69};
70
71// class to store segmentation data: a list of segments, defined by their position and length and a type
73{
74 public:
75 explicit SegmentationData(const std::string& sourceGraph="");
77
78 void add(const Segment& s);
79 const std::vector<Segment>& getSegments() const { return m_segments; }
80 std::vector<Segment>& getSegments() { return m_segments; }
81
82 inline const std::string& getGraphId() const { return m_graphId; }
83
84 private:
85 std::vector<Segment> m_segments;
86 std::string m_graphId;
87};
88
89
90} // end namespace
91} // end namespace
92
93#endif
QDebug & operator<<(QDebug &qd, const std::string &str)
Definition QsLog.cpp:39
LinguisticGraph::vertex_descriptor LinguisticGraphVertex
#define LIMA_TEXTSEGMENTATION_EXPORT
just for semantics: base class for analysisData
An AnalysisData containing a LinguisticGraph with a language and an id.
void setLastVertex(LinguisticGraphVertex v)
LinguisticGraphVertex getFirstVertex() const
void setFirstVertex(LinguisticGraphVertex v)
const std::string & getType() const
void setType(const std::string &type)
LinguisticGraphVertex getLastVertex() const
const std::vector< Segment > & getSegments() const
NAUTITIA.
static bool operator<(const QStringView &entityStr, const TextHtmlEntity &entity)