FRIDAY / prototype1 /LangDetectModel /langDetect.py
Liantsoaxx08's picture
prototype1
80d1823
Raw
History Blame Contribute Delete
508 Bytes
import pickle
## load language detection model
with open('language_model.pkl', 'rb') as f:
model = pickle.load(f)
## load tfidf vectorizer
with open('tfidf.pkl', 'rb') as f:
tfidf = pickle.load(f)
## load label encoder
with open('label_encoder.pkl', 'rb') as f:
enc = pickle.load(f)
class AIlgdetect:
def checkLg(text):
yele = [text]
yele_tf = tfidf.transform(yele)
answer = model.predict(yele_tf)
ans = enc.inverse_transform(answer)
return ans[0]