// This file is auto-generated by alef — DO NOT EDIT.
// alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75
// To regenerate: alef generate
// To verify freshness: alef verify --exit-code
// Issues & docs: https://github.com/kreuzberg-dev/alef
package dev.kreuzberg;

import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
import org.jspecify.annotations.Nullable;

/**
 * Keyword extraction configuration.
 */
@JsonInclude(JsonInclude.Include.NON_ABSENT)
@JsonDeserialize(builder = KeywordConfig.Builder.class)
public record KeywordConfig(
    /**
     * Algorithm to use for extraction.
     */
    @Nullable @JsonProperty("algorithm") KeywordAlgorithm algorithm,
    /**
     * Maximum number of keywords to extract (default: 10).
     */
    @Nullable @JsonProperty("max_keywords") Long maxKeywords,
    /**
     * Minimum score threshold (0.0-1.0, default: 0.0).
     *
     * Keywords with scores below this threshold are filtered out.
     * Note: Score ranges differ between algorithms.
     */
    @Nullable @JsonProperty("min_score") Float minScore,
    /**
     * N-gram range for keyword extraction (min, max).
     *
     * (1, 1) = unigrams only
     * (1, 2) = unigrams and bigrams
     * (1, 3) = unigrams, bigrams, and trigrams (default)
     */
    @Nullable @JsonProperty("ngram_range") List<Long> ngramRange,
    /**
     * Language code for stopword filtering (e.g., "en", "de", "fr").
     *
     * If null, no stopword filtering is applied.
     */
    @Nullable @JsonProperty("language") String language,
    /**
     * YAKE-specific tuning parameters.
     */
    @Nullable @JsonProperty("yake_params") YakeParams yakeParams,
    /**
     * RAKE-specific tuning parameters.
     */
    @Nullable @JsonProperty("rake_params") RakeParams rakeParams
) {
    public static Builder builder() {
        return new Builder();
    }
    public KeywordConfig{
        if (maxKeywords == null) maxKeywords = 10L;
    }

    // CPD-OFF
    @JsonPOJOBuilder(withPrefix = "with", buildMethodName = "build")
    public static final class Builder {

        @Nullable private KeywordAlgorithm algorithm = KeywordAlgorithm.Yake;
        @JsonProperty("max_keywords")
private Long maxKeywords = null;
        @JsonProperty("min_score")
private Float minScore = null;
        @JsonProperty("ngram_range")
private List<Long> ngramRange = null;
private String language = null;
        @JsonProperty("yake_params")
private YakeParams yakeParams = null;
        @JsonProperty("rake_params")
private RakeParams rakeParams = null;

        /** Sets the algorithm field. */
        @JsonProperty("algorithm")
        public Builder withAlgorithm(final @Nullable KeywordAlgorithm value) {
            this.algorithm = value;
            return this;
        }

        /** Sets the maxKeywords field. */
        @JsonProperty("max_keywords")
        public Builder withMaxKeywords(final @Nullable Long value) {
            this.maxKeywords = value;
            return this;
        }

        /** Sets the minScore field. */
        @JsonProperty("min_score")
        public Builder withMinScore(final @Nullable Float value) {
            this.minScore = value;
            return this;
        }

        /** Sets the ngramRange field. */
        @JsonProperty("ngram_range")
        public Builder withNgramRange(final @Nullable List<Long> value) {
            this.ngramRange = value;
            return this;
        }

        /** Sets the language field. */
        @JsonProperty("language")
        public Builder withLanguage(final @Nullable String value) {
            this.language = value;
            return this;
        }

        /** Sets the yakeParams field. */
        @JsonProperty("yake_params")
        public Builder withYakeParams(final @Nullable YakeParams value) {
            this.yakeParams = value;
            return this;
        }

        /** Sets the rakeParams field. */
        @JsonProperty("rake_params")
        public Builder withRakeParams(final @Nullable RakeParams value) {
            this.rakeParams = value;
            return this;
        }

        /** Builds the KeywordConfig instance. */
        public KeywordConfig build() {
            return new KeywordConfig(
                algorithm,
                maxKeywords,
                minScore,
                ngramRange,
                language,
                yakeParams,
                rakeParams
            );
        }
    }
    // CPD-ON
    public static KeywordConfig defaultInstance() {
        throw new UnsupportedOperationException("defaultInstance is not yet bridged via JNI; use the Builder instead.");
    }
}
