package com.heyu.api.baidu.response.common;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * {
 *     "paragraphs_result": [
 *         {
 *             "words_result_idx": [
 *                 0
 *             ]
 *         },
 *         {
 *             "words_result_idx": [
 *                 1
 *             ]
 *         },
 *         {
 *             "words_result_idx": [
 *                 2
 *             ]
 *         },
 *         {
 *             "words_result_idx": [
 *                 3
 *             ]
 *         },
 *         {
 *             "words_result_idx": [
 *                 4,
 *                 5
 *             ]
 *         },
 *         {
 *             "words_result_idx": [
 *                 6
 *             ]
 *         },
 *         {
 *             "words_result_idx": [
 *                 7
 *             ]
 *         },
 *         {
 *             "words_result_idx": [
 *                 8,
 *                 9
 *             ]
 *         }
 *     ],
 *     "paragraphs_result_num": 8,
 *     "direction": 3,
 *     "language": 3,
 *     "words_result": [
 *         {
 *             "probability": {
 *                 "average": 0.9292118549,
 *                 "min": 0.7395062447,
 *                 "variance": 0.01200169791
 *             },
 *             "words": "车甲m力"
 *         },
 *         {
 *             "probability": {
 *                 "average": 0.999358356,
 *                 "min": 0.9983035326,
 *                 "variance": 5.616034855e-7
 *             },
 *             "words": "23K"
 *         },
 *         {
 *             "probability": {
 *                 "average": 0.9994705319,
 *                 "min": 0.9994705319,
 *                 "variance": 0
 *             },
 *             "words": "国"
 *         },
 *         {
 *             "probability": {
 *                 "average": 0.9864490032,
 *                 "min": 0.9624524117,
 *                 "variance": 0.000288115174
 *             },
 *             "words": "24L"
 *         },
 *         {
 *             "probability": {
 *                 "average": 0.9983958602,
 *                 "min": 0.9903038144,
 *                 "variance": "0.00001094429899"
 *             },
 *             "words": "中华人民共和国"
 *         },
 *         {
 *             "probability": {
 *                 "average": 0.9995914698,
 *                 "min": 0.9991493225,
 *                 "variance": 7.65195054e-8
 *             },
 *             "words": "居民身份证"
 *         },
 *         {
 *             "probability": {
 *                 "average": 0.849159956,
 *                 "min": 0.6997103095,
 *                 "variance": 0.0223351866
 *             },
 *             "words": "贝儿"
 *         },
 *         {
 *             "probability": {
 *                 "average": 0.9898030162,
 *                 "min": 0.9303755164,
 *                 "variance": 0.0004193784844
 *             },
 *             "words": "签发机关城步苗族自治县公安局"
 *         },
 *         {
 *             "probability": {
 *                 "average": 0.9998774529,
 *                 "min": 0.9995853305,
 *                 "variance": 2.900405249e-8
 *             },
 *             "words": "有效期限"
 *         },
 *         {
 *             "probability": {
 *                 "average": 0.9891473055,
 *                 "min": 0.8831946254,
 *                 "variance": 0.0007565403939
 *             },
 *             "words": "2019.10.11-2039.10.11"
 *         }
 *     ],
 *     "words_result_num": 10,
 *     "log_id": "1893516070299843167"
 * }
 *
 * https://console.bce.baidu.com/support/?_=1740219852952&timestamp=1740283517091#/api?product=AI&project=%E6%96%87%E5%AD%97%E8%AF%86%E5%88%AB&parent=%E9%80%9A%E7%94%A8%E5%9C%BA%E6%99%AFOCR&api=rest%2F2.0%2Focr%2Fv1%2Fgeneral_basic&method=post
 */
@NoArgsConstructor
@Data
public class BGeneralBasicResp {


    @JsonProperty("paragraphs_result")
    private List<ParagraphsResultDTO> paragraphsResult;
    @JsonProperty("paragraphs_result_num")
    private Integer paragraphsResultNum;
    @JsonProperty("direction")
    private Integer direction;
    @JsonProperty("language")
    private Integer language;
    @JsonProperty("words_result")
    private List<WordsResultDTO> wordsResult;
    @JsonProperty("words_result_num")
    private Integer wordsResultNum;
    @JsonProperty("log_id")
    private String logId;
    @JsonProperty("error_msg")
    private String errorMsg;


    @NoArgsConstructor
    @Data
    public static class ParagraphsResultDTO {
        @JsonProperty("words_result_idx")
        private List<Integer> wordsResultIdx;
    }

    @NoArgsConstructor
    @Data
    public static class WordsResultDTO {
        @JsonProperty("probability")
        private ProbabilityDTO probability;
        @JsonProperty("words")
        private String words;

        @NoArgsConstructor
        @Data
        public static class ProbabilityDTO {
            @JsonProperty("average")
            private Double average;
            @JsonProperty("min")
            private Double min;
            @JsonProperty("variance")
            private Double variance;
        }
    }
}
