LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
BratJSONDumper.h
Go to the documentation of this file.
1// Copyright (C) 2004-2012 by CEA LIST *
2// SPDX-FileCopyrightText: 2022 CEA LIST <gael.de-chalendar@cea.fr>
3//
4// SPDX-License-Identifier: MIT
5
6#ifndef BRATJSONDUMPERBRATDUMPER_H
7#define BRATJSONDUMPERBRATDUMPER_H
8
10
11namespace Lima {
12namespace LinguisticProcessing {
13namespace AnalysisDumpers {
14
15#define BRATJSONDUMPER_CLASSID "BratJSONDumper"
16
17// output results in JSON compatible with the embedded Brat
18// see docData in https://brat.nlplab.org/embed.html
20{
21public:
23 virtual ~BratJSONDumper();
24
26 Manager* manager) override;
27
28 void outputGlobalHeader(std::ostream& os, const std::string& sourceFile="",
29 const LimaStringText& originalText=LimaStringText("")) const override;
30 void outputGlobalFooter(std::ostream& os) const override;
31 void outputEntitiesHeader(std::ostream& os) const override;
32 void outputEntitiesFooter(std::ostream& os) const override;
33 void outputRelationsHeader(std::ostream& os) const override;
34 void outputRelationsFooter(std::ostream& os) const override;
35 void outputEventsHeader(std::ostream& os) const override;
36 void outputEventsFooter(std::ostream& os) const override;
37
38 void outputEntityString(std::ostream& out,
39 unsigned int entityId,
40 const std::string& entityType,
41 const std::string& entityString,
42 const std::vector<std::pair<uint64_t,uint64_t> >& positions,
43 const Automaton::EntityFeatures& entityFeatures,
44 bool noNorm=false) const override;
45
46 void outputAttributesString(std::ostream& out,
47 unsigned int entityId,
48 std::map <std::tuple <std::size_t, std::string , std::string >, std::size_t >& mapAttributes) const override;
49
50 unsigned int outputRelationString(std::ostream& out,
51 unsigned int relationId,
52 const std::string& relationType,
53 const std::string& sourceArgString,
54 const std::string& targetArgString) const override;
55
56 void outputEventString(std::ostream& out,
57 unsigned int eventId,
58 unsigned int eventMentionId,
59 const std::string& eventMentionType,
60 const std::vector<unsigned int>& eventRoleId,
61 const std::vector<std::string>& eventRoleType) const override;
62
63 void outputEntityNorm(std::ostream& out,
64 unsigned int entityId,
65 const std::string& entityNorm) const override;
66
67
68 // add event mention as a separate entity
69 //bool addEventMentionAsEntity() const override { return true; }
70 bool addEventMentionAsEntity() const override { return false; }
71
72private:
73 bool m_useNormalizedForms; //<! output normalized forms in brat format
74 // set members mutable (modified in the inherited const functions)
75// mutable bool m_firstEntity;
76 mutable bool m_firstRelation;
77 mutable bool m_firstEvent;
78 // attributes and norms are printed with the entities in AbstractIEDumper: need them to be printed
79 // separately in JSON: store them to print them at the end (could do that with all -> better ?)
80 mutable std::vector<std::string> m_attributes;
81 mutable std::vector<std::string> m_norms;
82 // event triggers are different from the entities: same format but stored associated with a 'triggers' key
83 // have to wait until the events to choose where to put them, store them until that point
84 mutable std::map<unsigned int,std::string> m_entities;
85 mutable std::vector<std::string> m_eventTriggers;
86};
87
88} // AnalysisDumpers
89} // LinguisticProcessing
90} // Lima
91
92#endif
#define LIMA_ANALYSISDUMPERS_EXPORT
Manage initialization of InitializableObjects using configuration module and parameters.
a list of generic features: each feature is unique (only one feature for a name)
define the limaStringText resource which is the text in limaString formal
NAUTITIA.