19#include <QXmlStreamReader>
25namespace LinguisticProcessing {
37 bool parse(QIODevice *device);
40 QString errorString()
const;
68 m_graphName(
"AnalysisGraph"),
69 m_dataName(
"segmentationData")
95 auto graph = std::dynamic_pointer_cast<AnalysisGraph>(analysis.
getData(m_d->
m_graphName.toStdString()));
114 if (segmData ==
nullptr)
117 LERROR <<
"data "<< data.get() <<
" is not an object of class SegmentationData";
125 QFile file(filename);
126 if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
128 "Cannot open" << filename,
130 if (!m_d->
parse(&file))
158 LTRACE <<
"SegmentationResultsLoaderPrivate::readResults";
161 while (
m_reader.readNextStartElement())
163 if (
m_reader.name() == QLatin1String(
"segment"))
171 else if (
m_reader.name().toString() ==
"position")
176 m_reader.raiseError(QObject::tr(
"Cannot convert position value %1 to int.").arg(
m_reader.text()));
179 else if (
m_reader.name().toString() ==
"length")
184 m_reader.raiseError(QObject::tr(
"Cannot convert length value %1 to int.").arg(
m_reader.text()));
187 else if (
m_reader.name().toString() ==
"type")
201 auto errorStr = QObject::tr(
"%1, Line %2, column %3")
#define LIMA_EXCEPTION_SELECT_LOGINIT(X, Y, Z)
This macro writes the message Y to the error stream configured by its first parameter X,...
#define SEGMENTATIONRESULTSLOADER_CLASSID
Defines a Factory to create Object of type Base.
#define LIMA_TEXTSEGMENTATION_EXPORT
Holds all data that pass through the ProcessUnits Analysis data are shared pointers,...
std::shared_ptr< AnalysisData > getData(const QString &id)
return AnalysisData by id
void setData(const QString &id, std::shared_ptr< AnalysisData > data)
set an analysisData with the given id.
std::string & getParamsValueAtKey(const std::string &key)
return a message when a 'param' was not found
Manage initialization of InitializableObjects using configuration module and parameters.
void init(Common::XMLConfigurationFiles::GroupConfigurationStructure &unitConfiguration, Manager *manager) override
initialize with parameters from configuration file.
QString getInputFile(AnalysisContent &analysis) const
An AnalysisData containing a LinguisticGraph with a language and an id.
void setVerticesFromPositions(uint64_t posBegin, uint64_t length, LinguisticAnalysisStructure::AnalysisGraph *anagraph)
void add(const Segment &s)
LinguisticAnalysisStructure::AnalysisGraph * m_graph
QString errorString() const
QXmlStreamReader m_reader
SegmentationResultsLoaderPrivate()
bool parse(QIODevice *device)
~SegmentationResultsLoaderPrivate()=default
SegmentationData * m_data
SegmentationResultsLoader()
virtual ~SegmentationResultsLoader()
void init(Common::XMLConfigurationFiles::GroupConfigurationStructure &unitConfiguration, Manager *manager) override
initialize with parameters from configuration file.
LimaStatusCode process(AnalysisContent &analysis) const override
Process on data in analysisContent.
Throw this exception when encountering problems with XML files opening or parsing.
SimpleFactory< MediaProcessUnit, SegmentationResultsLoader > SegmentationResultsLoaderFactory(SEGMENTATIONRESULTSLOADER_CLASSID)