-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreadCSO.py
More file actions
38 lines (20 loc) · 784 Bytes
/
readCSO.py
File metadata and controls
38 lines (20 loc) · 784 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Dec 13 17:51:09 2024
@author: Angelo Salatino
"""
from cso_reader import Ontology
ont = Ontology()
print(ont.ontology_attr)
print(f"Total concepts: {len(ont.topics)}")
unique_concepts = {ont.get_primary_label(topic) for topic, _ in ont.topics.items()}
print(f"Total unique concepts: {len(unique_concepts)}")
### Example: Count all topics with more that one unigram
count = 0
for topic, _ in ont.topics.items():
if (' ' in topic) == True:
count += 1
print(f"Total topics with more than 1 gram: {count}")
descendants = ont.get_all_descendants_of_topics(["artificial intelligence", "semantic web"])
print(f"artificial intelligence is at level {ont.level['artificial intelligence']}")