Package edu.cmu.tetrad.search.blocks
Class BlockSpecTextCodec
java.lang.Object
edu.cmu.tetrad.search.blocks.BlockSpecTextCodec
Text codec for BlockSpec: - Supports LHS names with optional rank: L1, L1(2) - Validates duplicate block names
(ERROR) - Warns if #index refers to a named variable (prefer name) - Preserves user-supplied names and ranks; does
not reorder blocks - Sorts members within each block (stable) and removes within-line duplicates
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordRepresents an issue encountered during the parsing or processing of block specifications.static final recordRepresents the result of parsing a textual representation of a block specification.static enumRepresents the severity level of a condition or situation. -
Method Summary
-
Method Details
-
parse
Parses an input textual representation of block specifications into a structured format.The input text is processed line-by-line to construct a block specification and validate the provided structure. Lines in the text that are either malformed, contain duplicates, or reference unknown variables are recorded as issues.
- Parameters:
text- the input text defining the block specificationds- the dataset providing variable names and their corresponding indices- Returns:
- a ParseResult record consisting of a constructed BlockSpec object and a list of encountered issues
-
format
Formats the given BlockSpec object into a textual representation.Generates a string description of the block specification, including the names of variables and latent nodes, and their ranks. The format includes line-by-line grouping of variables associated with blocks, using the structure of the given BlockSpec object.
- Parameters:
spec- the BlockSpec object to be formatted- Returns:
- a string representing the formatted textual description of the block specification
-