From 3951857acc2cac9690eebda8604e23c304c531a0 Mon Sep 17 00:00:00 2001 From: Marek Kaluba Date: Mon, 24 Jan 2022 12:25:40 +0100 Subject: [PATCH] sanitize group names --- data/smallhyperbolicgrp.jl | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/data/smallhyperbolicgrp.jl b/data/smallhyperbolicgrp.jl index 4a376aa..0b309ad 100644 --- a/data/smallhyperbolicgrp.jl +++ b/data/smallhyperbolicgrp.jl @@ -22,7 +22,7 @@ _name(G) = "G_$(G.order1)_$(G.order2)_$(G.order3)_$(G.index)" name(G::TriangleGrp) = _name(G) grp_name(nt::NamedTuple) = _name(nt) -latex_name(G::TriangleGrp) = "\$G^{$(G.order1),$(G.order2),$(G.order3)}_$(G.index)" +latex_name(G::TriangleGrp) = "G^{$(G.order1),$(G.order2),$(G.order3)}_$(G.index)" function _ishyperbolic(half_girth_type, nt::NamedTuple) a, b, c = half_girth_type @@ -46,10 +46,27 @@ function _ishyperbolic(half_girth_type, nt::NamedTuple) end end +function _sanitize_group_name(s::AbstractString) + s = replace(s, '$'=>"") + s = replace(s, "\\infty"=>"inf") + s = replace(s, r"\\textrm{(.*?)}"=>s"\1") + s = replace(s, r"(Alt)_{(\d+)}"=>s"\1(\2)") + s = replace(s, "_{}"=>"") + return s +end + function TriangleGrp(half_girth_type::NTuple{3,Int}, generators, relations, nt::NamedTuple) # @assert fieldnames(SmallHyperbolicGrp) == propertynames(nt) hyperbolic, witness = _ishyperbolic(half_girth_type, nt) + l2_quotients = let v = _sanitize_group_name.(parse_vec(String, nt.L2_quotients)) + if isempty(v) || (length(v)==1 && isempty(first(v))) + Vector{String}() + else + String.(v) + end + end + TriangleGrp( half_girth_type, convert(Vector{String}, generators), @@ -64,8 +81,8 @@ function TriangleGrp(half_girth_type::NTuple{3,Int}, generators, relations, nt:: _tf_missing(nt.virtually_torsion_free), _tf_missing(nt.Kazhdan), convert(Int, nt.abelianization_dimension), - parse_vec(String, nt.L2_quotients), - [Pair(p...) for p in parse_vec(Tuple{String,Int}, nt.quotients)], + l2_quotients, + [Pair(_sanitize_group_name(p[1]), p[2]) for p in parse_vec(Tuple{String,Int}, nt.quotients)], parse_vec(Int, nt.alternating_quotients), convert(Int, nt.maximal_order_for_alternating_quotients), )