import sys
import os

# Ensure project root is on sys.path (for pickle shim)
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
if ROOT not in sys.path:
    sys.path.insert(0, ROOT)

import joblib

from tone.models.persuasive import PersuasiveClassifier
from tone.models.questioning import QuestioningClassifier
from tone.models.formal import FormalClassifier
from tone.models.assertive import AssertiveClassifier
from tone.models.authoritative import AuthoritativeClassifier
from tone.models.narrative import NarrativeClassifier


ARTIFACTS = "E:/tone/tone/artifacts"


def resave(name):
    path = os.path.join(ARTIFACTS, name)
    model = joblib.load(path)
    joblib.dump(model, path)
    print(f"Resaved {name}")


def main():
    resave("persuasive_model.joblib")
    resave("questioning_model.joblib")
    resave("formal_model.joblib")
    resave("assertive_model.joblib")
    resave("authoritative_model.joblib")
    resave("narrative_model.joblib")


if __name__ == "__main__":
    main()
