Helper function to convert string labels to integers