"megatron/training/tokenizer/bert_tokenization.py" did not exist on "b7f1b05071b041309f36698d197eaae54b9fcbea"
index.tsx 3.87 KB
Newer Older
dechen lin's avatar
dechen lin committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import UploadBg from "@/assets/imgs/online.experience/file-upload-bg.svg";
import style from "./index.module.scss";
import { ExtractorUploadButton } from "../pdf-upload-button";
import { useNavigate } from "react-router-dom";
import cls from "classnames";

import { SubmitRes } from "@/api/extract";
import { Checkbox, Popover } from "antd";

import { useIntl } from "react-intl";
import IconFont from "@/components/icon-font";

import { ADD_TASK_LIST } from "@/constant/event";
import { useState } from "react";

const PdfUpload = () => {
  const navigate = useNavigate();

  const { formatMessage } = useIntl();

  const [checked, setChecked] = useState(false);

  const afterUploadSuccess = (data: SubmitRes) => {
    navigate(`/OpenSourceTools/Extractor/PDF/${data?.id}`);
    setTimeout(() => {
      document.dispatchEvent(
        new CustomEvent(ADD_TASK_LIST, {
          detail: data,
        })
      );
    }, 10);
  };

  const afterAsyncCheck = async () => {
    return Promise.resolve(true);
  };

  return (
    <div className="w-full h-full flex flex-col relative items-center relative">
      <div className="w-full h-full flex flex-col  relative justify-center items-center translate-y-[-60px] z-0">
        <div className="mb-6 text-[1.5rem] text-[#121316] font-semibold">
          {formatMessage({ id: "extractor.pdf.title" })}
        </div>
        <div className="mb-12 text-[1.25rem] text-center text-[#121316]/[0.8] leading-[1.5rem]  max-w-[48rem]">
          {formatMessage({ id: "extractor.pdf.subTitle" })}
        </div>
        <ExtractorUploadButton
          accept=".pdf"
          taskType="pdf"
          afterUploadSuccess={afterUploadSuccess}
          afterAsyncCheck={afterAsyncCheck}
          extractType={"pdf"}
          isOcr={checked}
          text={
            <div
              className={cls(
                style.uploadSection,
                "border-[1px] border-dashed border-[#0D53DE] rounded-xl flex flex-col items-center justify-center"
              )}
            >
              <img src={UploadBg} className="mb-4" />

              <span
                className={cls(style.uploadText, "text-[18px] leading-[20px]")}
              >
                {formatMessage({ id: "extractor.common.upload" })}
              </span>
              <span
                className={cls(style.uploadDescText, "!mb-0 flex items-center")}
                onClick={(e) => {
                  e.preventDefault();
                  e.stopPropagation();
                }}
              >
                <Checkbox
                  className="mr-1"
                  checked={checked}
                  onClick={() => setChecked(!checked)}
                />
                {formatMessage({ id: "extractor.pdf.ocr" })}
                <Popover
                  content={
                    <div className="max-w-[20rem]">
                      {formatMessage({
                        id: "extractor.pdf.ocr.popover",
                      })}
                    </div>
                  }
                  placement="right"
                  showArrow={false}
                  overlayClassName={style.customPopover}
                >
                  <IconFont
                    type="icon-QuestionCircleOutlined"
                    className="text-[#121316]/[0.6] ml-1 text-[16px] hover:text-[#0D53DE]"
                  />
                </Popover>
              </span>
              {/* <span className={cls(style.uploadDescText)}>
                {formatMessage({ id: "extractor.common.pdf.upload.tip" })}
              </span> */}
            </div>
          }
          className={style.textBtn}
          showIcon={false}
        />
      </div>
      <div className="absolute bottom-[1.5rem] text-[13px] text-[#121316]/[0.35] text-center leading-[20px] max-w-[64rem]">
        {formatMessage({
          id: "extractor.law",
        })}
      </div>
    </div>
  );
};
export default PdfUpload;