21 #ifndef DOXYGEN_SHOULD_SKIP_THIS 30 template <
typename GUM_SCALAR >
33 const std::string& filePath) :
34 BNReader< GUM_SCALAR >(bn, filePath) {
43 template <
typename GUM_SCALAR >
54 template <
typename GUM_SCALAR >
58 std::string status =
"Loading File ...";
64 if (xmlDoc.NoChildren()) {
66 ": Loading fail, please check the file for any syntax error.");
70 status =
"File loaded. Now looking for BIF element ...";
76 status =
"BIF Element reached. Now searching network ...";
82 status =
"Network found. Now proceedind variables instanciation...";
88 status =
"All variables have been instancied. Now filling up diagram...";
93 status =
"Instanciation of network completed";
103 template <
typename GUM_SCALAR >
110 for (varIte = varIte.begin(parentNetwork); varIte != varIte.end(); ++varIte)
116 for (varIte = varIte.begin(parentNetwork); varIte != varIte.end(); ++varIte) {
128 auto newVar =
new LabelizedVariable(varName, varDescription, 0);
133 for (varOutComesIte = varOutComesIte.begin(currentVar);
134 varOutComesIte != varOutComesIte.end();
136 newVar->addLabel(varOutComesIte->GetTextOrDefault(
""));
144 "Network found. Now proceedind variables instanciation...";
145 int progress = (int)((
float)nbIte / (float)nbVar * 45) + 10;
151 template <
typename GUM_SCALAR >
157 for (definitionIte = definitionIte.begin(parentNetwork);
158 definitionIte != definitionIte.end();
165 for (definitionIte = definitionIte.begin(parentNetwork);
166 definitionIte != definitionIte.end();
171 std::string currentVarName =
173 NodeId currentVarId =
__bn->idFromName(currentVarName);
177 List< NodeId > parentList;
179 for (givenIte = givenIte.begin(currentVar); givenIte != givenIte.end();
181 std::string parentNode = givenIte->GetTextOrDefault(
"");
182 NodeId parentId =
__bn->idFromName(parentNode);
183 parentList.pushBack(parentId);
187 parentListIte != parentList.rendSafe();
189 __bn->addArc(*parentListIte, currentVarId);
194 std::list< GUM_SCALAR > tablelist;
197 while (!issTableString.eof()) {
198 issTableString >> value;
199 tablelist.push_back(value);
202 std::vector< GUM_SCALAR > tablevector(tablelist.begin(), tablelist.end());
205 __bn->cpt(currentVarId).fillWith(tablevector);
209 "All variables have been instancied. Now filling up diagram...";
210 int progress = (int)((
float)nbIte / (float)nbDef * 45) + 55;
218 #endif // DOXYGEN_SHOULD_SKIP_THIS void __parsingVariables(ticpp::Element *parentNetwork)
Parsing xml element containing data on variables.
Wrapper around TiXmlElement.
std::string GetTextOrDefault(const std::string &defaultValue) const
Gets the text of an Element, if it doesn't exist it will return the defaultValue. ...
BayesNet< GUM_SCALAR > * __bn
An handle to the bayes net in which will be load the content of the xml filePath. ...
std::string __filePath
the path to the xml filePath
ListIteratorSafe< Val > iterator_safe
Types for STL compliance.
classe for import of bayes net from a XML file written with BIF Format
gum is the global namespace for all aGrUM entities
void __fillingBN(ticpp::Element *parentNetwork)
fill the diagram
const char * what() const
Override std::exception::what() to return m_details.
This is a ticpp exception class.
#define GUM_EMIT2(signal, arg1, arg2)
gum::Signaler2< int, std::string > onProceed
Signaler used to indicates how many percent of the Xml files have been parsed yet.
Size proceed() final
Reads the bayes net from the file referenced by filePath given at the creation of class...
Wrapper around TiXmlDocument.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Element * FirstChildElement(bool throwIfNoChildren=true) const
The first child element of this node.
Iterator for conveniently stepping through Nodes and Attributes.
BIFXMLBNReader(BayesNet< GUM_SCALAR > *bn, const std::string &filePath)
Constructor A reader is created to reading a defined file.
Size NodeId
Type for node ids.
~BIFXMLBNReader() final
Default destructor.
#define GUM_ERROR(type, msg)