File size: 1,878 Bytes
e70050b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import sys
from pathlib import Path
import json

# Add project root to path (one level up from this script)
sys.path.append(str(Path(__file__).parent.parent))

from syscred.ontology_manager import OntologyManager
from syscred.config import config

def debug_graph():
    print("=== Debugging Ontology Graph Extraction ===")
    
    # Initialize manager
    base_path = str(config.ONTOLOGY_BASE_PATH)
    data_path = str(config.ONTOLOGY_DATA_PATH)
    
    print(f"Loading data from: {data_path}")
    manager = OntologyManager(base_ontology_path=base_path, data_path=data_path)
    
    # Get Stats
    stats = manager.get_statistics()
    print(f"Total Triples: {stats['total_triples']}")
    print(f"Evaluations: {stats.get('total_evaluations', 'N/A')}")
    
    # Try getting graph JSON
    print("\nExtracting Graph JSON...")
    graph_data = manager.get_graph_json()
    
    nodes = graph_data.get('nodes', [])
    links = graph_data.get('links', [])
    
    print(f"Nodes found: {len(nodes)}")
    print(f"Links found: {len(links)}")
    
    if len(nodes) > 0:
        print("\n--- Sample Nodes ---")
        for n in nodes[:3]:
            print(json.dumps(n, indent=2))
    else:
        print("\n❌ No nodes found! Checking latest report query...")
        # Manually run the query to see what's wrong
        query = """
        PREFIX cred: <http://www.dic9335.uqam.ca/ontologies/credibility-verification#>
        SELECT ?report ?timestamp WHERE {
            ?report a cred:RapportEvaluation .
            ?report cred:completionTimestamp ?timestamp .
        }
        ORDER BY DESC(?timestamp)
        LIMIT 5
        """
        print(f"Running SPARQL:\n{query}")
        results = manager.data_graph.query(query)
        for row in results:
            print(f"Found Report: {row.report} at {row.timestamp}")

if __name__ == "__main__":
    debug_graph()