Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parent-Child relationship in notations.txt errors #21

Open
epoz opened this issue Oct 24, 2021 · 1 comment
Open

Parent-Child relationship in notations.txt errors #21

epoz opened this issue Oct 24, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@epoz
Copy link
Contributor

epoz commented Oct 24, 2021

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", [])]
@epoz epoz added the bug Something isn't working label Oct 24, 2021
@epoz
Copy link
Contributor Author

epoz commented Oct 24, 2021

Running the above code snippet gives you an in-memory dict representing the base IC tree structure.
This could then be serialized to JSON, and when gzipped results in a tiny 144Kb file!

A tiny file could be sent along to the browser and used to boot-strap the tree browsing code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant