Views
No views yet
intfloat/multilingual-e5-large, trained with Indonesian police news data.1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2
3tokenizer = AutoTokenizer.from_pretrained("faizaulia/e5-fine-tune-polri-news-emotion")
4model = AutoModelForSequenceClassification.from_pretrained("faizaulia/e5-fine-tune-polri-news-emotion")LAMPUNG, KOMPAS.com - Komplotan perampok yang menyekap satu keluarga di Kabupaten Lampung Timur ditembak aparat kepolisian. Komplotan ini menggondol uang sebanyak Rp 50 juta milik korban. Kapolres Lampung Timur, AKBP M Rizal Muchtar mengatakan, tiga dari empat pelaku ini telah ditangkap pada Senin (27/2/2023) dini hari.
1nltk.download('stopwords')
2nltk.download('wordnet')
3
4stop_words = set(stopwords.words('indonesian'))
5
6def remove_stopwords(text):
7 words = text.split()
8 words = [word for word in words if word not in stop_words]
9 return ' '.join(words)
10
11def clean_texts(text):
12 text = re.sub('\n',' ',text) # Remove every '\n'
13 text = re.sub(' +', ' ', text) # Remove extra spaces
14 text = re.sub('[\u2013\u2014]', '-', text) # Sub — and – char to -
15 text = re.sub('(.{0,40})-', '', text) # Remove news website/location at the beginning
16 text = re.sub(r'[^a-zA-Z\s]', '', text) # Remove non alphanbet characters
17 return text
18
19def preprocess_text(text):
20 text = text.lower()
21 text = clean_texts(text)
22 text = remove_stopwords(text)
23 return text