fix:service some bug

This commit is contained in:
ext-ensky-jeremy.jj.he
2025-08-13 09:31:23 +08:00
parent f2fe78cce4
commit ae2ba0893a

View File

@@ -19,7 +19,8 @@ class NewsClassifierService:
@bentoml.api
def classify(self,text: str) -> dict:
categories = ['Competition News','financial news','Medical news','sports news']
token_text =self.model_vectorizer.transform([text])
cleaned_text = text.strip().replace("\n", "")
token_text =self.model_vectorizer.transform([cleaned_text])
prediction = self.model_logistic.predict(token_text)
print(f"Prediction: {prediction}")
predict = categories[prediction[0]]