Natural lang formatting a predicate.
(name: str, args: list[str])
| 91 | |
| 92 | |
| 93 | def pretty_nl(name: str, args: list[str]) -> str: |
| 94 | """Natural lang formatting a predicate.""" |
| 95 | if name == 'aconst': |
| 96 | a, b, c, d, y = args |
| 97 | return f'{pretty_angle(a, b, c, d)} = {y}' |
| 98 | if name == 'rconst': |
| 99 | a, b, c, d, y = args |
| 100 | return f'{a}{b}:{c}{d} = {y}' |
| 101 | if name == 'acompute': |
| 102 | a, b, c, d = args |
| 103 | return f'{pretty_angle(a, b, c, d)}' |
| 104 | if name in ['coll', 'C']: |
| 105 | return '' + ','.join(args) + ' are collinear' |
| 106 | if name == 'collx': |
| 107 | return '' + ','.join(list(set(args))) + ' are collinear' |
| 108 | if name in ['cyclic', 'O']: |
| 109 | return '' + ','.join(args) + ' are concyclic' |
| 110 | if name in ['midp', 'midpoint', 'M']: |
| 111 | x, a, b = args |
| 112 | return f'{x} is midpoint of {a}{b}' |
| 113 | if name in ['eqangle', 'eqangle6', '^']: |
| 114 | a, b, c, d, e, f, g, h = args |
| 115 | return f'{pretty_angle(a, b, c, d)} = {pretty_angle(e, f, g, h)}' |
| 116 | if name in ['eqratio', 'eqratio6', '/']: |
| 117 | return '{}{}:{}{} = {}{}:{}{}'.format(*args) |
| 118 | if name == 'eqratio3': |
| 119 | a, b, c, d, o, o = args # pylint: disable=redeclared-assigned-name |
| 120 | return f'S {o} {a} {b} {o} {c} {d}' |
| 121 | if name in ['cong', 'D']: |
| 122 | a, b, c, d = args |
| 123 | return f'{a}{b} = {c}{d}' |
| 124 | if name in ['perp', 'T']: |
| 125 | if len(args) == 2: # this is algebraic derivation. |
| 126 | ab, cd = args # ab = 'd( ... )' |
| 127 | return f'{ab} \u27c2 {cd}' |
| 128 | a, b, c, d = args |
| 129 | return f'{a}{b} \u27c2 {c}{d}' |
| 130 | if name in ['para', 'P']: |
| 131 | if len(args) == 2: # this is algebraic derivation. |
| 132 | ab, cd = args # ab = 'd( ... )' |
| 133 | return f'{ab} \u2225 {cd}' |
| 134 | a, b, c, d = args |
| 135 | return f'{a}{b} \u2225 {c}{d}' |
| 136 | if name in ['simtri2', 'simtri', 'simtri*']: |
| 137 | a, b, c, x, y, z = args |
| 138 | return f'\u0394{a}{b}{c} is similar to \u0394{x}{y}{z}' |
| 139 | if name in ['contri2', 'contri', 'contri*']: |
| 140 | a, b, c, x, y, z = args |
| 141 | return f'\u0394{a}{b}{c} is congruent to \u0394{x}{y}{z}' |
| 142 | if name in ['circle', 'I']: |
| 143 | o, a, b, c = args |
| 144 | return f'{o} is the circumcenter of \\Delta {a}{b}{c}' |
| 145 | if name == 'foot': |
| 146 | a, b, c, d = args |
| 147 | return f'{a} is the foot of {b} on {c}{d}' |
| 148 | |
| 149 | |
| 150 | def pretty(txt: str) -> str: |
nothing calls this directly
no test coverage detected