All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.qingxun.javasdkapi.examples.PaperCheckOpenApiClientDemo Maven / Gradle / Ivy

Go to download

openapi SDK for Java Copyright © 2023 杭州轻寻科技 All rights reserved. 版权所有 (C)杭州轻寻科技 http://open.qingxun.com

The newest version!
package com.qingxun.javasdkapi.examples;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.qingxun.javasdkapi.clients.AccountsOpenApiClient;
import com.qingxun.javasdkapi.clients.PaperCheckOpenApiClient;
import com.qingxun.javasdkapi.common.JsonUtil;
import com.qingxun.javasdkapi.request.DetectDocPageRequest;
import com.qingxun.javasdkapi.request.DownloadCheckSubmitRequest;
import com.qingxun.javasdkapi.request.GetAccountRequest;
import com.qingxun.javasdkapi.request.PaperCheckSubmitRequest;
import com.qingxun.javasdkapi.response.BaseResponse;
import com.qingxun.javasdkapi.response.DetectDocCharactersResponse;
import com.qingxun.javasdkapi.response.DownloadPaperCheckResponse;
import com.qingxun.javasdkapi.response.GetAccountResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

import static com.qingxun.javasdkapi.common.JsonUtil.objectMapper;

public class PaperCheckOpenApiClientDemo {
    private final static String appId = "您的appId";

    private final static String privateKey = "您的privateKey";

    private final static String  filePath ="论文路径";
    private final static String  author ="论文作者名称";
    private final static String  tittle="论文标题";

    /**
     * 0:专业版,默认 (单篇限 20 万 字符,适用期刊、 初稿、修改稿 等),
     * 1:本科版 (单篇限 7 万字符,适用专/本论文),
     * 2:硕博版 (单篇限 30 万字符,适用硕/ 博/著作等),
     * 所有版本最低字符数要大于500
     */
    private final static Integer  type=1;
    /**
     * 任务 id
     * 上传源文件后可 获取该 ID
     */
    private final static Integer  taskId= 0;



    private final static Logger log = LoggerFactory.getLogger(PaperCheckOpenApiClientDemo.class);

    private static PaperCheckOpenApiClient paperCheckOpenApiClient = new PaperCheckOpenApiClient(appId, privateKey);



    public static DetectDocCharactersResponse detectedPaperInfo() {
        DetectDocPageRequest  detectDocPageRequest = null;
        try {
            detectDocPageRequest = new DetectDocPageRequest.Builder()
                    //.setFile(new File(filePath))
                    .setFileStream(new FileInputStream(filePath)).setFileName(tittle)

                    .builder();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }


        return  paperCheckOpenApiClient.excute(detectDocPageRequest);
    }

    public static BaseResponse submit() {
        PaperCheckSubmitRequest  paperCheckSubmitRequest = new PaperCheckSubmitRequest.Builder()
                .setAuthor(author).setTitle(tittle).setType(type).setTaskId(taskId).bulider();

        return  paperCheckOpenApiClient.excute(paperCheckSubmitRequest);
    }

    public static DownloadPaperCheckResponse download() {
        DownloadCheckSubmitRequest downloadCheckSubmitRequest = new DownloadCheckSubmitRequest.Builder()
                .setTaskId(taskId).bulider();
        return  paperCheckOpenApiClient.excute(downloadCheckSubmitRequest);
    }

    public static void main(String[] args) {
        try {
            BaseResponse result =  detectedPaperInfo();
            log.info("理工类论文模板.docx {}", objectMapper.writeValueAsString(result));
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
    }


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy