30#include <QtCore/QDateTime>
44namespace LinguisticProcessing
71 m_outputSuffix=string(
".coref")+
".xml";
85 auto metadata = std::dynamic_pointer_cast<LinguisticMetaData>(analysis.
getData(
"LinguisticMetaData"));
89 LERROR <<
"no LinguisticMetaData ! abort";
93 string textFileName = metadata->getMetaData(
"FileName");
94 string outputFile = textFileName + m_outputSuffix;
95 ofstream out(outputFile.c_str(), std::ofstream::binary);
97 throw runtime_error(
"can't open file " + outputFile);
100 auto anagraph = std::dynamic_pointer_cast<AnalysisGraph>(analysis.
getData(
"PosGraph"));
104 LERROR <<
"no PosGraph ! abort";
109 dump(out, anagraph.get(),
110 std::dynamic_pointer_cast<AnnotationData>(analysis.
getData(
"AnnotationData")).get());
125 LDEBUG <<
"DumpXMLAnnotationVisitor::examine_edge";
129 boost::tie(it, it_end) = boost::out_edges(v,g);
148 boost::tie(it, it_end) = boost::out_edges(v,g);
159 std::set< AnnotationGraphVertex > matches = m_ad->
matches(
"PosGraph",v,
"annot");
163 LERROR <<
"DumpXMLAnnotationVisitor::examine_edge No annotation graph vertex matches PoS graph vertex " << v <<
". This should not happen.";
179 catch (
const boost::bad_any_cast& )
182 LERROR <<
"non coreferent annotation";
192 if (s.substr(0,2) ==
"s'")
197 s = s.substr(2,s.size());
233 boost::tie(it, it_end) = boost::in_edges(vProcessed,g);
239 && (vProcessed != vNotProcessed)
243 && source(refEdge,g)==source(currentEdge,g))
251 vProcessed = source(*it,g);
253 vNotProcessed = source(currentEdge,g);
254 boost::tie(it, it_end) = boost::in_edges(vNotProcessed,g);
270 if (m_outputSuffix ==
".wh.xml")
272 xmlStream <<
"<?xml version='1.0' standalone='no'?>" << std::endl;
273 xmlStream <<
"<!--generated by Amose on ";
274 xmlStream << QDateTime::currentDateTime().toString().toUtf8().data();
275 xmlStream <<
"-->" << std::endl;
276 xmlStream <<
"<!DOCTYPE COREF SYSTEM \"coref.dtd\">" << std::endl;
277 xmlStream << std::endl;
278 xmlStream <<
"<TEXT>" << std::endl;
284 xmlStream << std::endl << std::endl <<
"</TEXT>" << std::endl;
AgglutinatedToken is a fulltoken that is a agglutinated compound word.
This file is the main header file for the data related to annotation graphs.
xml logger for coreferences
#define COREFSOLVINGXMLLOGGER_CLASSID
DependencyGraph::edge_descriptor DependencyGraphEdge
typedefs to simplify the acces to various graphs elements
LinguisticGraph::in_edge_iterator LinguisticGraphInEdgeIt
boost::graph_traits< LinguisticGraph >::edge_descriptor LinguisticGraphEdge
typedefs to simplify the access to various graphs elements
LinguisticGraph::vertex_descriptor LinguisticGraphVertex
LinguisticGraph::out_edge_iterator LinguisticGraphOutEdgeIt
boost::adjacency_list< boost::vecS, boost::vecS, boost::bidirectionalS, LinguisticVertexProperties > LinguisticGraph
Property to identify the chains in the graph.
#define COREFSOLVERLOGINIT
Defines a Factory to create Object of type Base.
Data used for the syntactic analyzis of texts.
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
Holds an annotation graph and gives an API to manipulate it.
std::set< AnnotationGraphVertex > matches(const std::string &first, AnnotationGraphVertex firstVx, const std::string &second) const
Gets the set of vertices matched in the second graph by the given vertex of the first graph.
const GenericAnnotation & annotation(AnnotationGraphVertex v1, AnnotationGraphVertex v2, const LimaString &annot) const
This class allows to convert any object into an annotation by inheritance.
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.
const InitializationParameters & getInitializationParameters() const
get Initialization Parameters
A generic process unit to log information in files: contains some common informations such as : outpu...
virtual 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.
void init(Common::XMLConfigurationFiles::GroupConfigurationStructure &unitConfiguration, Manager *manager) override
initialize with parameters from configuration file.
virtual ~CorefSolvingXmlLogger()
virtual void outputXml(std::ostream &xmlStream, const LinguisticGraph &g, const Common::AnnotationGraphs::AnnotationData *ad) const
void examine_edge(LinguisticGraphEdge e, const LinguisticGraph &g)
bool are_equivalent(LinguisticGraphEdge currentEdge, LinguisticGraphVertex vProcessed, LinguisticGraphVertex vNotProcessed, const LinguisticGraph &g)
An AnalysisData containing a LinguisticGraph with a language and an id.
const LinguisticGraph * getGraph(void) const
Returns the underlying graph structure.
const LinguisticGraphVertex & firstVertex(void) const
Returns the first vertex of the graph.
bool isAlphaPossessive() const
holds surface data of a token
const TStatus & status() const
const LimaString & stringForm() const
static void logElapsedTime(const std::string &mess, const std::string &taskCategory=std::string(""))
log the number of microseconds since last UpdateCurrentTime
static void updateCurrentTime(const std::string &taskCategory=std::string(""))
store current time for new elapsed time computation
AnnotationGraph::vertex_descriptor AnnotationGraphVertex
bool hasAnnotation(AnnotationGraphVertex v, const LimaString &annot) const
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, CorefSolvingXmlLogger > fullTokenXmlLoggerFactory(COREFSOLVINGXMLLOGGER_CLASSID)
launch exception related to the configuration file parsing