Spaces:
Runtime error
Runtime error
Update app.py
Browse files1 unmodified line234567891011121314151617181920212223242526272829303132333435363738394041421 unmodified lineimport gradio as grimport pandas as pdimport numpy as npimport nltkfrom nltk.corpus import stopwordsimport reimport string
# NLTK kütüphanesini kullanarak türkçe dilindeki etkisiz kelimeleri (stopwords) indiriyoruz.nltk.download('stopwords')# İndirilen etkisiz kelimeleri "stop_words_list" değişkenine atıyoruz.stop_words_list = stopwords.words('turkish')# Veri setindeki "text" sütunu altındaki hatalı alanları temizlemek için bir dizi oluşturduk.false_text = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
def preprocess_text(text): # Küçük harflere çevirme text = text.lower() # Satır sonu karakterlerini kaldırma import re text = re.sub(r'\n', ' ', text) # Rakamları kaldırma text = re.sub(r'\d', '', text) # Noktalama işaretlerini kaldırma import string text = text.translate(str.maketrans("", "", string.punctuation)) # Stop-words'leri kaldırma words = text.split() words = [word for word in words if not word in stop_words_list] # Veri setindeki hatalı verilerin kaldırılması words = [word for word in words if not word in false_text] # Tekrarlanan karakterlerin kaldırılması words = [re.sub(r'(.)\1{1,}', r'\1\1', word) for word in words] # Tekrarlanan boşlukların kaldırılması words = [word.strip() for word in words if len(word.strip()) > 1]
text = " ".join(words) return text
def predict(text): model_path = "bert_model"app.py+33