LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
mediaticData.h
Go to the documentation of this file.
1// Copyright 2002-2020 CEA LIST
2// SPDX-FileCopyrightText: 2022 CEA LIST <gael.de-chalendar@cea.fr>
3//
4// SPDX-License-Identifier: MIT
5
14#ifndef LIMA_COMMONS_MEDIATICDATA_H
15#define LIMA_COMMONS_MEDIATICDATA_H
16
17#include "common/LimaCommon.h"
22
24
25#include "mediaData.h"
26
27#include <cstdlib>
28#include <string>
29#include <map>
30#include <set>
31
32#define ENTITY_TYPE_NONE_STRING "NO_TYPE"
33#define ENTITY_TYPE_NONE 0
34
35namespace Lima
36{
37namespace Common
38{
39namespace MediaticData
40{
41#define ID_NONE 0
42#define SYMBOLIC_NONE "NONE"
43
44class MediaticDataPrivate;
45
53{
54
55 friend class Singleton<MediaticData>;
56
57public:
58
65 void init(
66 const std::string& resourcesPath,
67 const std::string& configPath,
68 const std::string& configFile,
69 const std::deque< std::string >& meds,
70 const std::map< std::string, std::string >& opts = {});
71
72 void initMedia(const std::string& media);
73
74 const FsaStringsPool& stringsPool(MediaId med) const;
75 FsaStringsPool& stringsPool(MediaId med);
76
77
78 /*********************************************************************
79 * Ids convertion functions
80 ********************************************************************/
81
82 const std::map< std::string, MediaId >& getMediasIds() const;
85 const std::string& getMediaId(MediaId idNum) const;
87 MediaId getMediaId(const std::string& stringId) const;
88
89 const std::string& media(MediaId media) const;
90 MediaId media(const std::string& media) const;
91
92 const std::deque<std::string>& getMedias() const;
93
94 const MediaData& mediaData(MediaId media) const;
95 const MediaData& mediaData(const std::string& med) const;
96 MediaData& mediaData(MediaId media);
97
99
100 EntityType getEntityType(const LimaString& entityName) const;
101 EntityType getEntityType(const LimaString& groupName,
102 const LimaString& entityName) const;
106 EntityType getEntityType(EntityGroupId groupId, const LimaString& entityName) const;
107 EntityGroupId getEntityGroupId(const LimaString& groupName) const;
108
109 //const LimaString& getEntityName(const EntityType& type) const;
110 //cannot return const ref : name is build from group name and entity name
111 LimaString getEntityName(const EntityType& type) const;
112 const LimaString& getEntityGroupName(EntityGroupId id) const;
113
114 EntityGroupId addEntityGroup(const LimaString& groupName);
115 EntityType addEntity(const LimaString& groupName, const LimaString& entityName);
116
117 // simple implementation of entity taxonomy: child-parent links
118 void addEntityParentLink(const EntityType& child, const EntityType& parent);
119 bool isEntityAncestor(const EntityType& child, const EntityType& parent) const;
120
121 //get highest ancestors in a group
122 std::vector<EntityType> getGroupAncestors(EntityGroupId id) const;
123
124 //get highest ancestor in the hierarchy
125 EntityType getEntityAncestor(const EntityType& child) const;
126
127 //get first ancestor in the hierarchy
128 EntityType getEntityParent(const EntityType& child) const;
129
130 // get the list of nodes under the given ancestor as child->firstParent tuples
131 bool getEntityChildList(const EntityType& parent,
132 std::map<EntityType,EntityType>& EntityTypeMapping) const;
133
134 // read/write function necessary because entity types
135 // are saved in temporary files
136 void writeEntityTypes(std::ostream& os) const;
137 void readEntityTypes(std::istream& os,
138 std::map<EntityGroupId,EntityGroupId>& EntityGroupIdMapping,
139 std::map<EntityType,EntityType>& EntityTypeMapping);
140
142
143 uint8_t getRelation(const std::string& relation) const ;
144 const std::string& getRelation(uint8_t relation) const ;
145
146 ConceptType getConceptType(const std::string& typeName) const;
147 const std::string& getConceptName(const ConceptType& typeName) const;
148
149 bool getOptionValue(const std::string& name, std::string& value) const;
150
151 /*********************************************************************
152 * Configuration functions
153 ********************************************************************/
154
155 bool releaseStringsPool() const;
156
157 const std::string& getResourcesPath() const;
158
159 const std::string& getConfigPath() const;
160
162 size_t getNbCategories() const;
163
164 virtual ~MediaticData();
165
166 virtual void initEntityTypes(XMLConfigurationFiles::XMLConfigurationFileParser& configParser);
167
168 const LimaString& getEntityTypeNameSeparator() const;
169
170private:
171 MediaticData();
172 MediaticData(const MediaticData& md) = delete;
173 MediaticData& operator=(const MediaticData& md) = delete;
174
176
177};
178
179
180} // closing namespace MediaticData
181} // closing namesapce Common
182} // closing namespace Lima
183
184
185#endif // LIMA_CONFIGURATION_MEDIATICDATA_H
#define LIMA_MEDIATICDATA_EXPORT
Definition LimaCommon.h:132
Holds mediatic data for one media.
Definition mediaData.h:50
holds data about codes and names for grammatical categories, etc.
Parser class for the lima's xml configuration files.
Defines access method for the singleton pattern.
Definition Singleton.h:22
NAUTITIA.
QString LimaString
Definition LimaString.h:33