From 6ac407abaf4b33f7a3c79737417aab92fd810bfd Mon Sep 17 00:00:00 2001 From: paso Date: Fri, 16 Aug 2024 01:52:04 +0200 Subject: [PATCH] text formatted --- src/evaluate.jl | 4 ++-- src/print.jl | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/evaluate.jl b/src/evaluate.jl index 72fa8ec..bf2e1cb 100644 --- a/src/evaluate.jl +++ b/src/evaluate.jl @@ -154,11 +154,11 @@ end using PrettyTables # TODO document -function metricstable(ms::Vector{<:Rule}; metrics_kwargs = (;), syntaxstring_kwargs = (;), variable_names_map = nothing, pretty_table_kwargs...) +function metricstable(ms::Vector{<:Rule}; metrics_kwargs = (;), syntaxstring_kwargs = (;), variable_names_map = nothing, variable_idx = nothing, pretty_table_kwargs...) mets = readmetrics.(ms; metrics_kwargs...) colnames = unique(Iterators.flatten(keys.(mets))) - data = hcat(syntaxstring.(antecedent.(ms); variable_names_map = variable_names_map, syntaxstring_kwargs...), strip.(displaymodel.(consequent.(ms); show_symbols = false)), [[get(met, colname, "") for met in mets] for colname in colnames]...) + data = hcat(AnsiTextCell.(syntaxstring.(antecedent.(ms); variable_names_map = variable_names_map, variable_idx = variable_idx, syntaxstring_kwargs...)), strip.(displaymodel.(consequent.(ms); show_symbols = false)), [[get(met, colname, "") for met in mets] for colname in colnames]...) header = ["Antecedent", "Consequent", colnames...] pretty_table( data; diff --git a/src/print.jl b/src/print.jl index 9b9ec51..8c0f9df 100644 --- a/src/print.jl +++ b/src/print.jl @@ -182,7 +182,7 @@ function printmodel( println(io, "$(indentation_str)$(_typestr)$((length(info(m)) == 0) ? "" : "\n$(indentation_str)Info: $(info(m))")") end - depth == 0 && show_symbols && print(io, "▣") + depth == 0 && show_symbols && print(io, "\e[34m▣\e[0m") print(io, " $(outcome(m))") (show_subtree_metrics || show_metrics != false) && print(io, " : $(get_metrics_string(m; (show_metrics isa NamedTuple ? show_metrics : [])...))") show_shortforms != false && haskey(info(m), :shortform) && print(io, "\t\t\t\t\t\t\tSHORTFORM: $(@_antecedent_syntaxstring info(m)[:shortform] m parenthesize_atoms syntaxstring_kwargs kwargs)") @@ -215,7 +215,7 @@ function printmodel( println(io, "$(indentation_str)$(_typestr)$((length(info(m)) == 0) ? "" : "\n$(indentation_str)Info: $(info(m))")") end - depth == 0 && show_symbols && print(io, "▣") + depth == 0 && show_symbols && print(io, "\e[34m▣\e[0m") print(io, " $(f(m))") (show_subtree_metrics || show_metrics != false) && print(io, " : $(get_metrics_string(m; (show_metrics isa NamedTuple ? show_metrics : [])...))") show_shortforms != false && haskey(info(m), :shortform) && print(io, "\t\t\t\t\t\t\tSHORTFORM: $(@_antecedent_syntaxstring info(m)[:shortform] m parenthesize_atoms syntaxstring_kwargs kwargs)") @@ -260,7 +260,7 @@ function printmodel( println(io, "$(indentation_str)$(_typestr)$((length(info(m)) == 0) ? "" : "\n$(indentation_str)Info: $(info(m))")") end - depth == 0 && show_symbols && print(io, "▣") + depth == 0 && show_symbols && print(io, "\e[34m▣\e[0m") ######################################################################################## if isnothing(max_depth) || depth < max_depth pipe = "$(indentation_list_children) " @@ -282,7 +282,7 @@ function printmodel( println(io, "") else line = "$(pipe)$(ant_str)" * " $(arrow) " - ind_str = indentation_str * repeat(" ", length(line) + length("▣") + 1) + ind_str = indentation_str * repeat(" ", length(line) + length("\e[34m▣\e[0m") + 1) if (show_subtree_metrics || show_metrics != false) print(io, line) _io = IOBuffer() @@ -339,7 +339,7 @@ function printmodel( println(io, "$(indentation_str)$(_typestr)$((length(info(m)) == 0) ? "" : "\n$(indentation_str)Info: $(info(m))")") end - depth == 0 && show_symbols && print(io, "▣") + depth == 0 && show_symbols && print(io, "\e[34m▣\e[0m") ######################################################################################## if isnothing(max_depth) || depth < max_depth pipe = "$(indentation_list_children) " @@ -414,7 +414,7 @@ function printmodel( println(io, "$(indentation_str)$(_typestr)$((length(info(m)) == 0) ? "" : "\n$(indentation_str)Info: $(info(m))")") end - depth == 0 && show_symbols && print(io, "▣") + depth == 0 && show_symbols && print(io, "\e[34m▣\e[0m") ######################################################################################## _show_rule_metrics = show_rule_metrics # TODO show this metrics if show_metrics