2025-06-06 10:26:12 +08:00
|
|
|
package cn.smartjavaai.translation.enums;
|
|
|
|
|
/**
|
|
|
|
|
* 机器翻译模型枚举
|
|
|
|
|
* @author lwx
|
|
|
|
|
* @date 2025/6/05
|
|
|
|
|
*/
|
2025-06-17 11:03:34 +08:00
|
|
|
public enum TranslationModeEnum {
|
2025-06-06 10:26:12 +08:00
|
|
|
|
2025-06-17 11:03:34 +08:00
|
|
|
NLLB_MODEL;
|
2025-06-06 10:26:12 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据名称获取枚举 (忽略大小写和下划线变体)
|
|
|
|
|
*/
|
2025-06-17 11:03:34 +08:00
|
|
|
public static TranslationModeEnum fromName(String name) {
|
2025-06-06 10:26:12 +08:00
|
|
|
String formatted = name.trim().toUpperCase().replaceAll("[-_]", "");
|
2025-06-17 11:03:34 +08:00
|
|
|
for (TranslationModeEnum model : values()) {
|
2025-06-06 10:26:12 +08:00
|
|
|
if (model.name().replaceAll("_", "").equals(formatted)) {
|
|
|
|
|
return model;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
throw new IllegalArgumentException("未知模型名称: " + name);
|
|
|
|
|
}
|
|
|
|
|
}
|