Sem-DPO: Mitigating Semantic Inconsistency in Preference Optimization for Prompt Engineering