Skip to content

Parent-Child relationship in notations.txt errors #21

@epoz

Description

@epoz

The following list of items in notation.txt has an issue with the parent-child relationship:

11P315(AUGUSTINIANS)
11P315(BENEDICTINES)
11P315(CARMELITES)
11P315(CARTHUSIANS)
11P315(CISTERCIANS)
11P315(DOMINICANS)
11P315(FRANCISCANS)
11P315(PRAEMONSTRATENSIANS)
23Q8
23Q81
25C112
25D12(FLINT)
25H182
25H183
32B311(ENGLISHMEN)
32B311(SLOWAKIANS)
32B313(...)
32B313(MOROCCO)
32B313(SRI LANKA)
32B3213
32B3213(...)
32B3213(INDIA)
32B3213(GREAT BRITAIN)
32B3213(THE NETHERLANDS)
32B332
32B332(AUSTRALIA)
32B333
32B333(EUROPE)
34A111
41D211(ROBE À L’ANGLAISE)
42A4213
45C15(CROSSBOW)
46C11213
49E3933(...)
49E3933(BALNEUM ARENAE)
49E3933(BALNEUM MARIAE)
73C941
73D144
73F421(...)
73G423
91B25(PYRACMON)
95A(SISYPHUS)681
95A(SISYPHUS)6811
95A(SISYPHUS)682
95A(SISYPHUS)6821
95B(THEONOE)1
95B(THEONOE)11
95B(THEONOE)12
95B(THEONOE)2
95B(THEONOE)3
95B(THEONOE)31
95B(THEONOE)32
95B(THEONOE)33
95B(THEONOE)34
95B(THEONOE)35
95B(THEONOE)36
95B(THEONOE)37
95B(THEONOE)4
95B(THEONOE)5
95B(THEONOE)6
95B(THEONOE)68
95B(THEONOE)69
95B(THEONOE)7
95B(THEONOE)78
95B(THEONOE)79
95B(THEONOE)8
95B(TYRO)1
95B(TYRO)11
95B(TYRO)12
95B(TYRO)2
95B(TYRO)3
95B(TYRO)4
95B(TYRO)5
95B(TYRO)6
95B(TYRO)61
95B(TYRO)68
95B(TYRO)69
95B(TYRO)7
95B(TYRO)78
95B(TYRO)79
95B(TYRO)8

Discovered this when doing a recursive im-memory listing parent-child relationships:

import textbase

def depth_first_find(node, wanted):
    if node["n"] == wanted:
        return node
    for kid in node.get("c", []):
        possible =  depth_first_find(kid, wanted)
        if possible:
            return possible

tree = {"n": "", "c": [
    {"n":"0", "c":[]},
    {"n":"1", "c":[]},
    {"n":"2", "c":[]},
    {"n":"3", "c":[]},
    {"n":"4", "c":[]},
    {"n":"5", "c":[]},
    {"n":"6", "c":[]},
    {"n":"7", "c":[]},
    {"n":"8", "c":[]},
    {"n":"9", "c":[]},
] }

map = {}

for x in textbase.parse("notations.txt"):
    notation = x['N'][0]
    node = map.get(notation)
    if node is None:
        node = depth_first_find(tree, notation)
        if node is not None:
            map[notation] = node
        else:
            print(notation)
            continue
    node["c"] = [{"n": c} for c in x.get("C", [])]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions