87 LINFO <<
"start finding paragraph founds";
92 auto graph = std::dynamic_pointer_cast<AnalysisGraph>(analysis.
getData(m_graph));
94 LERROR <<
"no graph '" << m_graph <<
"' available !";
98 analysis.
setData(m_dataName,boundaries);
100 auto text = std::dynamic_pointer_cast<LimaStringText>(analysis.
getData(
"Text"));
102 std::vector<uint64_t> paragraphPositions;
104 int i=text->indexOf(m_paragraphSeparator,currentPos);
106 paragraphPositions.push_back((uint64_t)i);
108 currentPos=text->indexOf(QRegularExpression(QString(QLatin1String(
"[^%1]")).arg(m_paragraphSeparator)),i+1);
109 i=text->indexOf(m_paragraphSeparator,currentPos);
112 if (paragraphPositions.empty()) {
113 LWARN <<
"no paragraph found";
119 std::deque<LinguisticGraphVertex> toVisit;
120 std::set<LinguisticGraphVertex> visited;
124 toVisit.push_back(graph->firstVertex());
125 visited.insert(graph->firstVertex());
127 while (!toVisit.empty())
132 if (currentVertex == graph->lastVertex()) {
136 if (currentVertex != graph->firstVertex()) {
139 if (position >= (paragraphPositions[parNum]+1)) {
142 boost::tie(inEdge,inEdge_end)=in_edges(currentVertex,*(graph->getGraph()));
144 if (beginParagraph!=prevVertex) {
145 boundaries->
add(
Segment(
"paragraph", beginParagraph, prevVertex, graph.get()));
147 beginParagraph=prevVertex;
151 if (parNum >= paragraphPositions.size()) {
159 boost::tie(outEdge,outEdge_end)=out_edges(currentVertex,*(graph->getGraph()));
161 for (; outEdge!=outEdge_end; outEdge++) {
163 if (visited.find(next)==visited.end()) {
164 toVisit.push_back(next);
165 visited.insert(next);
171 if (beginParagraph!=graph->lastVertex()) {
172 boundaries->
add(
Segment(
"paragraph", beginParagraph, graph->lastVertex(), graph.get()));
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.