package com.purui.prims.headless.chat.knowledge.builder;

import com.purui.prims.headless.chat.knowledge.DictWord;
import com.purui.prims.headless.api.pojo.SchemaElement;

import java.util.ArrayList;
import java.util.List;
import org.springframework.util.CollectionUtils;

public abstract class BaseWordWithAliasBuilder extends BaseWordBuilder {

    public abstract DictWord getOneWordNature(String word, SchemaElement schemaElement, boolean isSuffix);

    public List<DictWord> getOneWordNatureAlias(SchemaElement schemaElement, boolean isSuffix) {
        List<DictWord> dictWords = new ArrayList<>();
        if (CollectionUtils.isEmpty(schemaElement.getAlias())) {
            return dictWords;
        }

        for (String alias : schemaElement.getAlias()) {
            dictWords.add(getOneWordNature(alias, schemaElement, isSuffix));
        }
        return dictWords;
    }

}
