25namespace LinguisticProcessing {
26namespace LinguisticAnalysisStructure {
35 m_forbidBoundaryValues(),
53 MediaId language=manager->getInitializationParameters().media;
61 m_graph=string(
"PosGraph");
70 m_data=string(
"SentenceBoundaries");
76 for (deque<string>::const_iterator it=boundariesRestrictions.begin(),it_end=boundariesRestrictions.end();
80 LDEBUG <<
"init(): add filter for value " << *it;
90 deque<string> exclBoundariesRestrictions=unitConfiguration.
getListsValueAtKey(
"forbid-values");
91 for (deque<string>::const_iterator it=exclBoundariesRestrictions.begin(),it_end=exclBoundariesRestrictions.end();
95 LDEBUG <<
"init(): add filter for forbidden value " << *it;
108 for (deque<string>::const_iterator it=boundariesRestrictions.begin(),it_end=boundariesRestrictions.end();
114 LERROR <<
"init(): cannot find linguistic code for micro " << *it;
119 LDEBUG <<
"init(): add filter for micro " << micro;
121 m_boundaryMicros.push_back(micro);
127 LERROR <<
"Warning: No boundaries categories defined for language " << language;
139 LINFO <<
"start finding sentence bounds";
140 auto anagraph = std::dynamic_pointer_cast<AnalysisGraph>(analysis.
getData(m_graph));
143 LERROR <<
"no graph '" << m_graph <<
"' available !";
150 LDEBUG <<
"found beginSentence at " << beginSentence;
156 if (m_boundaryValues.empty() && m_forbidBoundaryValues.empty())
158 while (beginSentence!=lastVx)
160 LinguisticGraphVertex endSentence=anagraph->nextMainPathVertex(beginSentence,*m_microAccessor,m_boundaryMicros,lastVx);
161 if (endSentence == lastVx)
163 set<LinguisticGraphVertex> prevVx = getPrecedingNodes<set<LinguisticGraphVertex>>(*anagraph, lastVx);
170 if (beginSentence != endSentence && prevVx.end() == prevVx.find(beginSentence))
172 sb->
add(
Segment(
"sentence",beginSentence,endSentence,anagraph.get()));
177 LDEBUG <<
"found endSentence at " << endSentence;
179 sb->
add(
Segment(
"sentence",beginSentence,endSentence,anagraph.get()));
180 beginSentence=endSentence;
188 LinguisticGraphVertex endSentence=anagraph->nextMainPathVertex(beginSentence,*m_microAccessor,m_boundaryMicros,lastVx);
189 while (endSentence!=lastVx)
195 LDEBUG <<
"found endSentence at " << endSentence <<
"("
200 LDEBUG <<
"found endSentence at " << endSentence;
204 if (t==0 || (!m_forbidBoundaryValues.empty() && m_forbidBoundaryValues.find(t->
stringForm())!=m_forbidBoundaryValues.end()) )
207 LDEBUG <<
" -> not kept (bcz in forbidden values)";
210 else if (t==0 || (!m_boundaryValues.empty() && m_boundaryValues.find(t->
stringForm())==m_boundaryValues.end()) )
213 LDEBUG <<
" -> not kept (bcz not in restricted values)";
219 LDEBUG <<
"add sentence " << beginSentence <<
"-" << endSentence;
221 sb->
add(
Segment(
"sentence",beginSentence,endSentence,anagraph.get()));
222 beginSentence=endSentence;
224 endSentence=anagraph->nextMainPathVertex(endSentence,*m_microAccessor,m_boundaryMicros,lastVx);
227 if(beginSentence<endSentence) {
229 LDEBUG <<
"add last sentence " << beginSentence <<
"-" << endSentence;
231 sb->
add(
Segment(
"sentence",beginSentence,endSentence,anagraph.get()));
LinguisticGraph::vertex_descriptor LinguisticGraphVertex
#define SENTENCEBOUNDARIESFINDER_CLASSID
Defines a Factory to create Object of type Base.
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.
Provide tools to manage a specific property.
LinguisticCode getPropertyValue(const std::string &symbolicValue) const
Get the coded property value from the symbolic value.
std::string & getParamsValueAtKey(const std::string &key)
std::deque< std::string > & getListsValueAtKey(const std::string &key)
return a message when a 'list' was not found
return a message when a 'param' was not found
LimaStatusCode process(AnalysisContent &analysis) const override
Process on data in analysisContent.
SentenceBoundariesFinder()
void init(Common::XMLConfigurationFiles::GroupConfigurationStructure &unitConfiguration, Manager *manager) override
initialize with parameters from configuration file.
virtual ~SentenceBoundariesFinder()
holds surface data of a token
const LimaString & stringForm() const
void add(const Segment &s)
static const MediaticData & single()
const singleton accessor
This file contains a class to control log of informations about time, such as logging cumulated time ...
std::string limastring2utf8stdstring(const Lima::LimaString &phrase, uint32_t size0)
Convert a wide string to a string , in dest up to size bytes.
LimaString utf8stdstring2limastring(const std::string &src)
SimpleFactory< MediaProcessUnit, SentenceBoundariesFinder > sentenceBoundariesFinderFactory(SENTENCEBOUNDARIESFINDER_CLASSID)
launch exception related to the configuration file parsing