File size: 2,949 Bytes
bdb271a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
60
61
62
63
64
65
66
67
68
69
70
71
72
import random

# ---------------------------------------------------------
# DATA POOLS
# ---------------------------------------------------------
# list of locations used for synthetic data generation
LOCATIONS = [
    "Manila", "Marikina", "Quezon City", "Pasig", "Cainta", "Rizal", 
    "Bulacan", "Pampanga", "Cavite", "Batangas", "Laguna", "San Mateo",
    "Montalban", "Antipolo", "Valenzuela", "Malabon", "Navotas", "Las Pinas",
    "Taguig", "Makati", "Caloocan", "Muntinlupa", "Paranaque", "Pasay"
]

# list of disaster types used for synthetic data generation
DISASTERS = [
    "baha", "flood", "flooding", "tubig", 
    "bagyo", "typhoon", "storm", "hangin", "ulan",
    "sunog", "fire", "smoke", "apoy",
    "lindol", "earthquake", "quake", "aftershock",
    "landslide", "guho", "mudslide"
]

# list of critical keywords used in both urgent and non-urgent samples
URGENT_KEYWORDS = [
    "tulong", "help", "saklolo", "rescue", "emergency", "evacuate", 
    "need food", "trapped", "stranded", "stuck", "lubog", "buntis"
]

# ---------------------------------------------------------
# GENERATORS
# ---------------------------------------------------------

# generates a synthetic urgent post (positive sample)
def build_positive():
    kw = random.choice(URGENT_KEYWORDS)
    disaster = random.choice(DISASTERS)
    loc = random.choice(LOCATIONS)
    
    templates = [
        f"{kw.upper()} please! {disaster} dito sa {loc}!",
        f"{loc} need {kw}, {disaster} is rising!",
        f"Kami po sa {loc} ay need ng {kw}, sobrang taas ng {disaster}!",
        f"{kw.upper()}! {disaster} sa {loc}, di kami makalabas!",
        f"Na-trap kami sa {loc} dahil sa {disaster}, {kw} please!",
        f"{disaster} alert in {loc}, we need {kw} asap!",
        f"Wala na kaming matatakbuhan sa {loc}, {disaster} na! {kw}!"
    ]
    return random.choice(templates)

# generates a synthetic non-urgent post (negative sample/trap)
def build_negative():
    kw = random.choice(URGENT_KEYWORDS) # uses urgent keywords in a safe context
    disaster = random.choice(DISASTERS)
    loc = random.choice(LOCATIONS)
    
    category = random.choice(["news", "donation", "past", "question"])
    
    # templates that structure the urgent keyword as general news or a report
    if category == "news":
        return f"Update: {kw} operations for {disaster} victims in {loc} are ongoing."
        
    # templates that structure the urgent keyword as a donation or offering help
    elif category == "donation":
        return f"We are sending {kw} and relief goods to {loc}. Stay strong!"
        
    # templates that structure the urgent keyword using past tense
    elif category == "past": 
        return f"Remembering when we were {kw}ed during the last {disaster} in {loc}."
        
    # templates that structure the urgent keyword as a general question or advice
    else: 
        return f"Guys in {loc}, do you need {kw}? Comment below."