NLP_PROJECT_NEW / comment.py
Preethamreddy799's picture
new
e499a0f
'''
import requests
import os
# Function to load the pre-trained KNN model
def load_knn_model_expected():
github_url = "https://raw.githubusercontent.com/PreethamGollapalli/QA-Test-steps-generation-project/main/knn_model_expected%20(2).joblib"
response = requests.get(github_url)
if response.status_code == 200:
# Save the file locally
with open("knn_model_expected.joblib", "wb") as f:
f.write(response.content)
# Load the model
knn_model_expected = joblib.load("knn_model_expected.joblib")
# Optionally, clean up the local file
os.remove("knn_model_expected.joblib")
return knn_model_expected
else:
raise Exception(f"Failed to download the file: {response.status_code}")
def load_knn_model_steps ():
github_url = "https://raw.githubusercontent.com/PreethamGollapalli/QA-Test-steps-generation-project/main/knn_model_steps%20(2).joblib"
response = requests.get(github_url)
if response.status_code == 200:
# Save the file locally
with open("knn_model_steps.joblib", "wb") as f:
f.write(response.content)
# Load the model
knn_model_steps = joblib.load("knn_model_steps.joblib")
# Optionally, clean up the local file
os.remove("knn_model_steps.joblib")
return knn_model_steps
else:
raise Exception(f"Failed to download the file: {response.status_code}")
def load_tfidf_vectorizer():
github_url = "https://raw.githubusercontent.com/PreethamGollapalli/QA-Test-steps-generation-project/main/tfidf_vectorizer%20(3).pkl"
response = requests.get(github_url)
if response.status_code == 200:
# Save the file locally
with open("tfidf_vectorizer.pkl", "wb") as f:
f.write(response.content)
# Load the model
vectorizer = joblib.load("tfidf_vectorizer.pkl")
# Optionally, clean up the local file
os.remove("tfidf_vectorizer.pkl")
return vectorizer
else:
raise Exception(f"Failed to download the file: {response.status_code}")
'''
# Load models (KNN model and embedding model)
'''
knn_model_steps = load_knn_model_steps()
knn_model_results = load_knn_model_expected()
tfidf_vectorizer = load_tfidf_vectorizer()
'''