File size: 1,591 Bytes
af16ccb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import json
from faker import Faker
import random
from datetime import datetime, timedelta

fake = Faker()

def generate_fake_data(num_nodes=10, num_links=5):
    nodes = []
    links = []
    topics = ["Environment", "Politics", "Technology", "Health", "Economy"]
    emotions = ["trust", "joy", "fear", "sadness", "anger", "surprise"]
    sentiments = ["positive", "negative", "neutral"]

    # Generate nodes
    for i in range(1, num_nodes + 1):
        node = {
            "id": i,
            "headline": fake.sentence(nb_words=6),
            "topic": random.choice(topics),
            "emotion": random.choice(emotions),
            "time": (datetime.now() - timedelta(days=random.randint(0, 365))).strftime("%Y-%m-%d"),
            "sentiment": random.choice(sentiments)
        }
        nodes.append(node)

    # Generate links
    for _ in range(num_links):
        source = random.randint(1, num_nodes)
        target = random.randint(1, num_nodes)
        while target == source:
            target = random.randint(1, num_nodes)
        
        link = {
            "source": source,
            "target": target,
            "semantic_sim": round(random.uniform(0.1, 1.0), 2),
            "causal": random.choice([True, False]),
            "causal_note": fake.sentence(nb_words=8) if random.random() > 0.5 else None
        }
        links.append(link)

    return {"nodes": nodes, "links": links}

def main(num_nodes=10, num_links=5):
    data = generate_fake_data(num_nodes, num_links)
    return json.dumps(data, indent=2)

if __name__ == "__main__":
    print(main())