@@ -0,0 +1,1562 @@
+%22%22%22This script produces a TSV that help map the BBN ontology%0Ato the Eidos UN ontology based on entries and examples.%22%22%22%0A%0Aimport yaml%0Aimport requests%0Afrom indra.sources import bbn%0A%0A%0A%0Adef build_examples(node, tree, prefix):%0A    if not prefix or prefix in ('entity', 'event'):%0A        this_prefix = node%0A    else:%0A        this_prefix = prefix + ',' + node if prefix else node%0A    for entry in tree:%0A        if isinstance(entry, str) and entry%5B0%5D != '_':%0A            child = entry%0A        elif isinstance(entry, dict):%0A            for child in entry.keys():%0A                if child%5B0%5D != '_':%0A                    if isinstance(entry%5Bchild%5D, (list, dict)):%0A                        build_examples(child, entry%5Bchild%5D, this_prefix)%0A        if child%5B0%5D != '_':%0A            if this_prefix in all_examples:%0A                all_examples%5Bthis_prefix%5D.add(child)%0A            else:%0A                parts = this_prefix.split(',')%0A                all_examples%5Bthis_prefix%5D = set(parts + %5Bchild%5D)%0A%0A%0Aif __name__ == '__main__':%0A    # BBN%0A    bbn_ont_url = ('https://raw.githubusercontent.com/BBN-E/Hume/master/'%0A                   'resource/ontologies/hume_ontology.yaml')%0A%0A    all_examples = %7B%7D%0A%0A    yml = requests.get(bbn_ont_url).content%0A    root = yaml.load(yml)%0A    for top_entry in root:%0A        node = list(top_entry.keys())%5B0%5D%0A        build_examples(node, top_entry%5Bnode%5D, None)%0A%0A%0A    with open('bbn_ontology_examples.tsv', 'w') as fh:%0A        for k, v in sorted(all_examples.items(), key=lambda x: x%5B0%5D):%0A            fh.write('%25s%5Ct%25s%5Cn' %25 (k, ','.join(sorted(list(v)))))%0A

Add script to generate BBN TSV