75 LINFO <<
"SentenceBoundariesTransfer::process start transfering sentence bounds from AnalysisGraph to PosGraph";
81 LERROR <<
"SentenceBoundariesTransfer::process no SentenceBounds";
84 if (sb->getGraphId() ==
"PosGraph")
87 LINFO <<
"SentenceBoundariesTransfer: sentence bounds are already on PosGraph. Nothing to do.";
91 auto anagraph = std::dynamic_pointer_cast<AnalysisGraph>(analysis.
getData(
"AnalysisGraph"));
92 if (anagraph ==
nullptr)
94 LERROR <<
"SentenceBoundariesTransfer::process no graph 'AnalysisGraph' available !";
97 auto posgraph = std::dynamic_pointer_cast<AnalysisGraph>(analysis.
getData(
"PosGraph"));
98 if (posgraph ==
nullptr)
100 LERROR <<
"SentenceBoundariesTransfer::process no graph 'PosGraph' available !";
103 auto annotationData = std::dynamic_pointer_cast< AnnotationData >(analysis.
getData(
"AnnotationData"));
104 if (annotationData ==
nullptr)
106 LERROR <<
"SentenceBoundariesTransfer::process: no annotation graph available !";
111 for (
const auto& segment: sb->getSegments())
113 auto firstVxMatches = annotationData->matches(
"AnalysisGraph",
114 segment.getFirstVertex(),
116 if (segment.getFirstVertex() == 0)
117 firstVxMatches.insert(0);
118 if (firstVxMatches.empty())
120 LERROR <<
"SentenceBoundariesTransfer::process: no PoS graph vertex for segment first AnalysisGraph vextex"
121 << segment.getFirstVertex();
124 auto lastVxMatches = annotationData->matches(
"AnalysisGraph",
125 segment.getLastVertex(),
127 if (segment.getFirstVertex() == 1)
128 firstVxMatches.insert(1);
129 if (lastVxMatches.empty())
131 LERROR <<
"SentenceBoundariesTransfer::process: no PoS graph vertex for segment last AnalysisGraph vextex"
132 << segment.getLastVertex();
135 Segment newSegment(
"sentence", *firstVxMatches.begin(), *lastVxMatches.begin(), posgraph.get());
136 newSb->add(newSegment);
140 analysis.
setData(
"SentenceBoundaries", newSb);
Holds all data that pass through the ProcessUnits Analysis data are shared pointers,...
void removeData(const QString &id)
remove the analysisData with the given id
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.