TIF_E41253385/api_slearn/training_input.py

15 lines
739 B
Python

"""Column metadata checks; content must still be reviewed by the administrator."""
import re
IDENTITY = {'no', 'nomor', 'id', 'nama', 'name', 'nim', 'nis', 'nip', 'nik',
'prodi', 'jurusan', 'fakultas', 'gender', 'kelamin', 'email',
'telepon', 'phone', 'alamat', 'address', 'angkatan', 'semester',
'label', 'sentimen', 'sentiment'}
def validate_column(column):
words = set(re.sub(r'[^a-z0-9]+', ' ', column.casefold()).split())
compact = ''.join(sorted(words))
if not words or words & IDENTITY or {'program', 'studi'} <= words or compact in {'jeniskelamin', 'programstudi'}:
raise ValueError('Pilih kolom berisi ulasan, bukan kolom identitas atau label.')
return column.strip()