![]() |
aGrUM 3.0.0
a C++ library for (probabilistic) graphical models
|
Reads a MarkovRandomField from a GUM (json) file. More...
#include <agrum/MRF/io/GUM/GumMRFReader.h>
Public Member Functions | |
| GumMRFReader (MarkovRandomField< GUM_SCALAR > *mrf, std::string_view filename, bool binary=false) | |
| Constructor. | |
| GumMRFReader (MarkovRandomField< GUM_SCALAR > *mrf) | |
| Constructor for string-based parsing only (no file). Use exclusively with proceedFromString(); calling proceed() will fail. | |
| ~GumMRFReader () override | |
| Size | proceed () override |
| Parses the file and populates the MarkovRandomField. | |
| Size | proceedFromString (std::string_view content) |
| Parse a jgum JSON string directly (no file I/O). | |
| void | showElegantErrorsAndWarnings (std::ostream &stream=std::cerr) const |
| void | showErrorCounts (std::ostream &stream=std::cerr) const |
Accessors / Modifiers | |
| void | add (ParseError error) |
| Add an error object to the container. | |
| ParseError | error (Idx i) const |
| Returns the i-th error. | |
| ParseError | last () const |
| Returns the last added error. | |
| void | addError (std::string_view msg, std::string_view filename, Idx line, Idx col) |
| Adds an error. | |
| void | addWarning (std::string_view msg, std::string_view filename, Idx line, Idx col) |
| Adds a warning. | |
| void | addException (std::string_view msg, std::string_view filename) |
| Add an exception. | |
| Size | count () const |
| Returns the number of errors and warnings. | |
| void | syntheticResults (std::ostream &o) const |
| Print errors on output stream. | |
| void | simpleErrors (std::ostream &o) const |
| Print errors on output stream. | |
| void | simpleErrorsAndWarnings (std::ostream &o) const |
| Print errors on output stream. | |
| void | elegantErrors (std::ostream &o) const |
| Print errors on output stream. | |
| void | elegantErrorsAndWarnings (std::ostream &o) const |
| Print errors on output stream. | |
Coco/R helpers | |
| void | Error (const std::wstring &filename, Idx line, Idx col, const wchar_t *msg) |
| For adding errors. | |
| void | Warning (const std::wstring &filename, Idx line, Idx col, const wchar_t *msg) |
| For adding warnings. | |
| void | Exception (const std::wstring &filename, const wchar_t *msg) |
| For adding exceptions. | |
Class operators | |
| ErrorsContainer | operator+ (const ErrorsContainer &cont) const |
| Return the sum of two gum::ErrorsContainer. | |
| ErrorsContainer | operator+= (const ErrorsContainer &cont) |
| Add the content of a gum::ErrorsContainer to this gum::ErrorsContainer. | |
Public Attributes | |
| Size | error_count |
| Number of errors detected. | |
| Size | warning_count |
Private Member Functions | |
| template<typename JsonType> | |
| Size | _proceedFromJson_ (const JsonType &content) |
Private Attributes | |
| MarkovRandomField< GUM_SCALAR > * | _mrf_ |
| std::string | _streamName_ |
| bool | _parseDone_ |
| bool | _binary_ |
| std::vector< ParseError > | errors |
| The list of gum::ParseError contained in this gum::ErrorsContainer. | |
Reads a MarkovRandomField from a GUM (json) file.
Factors are expected as inline objects {"vars": [...], "values": [...]}. Supports both text (.jgum) and binary msgpack (.bgum) formats.
Definition at line 70 of file GumMRFReader.h.
| gum::GumMRFReader< GUM_SCALAR >::GumMRFReader | ( | MarkovRandomField< GUM_SCALAR > * | mrf, |
| std::string_view | filename, | ||
| bool | binary = false ) |
Constructor.
| mrf | The MarkovRandomField to populate. |
| filename | Path to the file to read. |
| binary | If true, the file is in msgpack binary format. |
|
explicit |
Constructor for string-based parsing only (no file). Use exclusively with proceedFromString(); calling proceed() will fail.
|
override |
|
private |
|
inherited |
Add an error object to the container.
| error | The gum::ParseError to add. |
Definition at line 74 of file errorsContainer_inl.h.
References error(), error_count, errors, and warning_count.
Referenced by addError(), addException(), addWarning(), Error(), Exception(), and Warning().
|
inherited |
Adds an error.
| msg | The error's message. |
| filename | The error's file. |
| line | The error's line. |
| col | The error's column. |
Definition at line 82 of file errorsContainer_inl.h.
References add().
|
inherited |
Add an exception.
| msg | The exception's message. |
| filename | The exception's file. |
Definition at line 98 of file errorsContainer_inl.h.
References add().
|
inherited |
Adds a warning.
| msg | The warning's message. |
| filename | The warning's file. |
| line | The warning's line. |
| col | The warning's column. |
Definition at line 90 of file errorsContainer_inl.h.
References add().
|
inherited |
Returns the number of errors and warnings.
Definition at line 103 of file errorsContainer_inl.h.
References error_count, and warning_count.
|
inherited |
Print errors on output stream.
| o | The output strem to send results. |
|
inherited |
Print errors on output stream.
| o | The output strem to send results. |
|
inherited |
For adding errors.
| filename | The error's file. |
| line | The error's line. |
| col | The error's column. |
| msg | The error's message. |
Definition at line 56 of file errorsContainer_inl.h.
References add(), and narrow().
|
inherited |
Returns the i-th error.
| i | The error to return. |
| OutOfBounds | Raised if there is less than i errors. |
Referenced by ErrorsContainer(), and add().
|
inherited |
For adding exceptions.
| filename | The exception's file. |
| msg | The exception's message. |
Definition at line 69 of file errorsContainer_inl.h.
References add(), and narrow().
|
inherited |
Returns the last added error.
| OutOfBounds | Raised if is no error to return. |
|
inherited |
Return the sum of two gum::ErrorsContainer.
| cont | The gum::ErrorsContainer to add. |
References ErrorsContainer().
|
inherited |
Add the content of a gum::ErrorsContainer to this gum::ErrorsContainer.
| cont | The gum::ErrorsContainer to add to this. |
References ErrorsContainer().
|
override |
Parses the file and populates the MarkovRandomField.
| Size gum::GumMRFReader< GUM_SCALAR >::proceedFromString | ( | std::string_view | content | ) |
Parse a jgum JSON string directly (no file I/O).
| void gum::GumMRFReader< GUM_SCALAR >::showElegantErrorsAndWarnings | ( | std::ostream & | stream = std::cerr | ) | const |
| void gum::GumMRFReader< GUM_SCALAR >::showErrorCounts | ( | std::ostream & | stream = std::cerr | ) | const |
|
inherited |
Print errors on output stream.
| o | The output strem to send results. |
|
inherited |
Print errors on output stream.
| o | The output strem to send results. |
|
inherited |
Print errors on output stream.
| o | The output strem to send results. |
Definition at line 106 of file errorsContainer_inl.h.
References error_count, and warning_count.
|
inherited |
For adding warnings.
| filename | The warning's file. |
| line | The warning's line. |
| col | The warning's column. |
| msg | The warning's message. |
Definition at line 61 of file errorsContainer_inl.h.
References add(), and narrow().
|
private |
Definition at line 109 of file GumMRFReader.h.
|
private |
Definition at line 106 of file GumMRFReader.h.
|
private |
Definition at line 108 of file GumMRFReader.h.
|
private |
Definition at line 107 of file GumMRFReader.h.
|
inherited |
Number of errors detected.
Definition at line 186 of file errorsContainer.h.
Referenced by add(), count(), and syntheticResults().
|
mutableprivateinherited |
The list of gum::ParseError contained in this gum::ErrorsContainer.
Definition at line 182 of file errorsContainer.h.
Referenced by add().
|
inherited |
Definition at line 189 of file errorsContainer.h.
Referenced by add(), count(), and syntheticResults().