Method and device for data processing, and storage medium
By integrating text, position, and graphic border features, the method and apparatus enhance the accuracy of structured text extraction from charts, overcoming the limitations of shallow fusion in existing technologies.
Patent Information
- Application Number
- US19/417227
- Authority / Receiving Office
- US · United States
- Patent Type
- Applications(United States)
- Current Assignee / Owner
- Priority Date
- 2025-05-27
- Filing Date
- 2025-12-11
- Publication Date
- 2026-12-03
AI Technical Summary
Existing chart analysis technologies fail to accurately extract structured data from multi-modal documents due to shallow fusion of images and text, leading to ambiguity and information omission.
A method and apparatus that acquire multi-modal information from charts, including text, position, and graphic border features, and fuse them using spatial, frequency domain, and image features to generate accurate structured text through a model.
Improves the accuracy and completeness of structured text extraction by integrating multi-source information, addressing the limitations of shallow fusion and enhancing the precision of chart recognition.
Smart Images

Figure US20260388301A1-D00000_ABST
Abstract
Description
CROSS-REFERENCE TO RELATED APPLICATION
[0001] This application claims priority to Chinese Patent Application No. 202510698114.6 filed on May 27, 2025, the disclosure of which is incorporated herein by reference in its entirety.BACKGROUND
[0002] With the development of artificial intelligence, the application scenarios of intelligent question-answering systems continue to expand in various industries, and users' demands for their functionalities are also gradually increased. In actual business and knowledge acquisition scenarios, a large number of documents often contain rich chart elements. These charts contain key data and information in an intuitive and visual form, and the documents contain such charts. When users need to ask questions and get answers about the information in the charts, the charts are required to be recognized into structured data.
[0003] When dealing with multi-modal information, existing chart analysis technologies often simply concatenate or perform shallow fusion of images and text information. For example, texts extracted using Optical Character Recognition (OCR) are only concatenated in series with the image features. As a result, the structured data obtained from chart recognition is not accurate enough and is prone to ambiguity or information omission.SUMMARY
[0004] The present application relates to the field of computer technologies, and more particularly to a method and a device for data processing, and a storage medium.
[0005] Embodiments of the present application provide a method and a device for data processing, and a storage medium, which fuses multi-modal information of chart graphics, text, and graphic border, thereby generating accurate and reliable structured text of chart.
[0006] In a first aspect, the embodiments of the application provide a method for data processing, which includes the following operations. A first text of a chart in a first document, first position information of the first text, and border information of a graphic of the chart are acquired. A first text feature of the first text is acquired. A spatial feature of a text box for the first text is determined according to the first position information. A second text feature is obtained according to the first text feature and the spatial feature of the text box. A frequency domain feature and an image feature of the chart are determined according to the chart and the border information of the graphic of the chart. A third text feature is obtained according to the second text feature, the frequency domain feature and the image feature of the chart. The third text feature is input into a model and a second text for the first document is obtained.
[0007] In a second aspect, the embodiments of the application provide a device for data processing, which includes a processor and a memory for storing a computer program code executable by the processor. The processor is configured to invoke and execute the computer program code from the memory to: acquire a first text of a chart in a first document, first position information of the first text, and border information of a graphic of the chart; acquire a first text feature of the first text; determine a spatial feature of a text box for the first text according to the first position information; obtain a second text feature based on the first text feature and the spatial feature of the text box; determine a frequency domain feature and an image feature of the chart according to the chart and the border information of the graphic of the chart; obtain a third text feature based on the second text feature, the frequency domain feature and the image feature of the chart; and obtain a second text for the first document by inputting the third text feature into a model.
[0008] In a third aspect, the embodiments of the present application provide a computer-readable storage medium having stored thereon a data processing program that, when executed by a processor, implements the method of the first aspect.BRIEF DESCRIPTION OF THE DRAWINGS
[0009] In order to more clearly explain the technical solutions in the embodiments of the present application or in the background, the accompanying drawings that need to be used in the embodiments of the present application or the background will be described below.
[0010] FIG. 1 is a schematic diagram of an architecture of a data processing system provided by an embodiment of the present application.
[0011] FIG. 2 is a flowchart of a method for data processing provided by an embodiment of the present application.
[0012] FIG. 3 is a flowchart of determining of a position encoding of a text box for a first text provided by an embodiment of the present application.
[0013] FIG. 4 is a flowchart of obtaining a mask for border information of a graphic provided by an embodiment of the present application.
[0014] FIG. 5 is a flowchart of obtaining a frequency domain feature of a chart provided by an embodiment of the present application.
[0015] FIG. 6 is a flowchart of obtaining an image feature of a chart provided by an embodiment of the present application.
[0016] FIG. 7 is a schematic structural diagram of an apparatus for data processing provided by an embodiment of the present application.
[0017] FIG. 8 is a schematic structure diagram of a device for data processing provided by an embodiment of the present disclosure.DETAILED DESCRIPTION
[0018] In order for the person skilled in the art to better understand the solutions of the present application, the technical solution in embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present disclosure. It is apparent that the described embodiments are part of the embodiments of the present application, but not all of them. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work shall fall within the scope of protection of the present application.
[0019] The terms “first”, “second”, and “third”, etc. in the specification, claims and drawings of the present application are used to distinguish from different objects, and are not used to describe a particular order. Furthermore, the terms “comprise” and “have” and any variations thereof are intended to cover non-exclusive inclusions. For example, processes, methods, systems, products, or apparatuses including a series of operations or units is not limited to the listed operations or units, but optionally further includes operations or units not listed, or optionally further includes other operations or units inherent to the processes, methods, products, or apparatuses.
[0020] Reference to an “embodiment” herein means that particular features, structures, or features described in connection with the embodiments may be included in at least one embodiment of the present application. The appearance of the wording in various places in the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment that is mutually exclusive from other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0021] With the development of artificial intelligence, the application scenarios of intelligent question-answering systems continue to expand in various industries, and users' demands for their functionalities are also gradually increased. In actual business and knowledge acquisition scenarios, a large number of documents often contain rich chart elements. These charts contain key data and information in an intuitive and visual form, and the documents contain such charts. When users need to ask questions and get answers about the information in the charts, the charts are required to be recognized into structured data.
[0022] When dealing with multi-modal information, existing chart analysis technologies often simply concatenate or perform shallow fusion of images and text information. For example, texts extracted using OCR are only concatenated in series with the image features. As a result, the structured data obtained by chart recognition is not accurate enough and is prone to ambiguity or information omission.
[0023] In view of the above problems, according to the method and apparatus for data processing provided by the embodiments of the present application, a first text of a chart in a first document, first position information of the first text, and border information of a graphic of the chart are acquired first. Then, a first text feature of the first text is acquired; a spatial feature of a text box for the first text is determined according to the first position information of the first text; a second text feature is obtained according to the first text feature and the spatial feature of the text box; a frequency domain feature and an image feature of the chart are determined according to the chart and the border information of the graphic of the chart; and a third text feature is obtained according to the second text feature, the frequency domain feature and the image feature of the chart. Finally, the third text feature is input into a model and a second text in the first document is obtained. By obtaining multi-source information such as chart text, its position and graphic border, the text feature, spatial feature, frequency domain feature and image feature are obtained based on the multi-source information, and these features are fused to obtain a comprehensive text feature, which is then input into a model to generate a text. In this way, the problems of shallow modal fusion and rough feature extraction in conventional methods are solved effectively, and thus the accuracy of extracting structured texts of the chart in the first document is significantly improved.
[0024] The method and apparatus for data processing provided by the embodiments of the present application may be applied to the data processing system as illustrated in FIG. 1. FIG. 1 is schematic diagram of an architecture of a data processing system provided by an embodiment of the present application. The data processing system 100 includes a client 101 and a server 102. The client 101 may communicate with the server 102 through a network, and the client 101 refers to a device used by users, such as a smart phone, a computer, etc. In this solution, the users may interact with the system through the client 101, and set or change parameters required for extraction of structured texts at the client 101, such as the size and overlapping degree of patches when patching is performed.
[0025] The server 102 refers to a remote computer for processing a large number of computing tasks and storing data. In this solution, the server 102 first acquires a first text of a chart in a first document, first position information of the first text, and border information of a graphic of the chart. Then, the server acquires a first text feature of the first text; determines a spatial feature of a text box in the chart based on the first position information of the first text; obtains a second text feature according to the first text feature and the spatial feature of the text box; determines a frequency domain feature and an image feature of the chart based on the chart and the border information of the graphic in the chart; and obtains a third text feature according to the second text feature, the frequency domain feature and the image feature of the chart. Finally, the server inputs the third text feature into a model and a second text in the first document is obtained.
[0026] On this basis, the present application provides a method and an apparatus for data processing, and the present application will be described in detail below with reference to the accompanying drawings.
[0027] FIG. 2 is a flowchart of a method for data processing provided by an embodiment of the present application. As illustrated in FIG. 2, the method includes the following operations S201 to S207.
[0028] At S201, a first text of a chart in a first document, first position information of the first text, and border information of a graphic in the chart are acquired.
[0029] The execution entity of the method may be the server 102 of the data processing system 100 illustrated in FIG. 1.
[0030] Herein, the first document may be a multi-modal document. The multi-modal document refers to a document containing two or more different types of modal information simultaneously, which synergistically expresses complete semantics. Common modalities include text (characters, symbols, formulas, etc.), images (photos, charts, illustrations, etc.), audio (voice, music, sound effects, etc.), video (moving images, animations, etc.), tables (structured data tables), interactive elements (hyperlinks, buttons, etc.). The first document may also be a document including only charts, which is not limited herein. The solution of the present application mainly focuses on the extraction of structured text from charts within the multi-modal documents.
[0031] Herein, acquiring the first text (such as coordinate axis labels, data annotations, legend descriptions, etc.) of the chart in the first document, the first position information of the first text, and the border information of the graphic in the chart may be implemented through Optical Character Recognition (OCR). Specifically, current mainstream OCR engines (such as Tesseract and PaddleOCR) support direct output of text and its position information. For graphic border extraction, it is extraction requires combining traditional computer vision (CV) and deep learning (DL) methods, where traditional CV segments graphic regions based on color and edge features, while the DL uses instance segmentation models, such as Mask R-CNN, to directly recognize graphics and their borders.
[0032] Herein, when acquiring the first text of the chart, DL models (such as DB and EAST algorithms) may be used to scan the chart region to detect positions of all text lines and generate text boxes (or Bounding Boxes). Each text box records the coordinate range (such as top-left corner and bottom-right corner coordinates) of the text. For content within the detected text boxes, character recognition is performed using models such as Convolutional Recurrent Neural Networks (CRNN), to convert the text in the image into editable text strings (i.e., the first text).
[0033] In addition to the basic coordinates of the text boxes, the first position information may further record precise position attributes of the text, such as the tilt angle of text lines, character spacing, and paragraph hierarchy of multi-line text, among other details, which are not limited herein.
[0034] When the chart is a bar chart, in order to extract the position information of pillars in the bar chart (including pillar boxes, that is, bounding boxes of the pillars), a computer vision library OpenCV may be used to analyze the picture of a chart to recognize and determine the positions of the pillars in the chart.
[0035] Specifically, the color bar chart is first converted into a grayscale image to reduce interference from color channels, and Gaussian Blur is used to remove noise in the image. The image is then converted to a binary image by using Otsu's Method, and a significant contrast is formed between the pillars and the background. Afterwards, edges within the image are detected using Canny edge detection, to highlight the contours of the pillars. The findContours function is used to find all continuous contours in the image. Based on features such as contour area and aspect ratio, contours that match the features of the pillars are filtered (excluding noise or irrelevant elements). Finally, for each of the filtered contours, the minimum bounding rectangle (minAreaRect) is calculated and the Bounding Box of each pillar is obtained. The position information of the pillars=(top-left coordinates, width, height) is extracted from the minimum bounding rectangle.
[0036] In addition to the above method, other methods may be used to acquire the first text of the chart in the first document, the first position information of the first text, and the border information of the graphic of the chart, and are not limited herein.
[0037] At S202, a first text feature of the first text is acquired.
[0038] In a possible implementation, acquiring a first text feature of the first text includes that: all characters in the first text are concatenated into a long text sequence; the long text sequence is converted into a numerical sequence; and the numerical sequence is encoded into the first text feature.
[0039] Specifically, after obtaining the first text, special symbols (such as garbled characters), irrelevant punctuation marks (such as continuous commas), etc. generated by mistaken recognition of OCR may be filtered out first, followed by text normalization and segmentation into paragraphs and sentences. All text fragments are then concatenated into a continuous long text sequence based on their spatial order in the chart (such as left to right, top to bottom). For example, if the original text fragment is [“Q1”, “revenue”, “increased by”, “15%”, “in 2025”], then the concatenated long text sequence is “Q1 revenue increased by 15% in 2025”.
[0040] Tokenizer of the Chinese word segmentation model roformer_v2_chinese_char_base may be used to segment the concatenated long text into character-level units, and map them to corresponding numerical sequences (Token IDs), while automatically adding a start token [CLS] and an end token [SEP] to mark text boundaries. Herein, RoFormer_v2 is a pre-trained model based on Transformer architecture, and adopts character-level word segmentation (Chinese Character Base). The processing steps are as follows:
[0041] Load pre-trained tokenizer: initializing a tokenizer based on roformer_v2_chinese_char_base, which supports Chinese character Base.
[0042] Add special Tokens: automatically adding special markers, such as [CLS] (classification marker, for overall semantic representation) and [SEP] (separation marker, for identifying the end of the text), at the start and end of the concatenated long text.
[0043] Chinese Character Base: segmenting text by characters (e.g., “Q1 in 2025”→[“Q”, “1”, “i”, “n”, “2”, “0”, “2”, “5”]). When processing out-of-vocabulary words (such as rare characters), the tokenizer will segment them into individual characters or use pre-trained sub-word units.
[0044] Map numerical ID: mapping each character to a corresponding numerical ID according to the vocabulary of roformer_v2.
[0045] Generate Token type and position encoding: Token-type IDs identify different text fragments (such as questions and answers in Q&A pairs), here all set to 0 (single text input). Simultaneously, position information for each token is generated using Reformer: Rotary Position Encoding (RoPE).
[0046] The numerical sequence may be processed using an encoding module within the roformer_v2_chinese_char_base model to generate a feature vector embedding_char that contains textual semantics and structural information. This vector is extracted through a deep neural network in the pre-trained model, which can capture the semantic association between characters (such as the relationship between “revenue” and “increased by”) and contextual structure, provide key input at the textual semantic level for subsequent multi-modal feature fusion.
[0047] It can be seen that in this example, the first text is concatenated into a sequence, then the sequence is converted into numerical form and it is then encoded to obtain the first text feature, which can effectively integrate scattered information within the chart text, while converting into the numerical sequence can facilitate computer processing. Finally, the semantic and structural features of the text are refined by encoding, so that the core meaning of the text is preserved, thereby improving the accuracy and completeness in subsequent extraction of the structured text from the chart.
[0048] At S203, a spatial feature of a text box for the first text is determined according to the first position information.
[0049] Herein, the spatial feature of the text box includes position encoding of the text box, width feature of the text box and height feature of the text box. The position encoding refers to coordinate position information of the text box in a page or chart (such as top-left corner coordinates (x1, y1) and bottom-right corner coordinates (x2, y2)), and the position encoding is used to characterize the spatial position relationship of the text box. The width feature refers to horizontal dimension of the text box, representing the horizontal distribution range of text content. The height feature refers to the vertical dimension of the text box, representing the number of lines or vertical density of the text content.
[0050] In a possible implementation, the determining a spatial feature of a text box for the first text according to the first position information includes: determining a position encoding of the text box for the first text according to the first position information; and determining a width feature and a height feature of the text box for the first text according to the first position information.
[0051] When determining the position encoding of the text box, coordinate data of the text box within the chart, such as top-left corner coordinates, bottom-right corner coordinates, is extracted according to the first position information of the first text. These coordinate data are normalized to be mapped to the range of 0-1, so that they have a unified scale standard. Or, relative coordinates are used to calculate the positional relationship of the text box with respect to the overall boundary of the chart or specific reference points, and are finally converted into encoding information that may represent the specific positions of text boxes within the chart.
[0052] When determining the width feature and the height feature of the text box, the top-left corner and bottom-right corner coordinates of the text box may be obtained according to the first position information of the first text. Then, the width feature and the height feature may be obtained by simple numerical calculation as follows. That is, the width of the text box is the difference between the abscissa of the bottom-right corner and the abscissa of the top-left corner, and the height of the text box is the difference between the ordinate coordinate of the bottom-right corner and the ordinate coordinate of the top-left corner feature, accurate numerical values of the width and height are obtained. These numerical values are then encoded to obtain the width feature and the height feature.
[0053] As can be seen, in the example, by using the first position information of the first text to determine the position encoding, the width feature, and the height feature of the text box, the spatial layout information of the first text within the chart can be quantified and digitally expressed. This provides spatial dimensional data support for subsequent multi-modal information fusion, so that the model can not only understand the semantic content of the text, but also combine its spatial attributes such as specific position and size in the chart, so as to more accurately grasp the association between the text and other elements in the chart, thereby improving the accuracy in extraction of structured text from the chart.
[0054] In a possible implementation, referring to FIG. 3, FIG. 3 is a flowchart of determining a position encoding of a text box for a first text provided by an embodiment of the present application. As illustrated in FIG. 3, determining the position encoding of the text box for the first text according to the first position information of the text includes the following operations S301, S302 and S303.
[0055] At S301, vertex coordinates of a text box for the first text are acquired according to the first position information.
[0056] At S302, center coordinates of the text box for the first text are acquired according to vertex coordinates of the text box of the first text.
[0057] At S303, the position encoding of the text box is obtained by encoding the vertex coordinates and the center coordinates of the text box.
[0058] When processing text information in the chart, based on the first position information of the first text (that is, original coordinate data of the first text in the chart), four vertex coordinates (which are usually the top-left corner, top-right corner, bottom-right corner, and bottom-left corner coordinates) of the text box are first extracted. These coordinates accurately define the boundary range of the first text in the two-dimensional space. Then, coordinates of a center point within the text box are further determined based on the four vertex coordinates of the text box, and the calculation method may be determining the center coordinates of the border box by calculating the average value of the vertex coordinates.
[0059] Herein, the vertex coordinates and center coordinates are encoded, that is, the numerical coordinate data is converted into vector representations understandable by the model. Normalization (e.g., mapping coordinate values to the range of 0-1), embedding mapping (e.g., through a pre-trained position embedding layer), or other feature engineering methods may be adopted in the encoding process to transform the coordinate data into position encoding vectors with semantic meanings. Herein, coordinate features (position encoding) obtained after encoding are embedding_left (corresponding to the left side), embedding_right (corresponding to the right side), embedding_top (corresponding to the top side), embedding_bottom (corresponding to the bottom side), and embedding_center (corresponding to the center).
[0060] Preferably, encoding the vertex coordinates and the center coordinates may be implemented using nn.Embedding. PyTorch's nn.Embedding is a commonly used method for converting discrete coordinate values into continuous dense vectors. Specifically, first, it is necessary to normalize and discretize the vertex coordinates (such as the horizontal and vertical coordinates of the four vertices of the quadrilateral) and the center coordinates of the text box, and convert them into discrete integer indexes (such as mapping to the range of [0, vocabulary size)). Then, these integer indexes are mapped to low-dimensional continuous vectors (i.e. coordinate embedding vectors) through a predefined Embedding Layer.
[0061] It can be seen that in this example, by extracting and encoding the vertex and center coordinates of the text bounding box, spatial position features of the first text in the chart can be comprehensively captured. The position encoding not only preserves the absolute position information of the first text, but also implies its relative positional relationship, which provides rich spatial context for the multi-modal model. This allows the model to combine the semantic content and spatial layout of the text when analyzing the chart, to more accurately infer the association between the text and other elements, thereby significantly improving the accuracy in structured analysis and information extraction of charts.
[0062] In a possible implementation, determining the width feature and the height feature of the text box for the first text according to the first position information includes: obtaining vertex coordinates of the text box for the first text according to the first position information; obtaining a width and height of the text box for the first text by acquiring a difference between bottom-right corner coordinates and top-left corner coordinates of the text box for the first text; encoding the width to obtain the width feature of the text box for the first text; and encoding the height to obtain the height feature of the text box for the first text.
[0063] When processing text information in the chart, four vertex coordinates (which are usually the top-left corner, the top-right corner, the bottom-right corner, and the bottom-left corner coordinates) of the text box are first extracted based on the first position information of the first text (that is, the original coordinate data of the text in the chart). These coordinates accurately define the boundary range of the first text in the two-dimensional space. Then, coordinates of the center point of the text box are further determined based on the four vertex coordinates of the text box, and its calculation method may be determining the center coordinates of the border box by calculating the average value of the vertex coordinates.
[0064] Herein, the height and width of the text box may be directly calculated by four vertex coordinates of the text box. Generally, the width of the text box may be directly calculated by subtracting the abscissa of the top-left corner of the text box from the abscissa of the bottom-right corner of the text box, and the height of the text box may be obtained by subtracting the ordinate of the top-left corner of the text box from the ordinate of the bottom-right corner of the text box.
[0065] An encoding function (such as nn.Embedding or normalized mapping) may be used to convert the calculated width value into a fixed-dimensional vector, that is, the width feature embedding_width. Similarly, an encoding function (such as nn.Embedding or normalized mapping) may be used to convert the calculated height value into a fixed-dimensional vector, that is, the height feature embedding_height.
[0066] It can be seen that in the present example, by extracting and encoding the width and height of the text box, the spatial dimension information of the text can be converted into semantic features understandable by the model. The features preserve the physical dimensions of the text in the chart; and combined with the position encoding, the model can more comprehensively understand the layout structure of the text in the chart, so that the association between the text and other elements (such as graphics and legends) can be inferred accurately during multi-modal fusion, and thus the accuracy of chart structured analysis is significantly improved.
[0067] At S204, a second text feature is obtained according to the first text feature and the spatial feature of the text box.
[0068] Fusing the first text feature (such as semantic features of the text, character embeddings, etc.), position encoding, width feature and height feature of the text box to obtain the second text feature may be implemented using concatenation, transformation or attention mechanism.
[0069] Herein, different modalities of features may be directly concatenated in dimensions to form a composite feature containing both the semantic and spatial information. The concatenation includes simple concatenation and hierarchical concatenation.
[0070] Specifically, in simple concatenation, the first text feature (such as a word embedding vector with dimension D1), a position encoding vector (with dimension D2), a width feature vector (with dimension D3), and a height feature vector (with dimension D4) are concatenated along the feature dimension, to obtain a second text feature with dimension D1+D2+D3+D4. In hierarchical concatenation, similar features are grouped and concatenated first (for example, the position encoding and width and height features are concatenated first to form a “spatial feature”, which is then concatenated with the semantic features). For example, spatial feature=[position encoding; width feature; height feature], second text feature=[first text feature; spatial feature].
[0071] Herein, Linear transformation or non-linear activation functions may be used to map multi-modal features into the same semantic space for fusion. Common methods include fully connected layer fusion (FC Layer Fusion) and Scaled Addition.
[0072] Specifically, in FC Layer Fusion, the first text feature, position encoding, width feature, and height feature are concatenated into a long vector v, and then dimensionality reduction and feature interaction are performed on the long vector v through fully connected layer (FC) and activation function (such as ReLU) to obtain the final second text feature. In Scaled Addition, the position encoding, width feature, and height feature are each subjected to linear transformation (e.g., via Wp, Ww, Wh transformations) to align their dimensions with those of the first text features. Finally, the transformed features are added to the first text feature to obtain the second text feature.
[0073] Herein, the importance weights of different features may be automatically learned using the attention mechanism to achieve fusion. Specifically, in Self-Attention Fusion, the first text feature, the position encoding, the width feature, and the height feature are treated as different “Query-Key-Value” pairs. Then, the weights for each feature are calculated using the self-attention mechanism, and weighted summation is performed to obtain the second text feature.
[0074] At S205, a frequency domain feature and an image feature of the chart are determined according to the chart and the border information of the graphic of the chart.
[0075] Herein, Frequency Domain Features are based on the spatial distribution law of border information. Spatial domain signals are converted into frequency domain signals by using methods such as Fourier transform, to extract periodic, repetitive or regular frequency components.
[0076] Image Features are features extracted based on the visual presentation of charts (e.g., pixel values, edges, textures, shapes), which can be realized through traditional computer vision algorithms or deep learning models.
[0077] In a possible implementation, the determining a frequency domain feature and an image feature of the chart according to the chart and border information of a graphic of the chart includes:
[0078] processing the border information of the graphic to obtain a mask for the border information of the graphic; obtaining the frequency domain feature of the graphic according to the mask and the chart; and obtaining the image feature of the graphic according to the chart.
[0079] Herein, the mask is a binary matrix having the same size as the chart image, where the border region pixels have a value of 1 (or are highlighted), and non-border regions have a pixel value of 0 (or are transparent). Specifically, based on coordinates of the bounding box of the graphic (e.g., vertices, line segment endpoints), a mask may be generated on a blank canvas through polygon filling algorithm or contour drawing, only the spatial position information of the border is preserved, and interference elements such as internal filling colors and text content within the chart are filtered out.
[0080] Herein, the chart is subjected to Fourier transform, and then the mask for the border information of the graphic is multiplied by the result of the Fourier transform. This product then undergoes an inverse Fourier transform, and a frequency domain feature embedding vector Embedding_frequency is obtained.
[0081] It can be seen that in this example, by using the mask to separate the border structure and combining multi-level analysis of frequency domain and image features, the frequency domain can be used to capture the border while preserving the visual details of the border through image features. Therefore, an accurate description of the chart structure is achieved.
[0082] In a possible implementation mode, referring to FIG. 4, FIG. 4 is a flowchart of obtaining a mask for border information of a graphic provided by an embodiment of the present application. As illustrated in FIG. 4, processing the border information of the graphic to obtain a mask for the border information of the graphic includes the following operations S401 to S405.
[0083] At S401, a feature vector of the border information of the graphic is obtained by performing feature extraction on the border information of the graphic.
[0084] Herein, when performing feature extraction on the border information of graphics, it is necessary to convert the border information of the graphic into a feature vector, which may be obtained using feature engineering calculation by taking the geometric attributes (such as vertex coordinates, aspect ratio, area) of the border as input.
[0085] Specifically, feature engineering may involve calculating statistic metrics, such as center point coordinates, border circumference, and eccentricity (for determining shape regularity), or spatial relationship encoding: distances between borders, angular differences (for determining connectivity).
[0086] Preferably, the border information of the graphic may be input to a boundary operator module, and the module processes the border information of the graphic through a Multilayer Perceptron (MLP) module. The MLP module is a feedforward model based on artificial neural network, which consists of an input layer, a plurality of hidden layers and an output layer. Each layer contains multiple neurons and utilizes non-linear activation functions to achieve complex pattern recognition and function approximation capabilities. The MLP may perform feature extraction and transformation on the features of the image.
[0087] At S402, numerical values in the feature vector are converted into a probability distribution array.
[0088] Herein, when converting the feature vectors into a probability distribution (a non-negative array with a sum of 1), the feature vector may be input to a Softmax module, and the Softmax function within the Softmax module may convert the result output by the MLP into a probability distribution, thereby obtaining an array.
[0089] Specifically, the Softmax function is:pi=exp(xi)∑ j=1Nexp(xj)
[0090] Herein, xi is an i-th element of the feature vector, pi is a probability value corresponding to the i-th element of the feature vector. Multiple probability groups are integrated to obtain a probability distribution array, and the sum of all values in the probability distribution array is 1.
[0091] At S403, the probability distribution array is used as a weight and multiplied by a preset first filter bank to obtain a second filter bank.
[0092] Herein, the number of filters in the first filter bank is the same as the length of the probability distribution array, for example, when the length of the probability distribution array is 10, the number of filters in the first filter bank is also 10. At this time, each of numerical values in the probability distribution array is used as a weight and multiplied by a respective filter at a corresponding position in the first filter bank to obtain a second filter bank.
[0093] Specifically, a set of filters with different functions (e.g., Gaussian filter, Laplacian filter, directional gradient filter) are predefined, and the number of the filters is consistent with the length of the probability distribution array. The calculation formula of the weighting operation is:f2i=pi·f1i.
[0094] Herein, f2i is an i-th filter of the second filter bank, pi is a probability value corresponding to the i-th element of the feature vector, f1i is the i-th filter of the first filter bank.
[0095] At S404, multiple first filters in the second filter bank are added to obtain a second filter.
[0096] Herein, multiple weighted filters may be combined into a comprehensive filter to balance the contributions from different features.
[0097] At S405, the second filter is processed through multilayer perceptron (MLP) to obtain a mask for the border information of the graphic.
[0098] When the second filter is processed using MLP, assuming that the second filter is a multi-dimensional tensor, the multi-dimensional structure of the second filter needs to be first flattened into a one-dimensional vector. A typical MLP structure includes an input layer, hidden layers and an output layer, and each layer implements non-linear transformation through full-connected layers and activation functions. Then, the flattened one-dimensional vector is used as the input to the MLP, and the final output of the MLP serves as the mask of the border information of the graphic.
[0099] It can be seen that in this example, converting features into a probability distribution and utilizing probability-weighted filter fusion enhances adaptability to different types of border structures. Finally, the mask is generated using MLP mechanism to effectively highlight the border regions. By combining filters and the MLP, this approach achieves precise capture of complex graphic structures while significantly reducing background interference, thereby providing high-quality border feature representations for subsequent extraction of structured text from charts.
[0100] In a possible implementation, referring to FIG. 5, FIG. 5 is a flowchart for obtaining frequency domain features of a chart provided by an embodiment of the present application. As illustrated in FIG. 5, obtaining the frequency domain feature of the chart according to the mask and the chart includes the following operations S501 to S504.
[0101] At S501, Fourier transform is performed on the graphic to obtain a first result.
[0102] Herein, the principle of Fourier transform is to convert an image from the spatial domain (pixel value matrix) to the frequency domain (distribution of frequency components). In the frequency domain, low-frequency components correspond to gradually changing areas in the image (such as large-area background, smooth contour), while high-frequency components correspond to rapidly changing edges and details (such as borders, text, coordinate axes) in the image.
[0103] The first result obtained by performing a Fourier transform on the graphic may be a complex matrix, which includes an amplitude spectrum (representing the strength of each frequency component) and a phase spectrum (representing positions for each frequency component).
[0104] At S502, the mask is multiplied by respective elements in the first result to obtain a second result.
[0105] The mask may be a binary matrix, where 1 means “preserve” and 0 means “suppress”. The frequency domain result is multiplied by the mask element by element, and the frequency components related to the border are preserved selectively. For example, if the mask covers high-frequency edges of the border, these components are preserved while background noise (such as filling color, text content) is suppressed.
[0106] At S503, inverse Fourier transform is performed on the second result to obtain a third result.
[0107] Herein, the inverse Fourier transform is to restore the processed frequency domain features back to the spatial domain to generate an image focused on the border. If high-frequency components of the first result are preserved, the border edge of the image after inverse transformation will be clearer. If low-frequency components of the first result are preserved, the image subject to inverse transformation will present a blurred overall contour.
[0108] At S504, the third result is encoded to obtain the frequency domain feature of the chart.
[0109] Herein, after the inverse Fourier transform is completed in operation S503, the third result obtained is a processed spatial domain image. Through the mask operation in the frequency domain, this image is now focused on features related to the border (such as edges and textures). If the mask preserves high-frequency components, the edge of the border in the image will be more prominent. If the low-frequency components are preserved, a smooth contour structure will be presented.
[0110] Specifically, the specific flow of converting the spatial domain image into a frequency domain feature embedding vector is as follows:
[0111] Preprocessing and normalization: Grayscale conversion (if it is a color image), a multi-channel image is converted into a single-channel grayscale image, and pixel values are scaled to a fixed range (such as [0, 1] or [−1, 1]).
[0112] Size adjustment: the image is resized to a uniform dimension to ensure consistent input size.
[0113] Feature extraction networks (e.g. CNN): image features are extracted using a pre-trained model (e.g. ResNet, VGG).
[0114] Visual Transformer (ViT): the image is partitioned into patches, then encoded by a Transformer.
[0115] Global average pooling (GAP): feature maps are compressed into a one-dimensional vector.
[0116] Linear projection: the feature dimension is reduced to the target size via a fully connected layer and the final frequency domain feature is obtained.
[0117] It can be seen that in this example, the charted is transformed from the spatial domain to the frequency domain through the Fourier transform, separating the low-frequency contours from the high-frequency details. Then, through mask operation, key frequency components such as borders are preserved while background noise interference is suppressed. Finally, the processed frequency domain information is transformed back to the spatial domain by inverse Fourier transform to highlight the structural features of the chart. Through a series of processes such as Fourier transform, mask operation, inverse Fourier transform and encoding, frequency domain features of the chart is precisely extracted.
[0118] In a possible implementation mode, referring to FIG. 6, FIG. 6 is a flowchart of obtaining image features of a chart provided by an embodiment of the present application. As illustrated in FIG. 6, obtaining image features of the chart according to the chart includes the following operations S601 and S602.
[0119] At S601, the graphic is segmented into multiple blocks according to a preset patch size and a patch overlapping degree.
[0120] When performing patch segmentation on a chart, it is necessary to predefine the size of each resulting sub-block (e.g., 224×224 pixels) to control the granularity of local features, as well as the overlapping ratio of pixels between adjacent sub-blocks (e.g., 20% overlap).
[0121] Specifically, the segmentation may be implemented by patching using a sliding window according to a fixed step size (for example, step size=patch size×(1−overlapping ratio)), so as to ensure full coverage of the entire image and consistent overlap regions. For example, if the patch size is 224×224 and the overlapping ratio is 20%, the step size for the adjacent blocks in the horizontal and vertical directions is 224×0.8=179 pixels.
[0122] At S602, features of the plurality of blocks are aggregated to obtain the image feature of the chart.
[0123] Herein, features are extracted individually for each sub-block (e.g., through the convolutional layers of a CNN or patch embedding of a Transformer) to obtain local feature vectors. These local features are then aggregated to form the global image feature of the chart.
[0124] Specifically, the aggregation method may include:
[0125] Average pooling: the average value of all sub-block features is calculated, and the common features are used as the image feature of the chart.
[0126] Maximum pooling: the maximum value for each dimension is selected, and the most prominent feature is preserved as the image feature of the chart.
[0127] Attention mechanism: weights are assigned to different sub-blocks (for example, blocks containing text have higher weights) using self-attention or cross-block interaction mechanism, and weighted summation is then performed to generate a global feature, thereby obtaining the image feature of the chart.
[0128] Hierarchical concatenation: local features are grouped and aggregated (for example by row / column), then recursively merged into a global feature to obtain the image feature of the chart.
[0129] It can be seen that in this example, by segmenting the chart into blocks according to preset parameters and feature aggregation, effective fusion of multi-scale information is realized. The patching operation enables to capture local details and global structure by controlling the patch size, while the overlapping setting can preserve the integrity of cross-block edge features. As for the feature aggregation, it suppresses local noise through statistical methods or attention mechanisms, integrates semantic and layout information of different regions, and generates a global feature vectors, which facilitates improving the accuracy of subsequent analysis for complex scenes by models.
[0130] At S206, a third text feature is obtained according to the second text feature, the frequency domain feature and the image feature of the chart.
[0131] Herein, obtaining the third text feature according to the second text feature, the frequency domain feature and the image feature of the chart may be implemented using the method such as concatenation, transformation, or attention mechanism.
[0132] Herein, different modalities of features may be directly concatenated in dimensions to form a composite feature containing both the semantic and spatial information. The concatenation includes simple concatenation and hierarchical concatenation.
[0133] Specifically, in simple concatenation, the second text feature, the frequency domain feature and the image feature of the chart are concatenated along the feature dimension to obtain the third text feature. In hierarchical concatenation, similar features are grouped and concatenated first (for example, the frequency domain features and image features of the chart are concatenated first, then concatenated with the second text feature).
[0134] Linear transformation or non-linear activation functions may be used to map multi-modal features into the same semantic space for fusion. Common methods include fully connected layer fusion (FC Layer Fusion) and Scaled Addition.
[0135] Specifically, in FC Layer Fusion, the second text feature, frequency domain features and image features of the chart are concatenated into a long vector v, and then dimensionality reduction and feature interaction are performed on the long vector v through fully connected layer (FC) and activation function (such as ReLU), and the second text feature is obtained finally. In scaled addition, the position encoding, width feature, and height feature are each subjected to linear transformation (e.g., via Wp, Ww, Wh transformations) to align their dimensions with those of the second text features. Finally, the transformed features are added to the first text feature to obtain the second text feature.
[0136] Herein, the importance weights for different features may be automatically learned using the attention mechanism to achieve fusion. Specifically, in Self-Attention Fusion, the second text feature, the frequency domain features and image features of the chart are treated as different “Query-Key-Value” pairs. Then, the weights for each feature are calculated using the self-attention mechanism, and weighted summation is performed to obtain the third text feature.
[0137] At S207, the third text feature is into a model to obtain the second text of the first document.
[0138] Herein, the model is a transformer-based image-to-text generation model, and its core is an Encoder-Decoder architecture, including an image encoding module composed of multiple transformer layers. The transformer layer has powerful feature extraction and processing capabilities, and it can perform in-depth analysis and encoding on image-related features. The processed feature are then inputted into a text decoding module composed of multiple transformer layers, which decodes the encoded features and outputs corresponding text features, and the second text of the first document is obtained.
[0139] During model training, sample pairs containing chart images (such as histograms, flowcharts) and their corresponding structured text descriptions are collected. These sample pairs are continuously input into the model and parameters of the model are adjusted so that the model's output increasingly approximates the true text content, i.e., the difference between the output text of the model and the real annotation is minimized, until the model converges and reaches a stable state.
[0140] Regarding pre-training of an image encoder, large-scale image datasets (such as ImageNet) may be used to pre-train the Transformer layers, allowing them to learn general visual features. For end-to-end fine-tuning, the image encoder and text decoder may be jointly trained using multimodal datasets to optimize the quality of text generation.
[0141] It can be seen that in this example, multi-source information such as chart text, position, and graphic border, text features, spatial features, frequency domain features, and image features are obtained based on the multi-source information, and these features are fused to obtain a comprehensive text feature, which is input into a model to generate text. In this way, the problems of shallow modal fusion and rough feature extraction of traditional methods are solved, and thus the accuracy of the structured text of the chart in the extracted first document is significantly improved.
[0142] Referring to FIG. 7, FIG. 7 is a schematic structural diagram of an apparatus for data processing provided by an embodiment of the present application. As illustrated in FIG. 7, the data processing apparatus 700 includes an acquisition module 701 and a determination module 702.
[0143] The acquisition module 701 is configured to: acquire a first text of a chart in a first document, first position information of the first text, and border information of a graphic of the chart; and acquire a first text feature of the first text.
[0144] The determination module 702 is configured to: determine a spatial feature of a text box for the first text according to the first position information; obtain a second text feature based on the first text feature and the spatial feature of the text box; determine a frequency domain feature and an image feature of the chart according to the chart and the border information of the graphic of the chart; obtain a third text feature based on the second text feature, the frequency domain feature and the image feature of the chart; and obtain a second text of the first document by inputting the third text feature into a model.
[0145] In a possible implementation, when obtaining the first text feature of the first text, the acquisition module 701 is specifically configured to: concatenate all characters in the first text into a long text sequence; convert the long text sequence into a numerical sequence; and encode the numerical sequence to obtain the first text feature.
[0146] In a possible implementation, the spatial feature includes a position encoding, a width feature, and a height feature. When determining the spatial feature of the text box for the first text according to the first position information, the determination module 702 is specifically configured to: determine the position encoding of the text box for the first text according to the first position information; and determine the width feature and the height feature of the text box for the first text according to the first position information.
[0147] In a possible implementation, when determining the position encoding of the text box for the first text according to the first position information, the determination module 702 is specifically configured to: acquire vertex coordinates of the text box for the first text according to the first position information; acquire center coordinates of the text box according to the vertex coordinates of the text box for the first text; and encoding the vertex coordinates and the center coordinates of the text box to obtain the position encoding of the text box.
[0148] In a possible implementation, when determining the width feature and the height feature of the text box for the first text according to the first position information, the determination module 702 is specifically configured to: acquire vertex coordinates of the text box for the first text according to the first position information; obtain width and height of the text box for the first text by acquiring a difference between bottom-right corner coordinates and top-left corner coordinates of the text box for the first text; encoding the width to obtain the width feature of the text box for the first text; and encoding the height to obtain the height feature of the text box for the first text.
[0149] In a possible implementation, when determining frequency domain feature and the image feature of the chart according to the chart and the border information of the graphic of the chart, the determination module 702 is specifically configured to: process the border information of the graphic to obtain a mask for the border information of the graphic; obtain the frequency domain feature of the graphic according to the mask and the chart; and obtain the image feature of the graphic according to the chart.
[0150] In a possible implementation, when processing the border information of the graphic to obtain a mask for the border information of the graphic, the determination module 702 is specifically configured to: obtain a feature vector for the border information of the graphic by performing feature extraction on the border information of the graphic; convert numerical values in the feature vector into a probability distribution array; multiply the probability distribution array as weights by a preset first filter bank to obtain a second filter bank, where the number of filters in the first filter bank is the same as the length of the probability distribution array; add multiple first filters in the second filter bank to obtain a second filter; and process the second filter using a multilayer perceptron mechanism to obtain the mask for the border information of the graphic.
[0151] In a possible implementation, when obtaining frequency domain feature of the graphic according to the mask and the chart, the determination module 702 is specifically configured to: perform Fourier transform on the chart to obtain a first result; multiply the mask by a respective element in the first result to obtain a second result; perform inverse Fourier transform on the second result to obtain a third result; and encode the third result to obtain the frequency domain feature of the chart.
[0152] In a possible implementation, when obtaining the image feature of the chart according to the chart, the determination module 702 is specifically configured to: segment the chart into multiple blocks according to a preset patch size and a patch overlapping degree; and aggregate features of the multiple blocks to obtain the image feature of the chart.
[0153] It is to be noted that for the specific implementation of functions of data processing apparatus 700, reference may be made to the descriptions of the date processing method illustrated in FIG. 2. For example, the acquisition module 701 is configured to perform related contents of S201 and S202, and the determination module 702 is configured to perform related contents of S203 to S207. Various units or modules in the data processing apparatus 700 may be separately or entirely merged into one or several additional units or modules, or a certain unit(s) or module(s) may be further divided into multiple functionally smaller units or modules, which can realize the same operation without affecting the realization of the technical effects of the embodiments of the present invention. The above units or modules are divided according to logical functions. In practical applications, functions of one unit (or module) are implemented by multiple units (or modules), or functions of multiple units (or modules) are implemented by one unit (or module).
[0154] According to the description of the above method embodiments and related device embodiments, referring to FIG. 8, FIG. 8 is a structural diagram of a device for data processing provided by an embodiment of the present application. As illustrated in FIG. 8, the data processing device 800 includes a processor 801, a memory 802, a communication interface 803, and a bus 804. Herein, the processor 801, the memory 802, and the communication interface 803 realize communication connection with each other through the bus 804.
[0155] Optionally, the memory 802 is a read only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM).
[0156] The memory 802 can store an executable program code. When the executable program code stored in the memory 802 is executed by the processor 801, the processor 801 and the communication interface 803 perform various operations of the data processing method of the embodiment as illustrated in FIG. 2.
[0157] The processor 801 employs a general-purpose CPU, a microprocessor, an application-specific integrated circuit (ASIC), a graphic processing unit (GPU), or one or more integrated circuits, and is configured to execute related programs to perform the data processing method according to the method embodiments of the present application.
[0158] The processor 801 may be an integrated circuit chip having signal processing capabilities. In implementation, various operation of the data processing method of the present application may be accomplished by integrated logic circuitry of hardware in the processor or instructions in the form of software. Optionally, the processor 801 is a general-purpose processor, a digital signal processor (DSP), an ASIC, an field programmable gate array (FPGA) or other programmable logic devices, a discrete gate or transistor logic device, or a discrete hardware component. The processor may implement or perform the methods, operations and logic diagrams disclosed in the embodiments of the present application. The general purpose processor may be a microprocessor or any conventional processor. The operations of the methods disclosed in the embodiments of the present application may be directly embodied as being executed by a hardware decoding processor or executed by hardware and software modules in a decoding processor. Optionally, the software modules may be located within a storage medium mature in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register or other storage media mature in the art. The storage medium is located in the memory 802. The processor 801 reads information from the memory 802, and combines the hardware thereof to complete the functions required by the modules included in the data processing apparatus 700 according to the embodiments of the present application, or performs the data processing method according to the embodiments of the method of the present application.
[0159] The communication interface 803 uses transceiver-related devices such as, but not limited to, transceivers.
[0160] The bus 804 may include paths for communicating information along various components (e.g., the memory 802, the processor 801, the communication interface 803) of the data processing device 800.
[0161] It should be noted that although the data processing device 800 in FIG. 8 only illustrates a memory, a processor, and a communication interface, it should be understood by those skilled in the art that in the specific implementation, the data processing device 800 also includes other devices necessary to achieve normal operations. At the same time, it should be understood by those skilled in the art that the data processing device 800 may also include hardware devices that implement other additional functions, depending on specific needs. In addition, it should be understood by those skilled in the art that the data processing device 800 may also include only the components necessary to implement the embodiments of the present application, and does not necessarily include all the components illustrated in FIG. 8.
[0162] Embodiments of the present application provide a computer-readable storage medium, having stored therein a computer program for electronic data exchange, where the computer program includes executable instructions for executing part or all of the operations of any one of the data processing methods as described in the above-described embodiments. The above computer includes an electronic client device.
[0163] Embodiments of the present application provide a computer program product, where the computer program product includes a computer program operable to cause a computer to perform part or all of the operations of any one of the data processing methods as described in the above method embodiments. The computer program product may be a software installation package.
[0164] It should be noted that, for the sake of simplicity of description, the above-described embodiments of any of the data processing methods are expressed as a series of combinations of operations, but it should be understood by those skilled in the art that the present application is not limited by the described execution orders of the operations, because some operations may be performed in other orders or simultaneously according to the present application. Secondly, it should also be understood by those skilled in the art that the embodiments described in the specification are all preferred embodiments, and the operations involved therein are not necessarily required for the present application.
[0165] The embodiments of the present application have been described in detail above, and the principles and implementations of the data processing method and apparatus of the present application have been described herein by applying specific examples. The descriptions of the above embodiments are only used for helping to understand the method of the present application and its core idea. Meanwhile, for those skilled in the art, variations may be made on the specific embodiments and applied scopes according to the idea of the data processing method and apparatus of the present application. In summary, the contents of the specification should not be construed as limiting the present application.
[0166] The present application is described with reference to flowcharts and / or block diagrams of the methods, hardware products, and computer program products in the embodiments of the present application. It should be understood that each flow and / or block in the flowchart and / or block diagrams, as well as combinations of the flowchart and / or block diagrams, may be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, a special purpose computer, an embedded processor, or other programmable data processing apparatus to produce a machine such that the instructions executed by the processor of the computer or other programmable data processing apparatus produce means for implementing the functions specified in one or more flows of the flowchart diagrams and / or one or more blocks of the block diagrams.
[0167] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to operate in a particular manner such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means, which implement the functions specified in one or more flows in the flowcharts and / or one or more blocks in the block diagrams. The storage medium may include a flash disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk.
[0168] Although the present application has been described herein in conjunction with various embodiments, other variations of the disclosed embodiments will be understood and implemented by those skilled in the art in carrying out the claimed application by reviewing the drawings, the disclosure, and the appended claims. In the claims, the term “comprising” does not exclude other components or steps, and the term “a” or “an” does not exclude a plurality. Certain measures are recited in mutually different dependent claims, while it does not mean that these measures cannot be combined to produce good results.
[0169] Those of ordinary skilled in the art will appreciate that all or part of the operations in the methods according to any of the data processing method in the method embodiments above may be implemented by related hardware under instructions of a program, which may be stored in a computer readable storage memory. The memory includes an ROM, a RAM, a magnetic disk, an optical disk and the like.
[0170] It may be understood that any product controlled or configured to execute the processing method of the flowcharts described in the embodiments of the data processing methods of the present application, such as the apparatus of the above flowcharts and the computer program product, belongs to the category of related products described in the present application.
[0171] It is obvious that various modifications and variations may be made by those skilled in the art to the data processing method and device without departing from the spirit and scope of the present application. In this way, if these modifications and variations fall within the scope of the claims of the present application and equivalent techniques thereof, the present application is intended to include these modifications and variations.
Claims
1. A method for data processing, comprising:acquiring a first text of a chart in a first document, first position information of the first text, and border information of a graphic of the chart;acquiring a first text feature of the first text;determining a spatial feature of a text box for the first text according to the first position information;obtaining a second text feature according to the first text feature and the spatial feature of the text box;determining a frequency domain feature and an image feature of the chart according to the chart and the border information of the graphic of the chart;obtaining a third text feature according to the second text feature, the frequency domain feature and the image feature of the chart; andinputting the third text feature into a model to obtain a second text for the first document.
2. The method of claim 1, wherein acquiring the first text feature of the first text comprises:concatenating all characters in the first text to obtain a long text sequence;converting the long text sequence into a numerical sequence; andencoding the numerical sequence to obtain the first text feature.
3. The method of claim 1, wherein the spatial feature comprises a position encoding, a width feature, and a height feature, and determining the spatial feature of the text box for the first text according to the first position information comprises:determining the position encoding of the text box for the first text according to the first position information; anddetermining the width feature and the height feature of the text box for the first text according to the first position information.
4. The method of claim 3, wherein determining the position encoding of the text box for the first text according to the first position information comprises:acquiring vertex coordinates of the text box for the first text according to the first position information;acquiring center coordinates of the text box for the first text according to the vertex coordinates of the text box for the first text; andencoding the vertex coordinates and the center coordinates of the text box to obtain the position encoding of the text box.
5. The method of claim 3, wherein determining the width feature and the height feature of the text box for the first text according to the first position information comprises:acquiring vertex coordinates of the text box for the first text according to the first position information;obtaining a width and a height of the text box for the first text by acquiring a difference between bottom-right corner coordinates and top-left corner coordinates of the text box for the first text;encoding the width to obtain the width feature of the text box for the first text; andencoding the height to obtain the height feature of the text box for the first text.
6. The method of claim 1, wherein determining the frequency domain feature and the image feature of the chart according to the chart and the border information of the graphic of the chart comprises:processing the border information of the graphic to obtain a mask for the border information of the graphic;obtaining the frequency domain feature of the chart according to the mask and the chart; andobtaining the image feature of the chart according to the chart.
7. The method of claim 6, wherein processing the border information of the graphic to obtain the mask for the border information of the graphic comprises:performing feature extraction on the border information of the graphic to obtain a feature vector of the border information of the graphic;converting numerical values in the feature vector into a probability distribution array;multiplying the probability distribution array as weights by a preset first filter bank to obtain a second filter bank, wherein a number of filters in the first filter bank is the same as a length of the probability distribution array;adding a plurality of first filters in the second filter bank to obtain a second filter; andprocessing, by using a multilayer perceptron (MLP) mechanism, the second filter to obtain a mask for the border information of the graphic.
8. The method of claim 6, wherein acquiring the frequency domain feature of the chart according to the mask and the chart comprises:performing Fourier transform on the chart to obtain a first result;multiplying the mask by respective elements in the first result to obtain a second result;performing inverse Fourier transform on the second result to obtain a third result; andencoding the third result to obtain a frequency domain feature of the chart.
9. The method of claim 6, wherein obtaining the image feature of the chart according to the chart comprises:segmenting the chart into a plurality of blocks according to a preset patch size and a patch overlapping degree;aggregating features of the plurality of blocks tom obtain the image feature of the chart.
10. A device for data processing, comprising:a processor, and a memory for storing a computer program code stored on the memory and executable by the processor, wherein the processor is configured to invoke and execute the executable program code to cause the device to:acquire a first text of a chart in a first document, first position information of the first text, and border information of a graphic of the chart;acquire a first text feature of the first text;determine a spatial feature of a text box for the first text according to the first position information;obtain a second text feature according to the first text feature and the spatial feature of the text box;determine a frequency domain feature and an image feature of the chart according to the chart and the border information of the graphic of the chart;obtain a third text feature according to the second text feature, the frequency domain feature and the image feature of the chart; andinputting the third text feature into a model to obtain a second text for the first document.
11. The device of claim 10, wherein when acquiring the first text feature of the first text, the processor is specifically configured to:concatenate all characters in the first text to obtain a long text sequence;convert the long text sequence into a numerical sequence; andencode the numerical sequence to obtain the first text feature.
12. The device of claim 10, wherein the spatial feature comprises a position encoding, a width feature, and a height feature, and when determining the spatial feature of the text box for the first text according to the first position information, the processor is specifically configured to:determine the position encoding of the text box for the first text according to the first position information; anddetermine the width feature and the height feature of the text box for the first text according to the first position information.
13. The device of claim 12, wherein when determining the position encoding of the text box for the first text according to the first position information, the processor is specifically configured to:acquire vertex coordinates of the text box for the first text according to the first position information;acquire center coordinates of the text box for the first text according to the vertex coordinates of the text box for the first text; andencode the vertex coordinates and the center coordinates of the text box to obtain the position encoding of the text box.
14. The device of claim 12, wherein when determining the width feature and the height feature of the text box for the first text according to the first position information, the processor is specifically configured to:acquire vertex coordinates of the text box for the first text according to the first position information;obtain a width and a height of the text box for the first text by acquiring a difference between bottom-right corner coordinates and top-left corner coordinates of the text box for the first text;encode the width to obtain the width feature of the text box for the first text; andencode the height to obtain the height feature of the text box for the first text.
15. The device of claim 10, wherein when determining the frequency domain feature and the image feature of the chart according to the chart and the border information of the graphic of the chart, the processor is specifically configured to:process the border information of the graphic to obtain a mask for the border information of the graphic;obtain the frequency domain feature of the chart according to the mask and the chart; andobtain the image feature of the chart according to the chart.
16. The device of claim 15, wherein when processing the border information of the graphic to obtain the mask for the border information of the graphic, the processor is specifically configured to:perform feature extraction on the border information of the graphic to obtain a feature vector of the border information of the graphic;convert numerical values in the feature vector into a probability distribution array;multiply the probability distribution array as weights by a preset first filter bank to obtain a second filter bank, wherein a number of filters in the first filter bank is the same as a length of the probability distribution array;add a plurality of first filters in the second filter bank to obtain a second filter; andprocess, by using a multilayer perceptron (MLP) mechanism, the second filter to obtain a mask for the border information of the graphic.
17. The device of claim 15, wherein when acquiring the frequency domain feature of the chart according to the mask and the chart, the processor is specifically configured to:perform Fourier transform on the chart to obtain a first result;multiply the mask by respective elements in the first result to obtain a second result;perform inverse Fourier transform on the second result to obtain a third result; andencode the third result to obtain a frequency domain feature of the chart.
18. The device of claim 15, wherein when obtaining the image feature of the chart according to the chart, the processor is specifically configured to:segment the chart into a plurality of blocks according to a preset patch size and a patch overlapping degree;aggregate features of the plurality of blocks tom obtain the image feature of the chart.
19. A non-transitory computer-readable storage medium, having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the following operations:acquiring a first text of a chart in a first document, first position information of the first in text, and border information of a graphic of the chart;acquiring a first text feature of the first text;determining a spatial feature of a text box for the first text according to the first position information;obtaining a second text feature according to the first text feature and the spatial feature of the text box;determining a frequency domain feature and an image feature of the chart according to the chart and the border information of the graphic of the chart;obtaining a third text feature according to the second text feature, the frequency domain feature and the image feature of the chart; andinputting the third text feature into a model to obtain a second text for the first document.
20. The non-transitory computer-readable storage medium of claim 17, wherein the computer program, when executed by a processor, specifically implements the following operations:concatenating all characters in the first text to obtain a long text sequence;converting the long text sequence into a numerical sequence; andencoding the numerical sequence to obtain the first text feature.
