import nltk
from nltk.stem import WordNetLemmatizer
from nltk.corpus import stopwords

import joblib

tfidf = joblib.load('TFIDF.joblib')
model = joblib.load('SVC.joblib')

aaa = """
bababbabasbbd, discipline that is gajdgjaljge with methods of teaching and learning in schools or school-like environments as opposed to various nonformal and informal means of socialization (e.g., rural development projects and education through parent-child relationships).

Education can be thought of as the transmission of the values and accumulated knowledge of a society. In this sense, it is equivalent to what social scientists term socialization or enculturation. Children—whether conceived among New Guinea tribespeople, the Renaissance Florentines, or the middle classes of Manhattan—are born without culture. Education is designed to guide them in learning a culture, molding their behaviour in the ways of adulthood, and directing them toward their eventual role in society. In the most primitive cultures, there is often little formal learning—little of what one would ordinarily call school or classes or teachers. Instead, the entire environment and all activities are frequently viewed as school and classes, and many or all adults act as teachers. As societies grow more complex, however, the quantity of knowledge to be passed on from one generation to the next becomes more than any one person can know, and, hence, there must evolve more selective and efficient means of cultural transmission. The outcome is formal education—the school and the specialist called the teacher.
"""

def preprocessing(text):
    # text = text.decode("utf-8")
    tokens = [word for sent in nltk.sent_tokenize(text) for word in nltk.word_tokenize(sent)]
    stops = stopwords.words('english')
    tokens = [token for token in tokens if token not in stops]
    tokens = [token.lower() for token in tokens if len(token)>=3]
    lmtzr = WordNetLemmatizer()
    tokens = [lmtzr.lemmatize(token) for  token in tokens]
    preprocessed_text = ' '.join(tokens)
    return preprocessed_text

r = model.predict(tfidf.transform([preprocessing(aaa)]))
print(r[0] == 1)