class AnalyzerFactory {

    private static final Map<String, Class<? extends Analyzer>> ANALYZERS;

    static {
        ANALYZERS = new ConcurrentHashMap<>();
    }

    public static Analyzer analyzer(String name, String mode) {<FILL_FUNCTION_BODY>}

    private static Analyzer customizedAnalyzer(String name, String mode) {
        Class<? extends Analyzer> clazz = ANALYZERS.get(name);
        if (clazz == null) {
            throw new HugeException("Not exists analyzer: %s", name);
        }

        assert Analyzer.class.isAssignableFrom(clazz);
        try {
            return clazz.getConstructor(String.class).newInstance(mode);
        } catch (Exception e) {
            throw new HugeException(
                    "Failed to construct analyzer '%s' with mode '%s'",
                    e, name, mode);
        }
    }

    @SuppressWarnings({"rawtypes", "unchecked"})
    public static void register(String name, String classPath) {
        ClassLoader classLoader = SerializerFactory.class.getClassLoader();
        Class<?> clazz;
        try {
            clazz = classLoader.loadClass(classPath);
        } catch (Exception e) {
            throw new HugeException("Load class path '%s' failed",
                                    e, classPath);
        }

        // Check subclass
        if (!Analyzer.class.isAssignableFrom(clazz)) {
            throw new HugeException("Class '%s' is not a subclass of " +
                                    "class Analyzer", classPath);
        }

        // Check exists
        if (ANALYZERS.containsKey(name)) {
            throw new HugeException("Exists analyzer: %s(%s)",
                                    name, ANALYZERS.get(name).getName());
        }

        // Register class
        ANALYZERS.put(name, (Class) clazz);
    }
}

        name = name.toLowerCase();
        switch (name) {
            case "ansj":
                return new AnsjAnalyzer(mode);
            case "hanlp":
                return new HanLPAnalyzer(mode);
            case "smartcn":
                return new SmartCNAnalyzer(mode);
            case "jieba":
                return new JiebaAnalyzer(mode);
            case "jcseg":
                return new JcsegAnalyzer(mode);
            case "mmseg4j":
                return new MMSeg4JAnalyzer(mode);
            case "ikanalyzer":
                return new IKAnalyzer(mode);
            default:
                return customizedAnalyzer(name, mode);
        }
    
<no_super_class>