# persuasive
import csv
import os

# Resolve project root safely
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

RAW_PATH = os.path.join(BASE_DIR, "raw.txt")
OUT_PATH = os.path.join(BASE_DIR, "data", "persuasive.csv")

PERSUASIVE_MARKERS = [
    "should",
    "must",
    "recommend",
    "suggest",
    "urge",
    "need to",
    "strongly believe",
    "encourage"
]


def load_raw_text(path):
    with open(path, "r", encoding="utf-8") as f:
        return [line.strip() for line in f if line.strip()]


def label_text(text):
    t = text.lower()
    for marker in PERSUASIVE_MARKERS:
        if marker in t:
            return 1
    return 0


def main():
    texts = load_raw_text(RAW_PATH)

    with open(OUT_PATH, "w", newline="", encoding="utf-8") as f:
        writer = csv.writer(f)
        writer.writerow(["text", "label"])

        for text in texts:
            writer.writerow([text, label_text(text)])

    print(f"Dataset written to {OUT_PATH}")


if __name__ == "__main__":
    main()
