Text comparison method and device, electronic equipment and storage medium

By constructing a digital twin network and texture map similarity assessment, and integrating text handwriting features, the problem of inaccurate handwriting recognition in existing technologies is solved, and the accuracy of handwriting recognition in small sample scenarios is improved.

CN121366420APending Publication Date: 2026-01-20CHINA MOBILE ZIJIN INNOVATION INST CO LTD +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511486195.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-17
Publication Date
2026-01-20

AI Technical Summary

Technical Problem

Existing technologies rely on the stroke features or data tags of individual characters in the handwriting identification process, which leads to inaccurate identification results when there are only a few reference handwriting samples.

Method used

By constructing a digital twin network, utilizing texture maps and vector similarity to evaluate attributes, and integrating text handwriting features, the dimensions of a single character are increased from 256 to 2048 of the texture map, reducing the risk of overfitting and improving the accuracy of handwriting recognition.

Benefits of technology

It improves the accuracy of handwriting recognition in small sample scenarios, solves the problem of inaccurate recognition caused by relying on single character features or data labels in existing technologies, and achieves highly accurate comparison of whether texts are from the same user.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121366420A_ABST
    Figure CN121366420A_ABST
Patent Text Reader

Abstract

The invention discloses a text comparison method and device, electronic equipment and a storage medium, and the method comprises the steps: obtaining a first to-be-compared text and a second to-be-compared text, and constructing a first texture map corresponding to the first to-be-compared text and a second texture map corresponding to the second to-be-compared text; based on a pre-trained digital twin network, respectively determining a first vector corresponding to the first texture map and a second vector corresponding to the second texture map; and determining a comparison result of the first to-be-compared text and the second to-be-compared text based on a similarity evaluation attribute of the first vector and the second vector. The problem that in the prior art, in the handwriting affirmation process, the handwriting affirmation result is not accurate enough under the scene that only a small number of reference handwritings exist due to the fact that the handwriting affirmation process depends on the stroke characteristics of a single character or depends on data labels is solved, and the effect of improving the accuracy of affirming whether the two texts are the same user handwriting or not is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data processing, and in particular to a text comparison method and device, electronic equipment and a storage medium. BACKGROUND

[0002] Many procedural documents in the work need to be written and archived by the relevant responsible user himself. In order to ensure that the handwriting in the document is the designated responsible user, it is very important to accurately identify the handwriting in the text.

[0003] At present, the identification of offline handwriting is generally achieved by extracting the stroke features of single characters, such as stroke center line, slope or starting and ending positions of strokes, or relying on data labels in a pre-trained handwriting identification model. However, such a way is not accurate for identifying handwriting of different styles, or cannot accurately identify handwriting when the handwriting sample is scarce.

[0004] In order to solve the above problems, the method for identifying handwriting in the text needs to be improved. SUMMARY

[0005] The embodiments of the present application provide a text comparison method, device, electronic equipment and storage medium to solve the problem that the prior art relies on stroke features of single characters or data labels in the handwriting identification process, and the handwriting identification result is not accurate in the scene where only a small amount of reference handwriting exists.

[0006] In a first aspect, the embodiments of the present application provide a text comparison method, comprising:

[0007] obtaining a first text to be compared and a second text to be compared, and constructing a first texture map corresponding to the first text to be compared and a second texture map corresponding to the second text to be compared;

[0008] determining a first vector corresponding to the first texture map and a second vector corresponding to the second texture map based on a pre-trained digital twin network;

[0009] determining a comparison result of the first text to be compared and the second text to be compared based on a similarity evaluation attribute of the first vector and the second vector.

[0010] In a second aspect, the embodiments of the present application also provide a text comparison device, comprising:

[0011] a texture map construction module configured to obtain a first text to be compared and a second text to be compared, and construct a first texture map corresponding to the first text to be compared and a second texture map corresponding to the second text to be compared;

[0012] a vector determination module configured to determine a first vector corresponding to the first texture map and a second vector corresponding to the second texture map based on a pre-trained digital twin network;

[0013] a comparison result determination module configured to determine a comparison result of the first to-be-compared text and the second to-be-compared text based on a similarity evaluation attribute of the first vector and the second vector.

[0014] In a third aspect, an electronic device is provided, and the electronic device comprises:

[0015] at least one processor; and

[0016] a memory connected to the at least one processor in communication; wherein

[0017] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the text comparison method according to any of the embodiments of the present application.

[0018] In a fourth aspect, a computer readable storage medium is provided, and the computer readable storage medium stores computer instructions for enabling a processor to implement the text comparison method according to any of the embodiments of the present application when the processor executes the computer instructions.

[0019] In a fifth aspect, a computer program product is provided, and the computer program product comprises a computer program, and the computer program implements the text comparison method according to any of the embodiments of the present application when the computer program is executed by a processor.

[0020] The technical scheme of the embodiment of the present application is: obtaining a first to-be-compared text and a second to-be-compared text, and constructing a first texture graph corresponding to the first to-be-compared text and a second texture graph corresponding to the second to-be-compared text; determining a first vector corresponding to the first texture graph and a second vector corresponding to the second texture graph based on a pre-trained digital twin network; and determining a comparison result of the first to-be-compared text and the second to-be-compared text based on a similarity evaluation attribute of the first vector and the second vector. In the technical scheme, the to-be-compared text is converted into a texture graph, the stroke features of multiple texts in the to-be-compared text are integrated, the feature dimension is increased from 256 dimensions of a single word to 2048 dimensions of a texture graph, further, the overfitting risk of extracting the texture graph is reduced in a small sample scene by the shared weight mechanism of the digital twin network, the stroke features are enhanced, and the accuracy of stroke identification of the first to-be-compared text and the second to-be-compared text is improved. The problem that the stroke identification result is not accurate enough in a scene where only a small amount of reference strokes exist is solved, and the effect of improving the accuracy of identifying whether two texts are the same user's strokes is achieved. BRIEF DESCRIPTION OF DRAWINGS

[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the description of the embodiments of the present application will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor on the basis of the contents of the embodiments of the present application and the drawings.

[0022] Figure 1 is a flowchart of a text comparison method according to an embodiment of the present application;

[0023] Figure 2 is a flowchart of a text comparison method according to an embodiment of the present application;

[0024] Figure 3 is a structural schematic diagram of a text comparison device according to an embodiment of the present application;

[0025] Figure 4 is a structural schematic diagram of an electronic device for implementing the text comparison method of the embodiment of the present application. DETAILED DESCRIPTION

[0026] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention. The acquisition, transmission, storage, use, and processing of data in the technical solutions of this application comply with the relevant provisions of national laws and regulations. It should be noted that in the embodiments of this application, certain software, components, or models and other existing solutions in the industry may be mentioned. These should be considered as exemplary, and their purpose is only to illustrate the feasibility of implementing the technical solutions of this application, but it does not mean that the applicant has or necessarily used such solutions.

[0027] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in sequences other than those illustrated or described herein.

[0028] Example 1

[0029] Figure 1 The present invention provides a flowchart of a text comparison method according to Embodiment 1. This embodiment is applicable to the case of handwriting identification in two texts to determine whether the handwriting in the two texts belongs to the same user. The method can be executed by a text comparison device, which can be implemented in hardware and / or software and can be configured in a computing device capable of executing the text comparison method.

[0030] like Figure 1 As shown, the method includes:

[0031] S110. Obtain the first text to be compared and the second text to be compared, and construct the first texture map corresponding to the first text to be compared and the second texture map corresponding to the second text to be compared.

[0032] The first and second comparison texts refer to two text materials that serve as references to each other and require handwriting identification. The first texture image and the second texture image are generated by digitizing and enhancing the first and second comparison texts, respectively, and are used for quantitative analysis and comparison of the micro-textural structure of handwriting.

[0033] In practical applications, handwriting identification is usually divided into offline identification and online identification modes. In the offline identification scenario, in order to determine whether two texts (i.e., a first to-be-compared text and a second to-be-compared text) are the handwriting of the same user, texture information corresponding to the first to-be-compared text is constructed to obtain a first texture graph, and texture information corresponding to the second to-be-compared text is constructed to obtain a second texture graph, and then a comparison result is obtained based on a feature comparison of the first texture graph and the second texture graph. The comparison result includes that the first to-be-compared text and the second to-be-compared text are the handwriting of the same user, or the first to-be-compared text and the second to-be-compared text are the handwriting of different users.

[0034] S120, based on the pre-trained digital twin network, respectively determining a first vector corresponding to the first texture graph and a second vector corresponding to the second texture graph.

[0035] The first vector can be understood as a feature vector obtained by vector encoding the first texture graph based on the first residual network branch, and the second vector can be understood as a feature vector obtained by vector encoding the second texture graph based on the second residual network branch.

[0036] Before performing handwriting identification on the first to-be-compared text and the second to-be-compared text, the digital twin network is pre-trained to perform vectorization processing on the first texture graph and the second texture graph based on the digital twin network.

[0037] In one specific example, a feature extractor is constructed based on ResNet-50, and the last layer of the Softmax classification layer is removed to output a 2048-dimensional feature vector. Among them, the network structure of the feature extractor includes: a convolution module, an activation function and a regularization module, the convolution module includes 5 groups of residual blocks, each group contains 3 convolution layers and 1 maximum pooling layer; the activation function can use Leaky ReLU (a=0.2) throughout the network to prevent gradient disappearance; the regularization module can add a Dropout layer (p=0.3) to suppress overfitting. On this basis, a digital twin network is constructed, which shares the weight mechanism, that is, two groups of ResNet branches sharing weights are constructed to input the texture graph pair (A, B) to be compared. Further, the similarity of the texture features of the two texture graphs is calculated to obtain a similarity evaluation attribute, and then it is determined whether the two text to be compared correspond to the handwriting of the same user based on the similarity evaluation attribute. Further, the digital twin network is optimized and trained, wherein the optimization process includes data augmentation, optimizer configuration and determination of training strategy. Exemplarily, the data augmentation method can be random rotation (±15°), translation (±5 pixels) and gamma correction of the texture graph to expand the training samples. The optimizer configuration can be to use the Adam optimizer (learning rate=0.0002, β1=0.9, β2=0.999) for gradient descent. The training strategy can use the early stopping method (Early Stopping), and the training is terminated when the validation set loss does not decrease for 5 consecutive epochs.

[0038] On this basis, based on the pre-trained digital twin network, a first vector corresponding to the first texture graph and a second vector corresponding to the second texture graph are determined, including: inputting the first texture graph and the second texture graph into the two groups of ResNet branches (i.e., the first residual network branch and the second residual network branch) of the digital twin network sharing weights, respectively, vector encoding the first texture graph based on the first residual network branch to obtain the first vector, and vector encoding the second texture graph based on the second residual network branch to obtain the second vector. Among them, the first residual network branch and the second residual network branch share weights.

[0039] S130, determining the comparison result of the first text to be compared and the second text to be compared based on the similarity evaluation attribute of the first vector and the second vector.

[0040] Among them, the similarity evaluation attribute is used to represent the vector similarity between the first vector and the second vector, the greater the similarity evaluation attribute, the higher the similarity of the first vector and the second vector, on the contrary, the smaller the similarity evaluation attribute, the lower the similarity of the first vector and the second vector.

[0041] Optionally, the similarity evaluation attribute of the first vector and the second vector is used to determine the comparison result of the first text to be compared and the second text to be compared, including: performing similarity calculation on the first vector and the second vector based on a preset vector similarity algorithm to obtain the similarity evaluation attribute between the first vector and the second vector; and determining the comparison result of the first text to be compared and the second text to be compared based on the similarity evaluation attribute.

[0042] Exemplarily, the vector similarity algorithm can be a cosine similarity algorithm, and after the first vector and the second vector are obtained, the feature vector difference between the first texture graph and the second texture graph is measured based on the Euclidean distance, and the similarity evaluation attribute S ∈ [0, 1] (i.e., the similarity evaluation attribute between the first vector and the second vector) is output.

[0043] wherein the first vector is denoted as f A , and the second vector is denoted as f B , and the similarity evaluation attribute of the first vector and the second vector is:

[0044]

[0045] wherein S represents the similarity evaluation attribute, , d represents the Euclidean distance between the first vector and the second vector, f A represents the first vector, and f B represents the second vector.

[0046] wherein the loss function is designed as a contrastive loss function:

[0047]

[0048] wherein L represents the loss function, N represents the number of training samples, y i is a label (1 represents the same handwriting, and 0 represents different handwriting), m is a preset threshold (recommended value 0.5), and S i represents the predicted evaluation attribute of the i-th sample.

[0049] On this basis, if the similarity evaluation attribute is greater than a preset similarity evaluation attribute, the comparison result is that the first text to be compared and the second text to be compared are the handwriting of the same user; and if the similarity evaluation attribute is less than the preset similarity evaluation attribute, it indicates that the first text to be compared and the second text to be compared are not the handwriting of the same user.

[0050] Optionally, when the similarity evaluation attribute is less than the preset similarity evaluation attribute, an abnormality warning is performed, and the comparison result is sent to an auditing system.

[0051] Of course, in actual application, at least one trust level corresponding to the comparison result and the similarity evaluation attribute interval corresponding to each trust level can also be set in advance, and the trust level of the comparison result is determined when the interval to which the similarity evaluation attribute belongs is obtained. For example, the trust level includes trusted, doubtful and untrusted, wherein the similarity evaluation attribute interval corresponding to the trusted level is [95, 100], the similarity evaluation attribute interval corresponding to the doubtful level is [85, 94], and the similarity evaluation attribute interval corresponding to the untrusted level is [0, 84]. If the similarity evaluation attribute of the first vector and the second vector is 98, the trust level corresponding to the comparison result is the trusted level, if the similarity evaluation attribute is 86, the trust level is the doubtful level, and if the similarity evaluation attribute is 75, the trust level is untrusted. When the trust level is the doubtful or untrusted level, the comparison result can be sent to the review system for manual review.

[0052] The technical scheme of the embodiment of the application acquires a first text to be compared and a second text to be compared, constructs a first texture graph corresponding to the first text to be compared and a second texture graph corresponding to the second text to be compared, determines a first vector corresponding to the first texture graph and a second vector corresponding to the second texture graph based on a pre-trained digital twin network, and determines a comparison result of the first text to be compared and the second text to be compared based on a similarity evaluation attribute of the first vector and the second vector. In the technical scheme, the handwriting features of multiple texts in the text to be compared can be integrated by converting the text to be compared into a texture graph, the feature dimension is increased from 256 dimensions of a single word to 2048 dimensions of a texture graph, further, the overfitting risk of extracting the texture graph is reduced in a small sample scene by the shared weight mechanism of the digital twin network, the handwriting features are enhanced, and the accuracy of handwriting identification of the first text to be compared and the second text to be compared is improved. The problem that the handwriting identification result is not accurate enough in a scene where only a small amount of reference handwriting exists is solved, and the effect of improving the accuracy of identifying whether two texts are the same user's handwriting is achieved.

[0053] Embodiment two

[0054] Figure 2 A flowchart of a text comparison method provided by the embodiment two of the application is shown in the figure. Optionally, the construction of the first texture graph corresponding to the first text to be compared and the second texture graph corresponding to the second text to be compared is refined.

[0055] As Figure 2 shown, the method comprises the following steps.

[0056] S210, binarizing the current to-be-compared text to obtain a to-be-processed image corresponding to the current to-be-compared text.

[0057] The current to-be-compared text is the first to-be-compared text or the second to-be-compared text. The to-be-processed image is a binarized image corresponding to the current to-be-compared text.

[0058] In a specific example, a gray-scale or color handwritten text image (64 x 64 pixels) (i.e., the current to-be-compared text) is received from an image acquisition device, the current to-be-compared text is converted into a binarized image by an adaptive threshold algorithm, background noise is removed and handwriting contour information is retained, and a to-be-processed image is obtained. The pixel value of the to-be-processed image only contains 0 (background) and 255 (foreground).

[0059] S220, performing projection segmentation on the current to-be-compared text to obtain at least one to-be-processed handwriting.

[0060] The projection segmentation includes horizontal projection segmentation, vertical projection segmentation, and specific segmentation. The horizontal projection segmentation refers to detecting wave crests and troughs by counting the projection values of each row of pixels of the image to segment text lines. The vertical projection segmentation refers to locating character space to realize character segmentation in a single line by counting the projection values of each column of pixels of the image. The specific segmentation refers to dynamically dividing regions based on local features such as stroke shape and density, and is suitable for fine segmentation of complex or connected characters.

[0061] On this basis, the to-be-processed image is subjected to horizontal projection segmentation, a horizontal projection histogram of the to-be-processed image is calculated, line boundaries are recognized, and line units are segmented by setting a line spacing threshold.

[0062] The horizontal projection histogram H(i) is defined as the number of foreground pixels in the ith line:

[0063]

[0064] W is the image width. By setting a threshold Th, the start and end positions of the line are recognized.

[0065] The to-be-processed image is subjected to vertical projection segmentation, vertical projection analysis is performed on each line unit, column boundaries are recognized, and single-character handwriting (i.e., at least one to-be-processed handwriting) is segmented.

[0066] On this basis, the specific segmentation is performed on each to-be-processed handwriting, connected writing or slanted writing is subjected to further segmentation of complex handwriting by using a connected domain analysis algorithm, and the independence of each to-be-processed handwriting unit is ensured.

[0067] S230, based on all the to-be-processed strokes, constructing a to-be-compared texture graph corresponding to the current to-be-compared text.

[0068] The to-be-compared texture graph is a first texture graph corresponding to the first to-be-compared text or a second texture graph corresponding to the second to-be-compared text.

[0069] Optionally, based on all the to-be-processed strokes, constructing a to-be-compared texture graph corresponding to the current to-be-compared text comprises: for each to-be-processed stroke, performing data preprocessing on the current to-be-processed stroke to obtain a to-be-used stroke; determining a character frequency of the to-be-used stroke in the current to-be-compared text, and determining a target position of the to-be-used stroke in a pre-set to-be-filled texture graph according to the character frequency; and filling each to-be-used stroke into the corresponding target position in the to-be-filled texture graph to obtain the to-be-compared texture graph corresponding to the current to-be-compared text.

[0070] The data preprocessing comprises at least one of data type conversion, missing value processing, and data standardization.

[0071] On the basis of the above examples, the to-be-processed strokes are subjected to data type conversion, each to-be-processed stroke is uniformly converted into a gray-scale image of a fixed size (such as 64x64 pixels), and the gray-scale image is subjected to missing value processing, such as supplementing missing pixel values by using the mean value method and removing duplicate strokes by using the minimum neighbor method. Further, the gray-scale image after de-duplication and missing value processing is subjected to data standardization processing, such as normalization processing of the image pixel values, to obtain the to-be-used strokes, so that they are distributed in the [0, 1] interval and the convergence speed of model training is improved.

[0072] Illustratively, let the pixel value be p, and the normalized pixel value p' be:

[0073]

[0074] wherein p min and p max are the minimum value and the maximum value of the pixel value, respectively.

[0075] Further, determining the character frequency of the to-be-used stroke in the current to-be-compared text and determining the target position of the to-be-used stroke in the pre-set to-be-filled texture graph according to the character frequency comprises: calling a pre-set size to-be-filled texture graph that is pre-constructed, and counting the character frequency of all to-be-used strokes in the current to-be-compared text; sorting the to-be-used strokes according to the character frequency to obtain a sorting result; and preferentially configuring characters from the central position of the to-be-filled texture graph in sequence according to the sorting result to obtain the target position of each to-be-used stroke in the to-be-filled texture graph.

[0076] On the basis of the above examples, for each to-be-used handwriting, a unicode character corresponding to each to-be-used handwriting is determined to uniquely identify each to-be-used handwriting, and all to-be-used handwritings are subjected to clustering analysis based on character similarity calculation, to remove duplicate handwritings in the to-be-used handwritings and retain the optimal sample of each to-be-used handwriting. Further, an n x n grid structure is adopted to obtain a to-be-filled texture graph, and the de-duplicated to-be-used handwritings are dynamically arranged in descending order of character frequency. The to-be-used handwriting with the highest character frequency will be preferentially concentrated in the center of the to-be-filled texture graph (i.e., the target position of the to-be-used handwriting with the highest character frequency in the to-be-filled texture graph), and then according to the sorting result, the target position of each to-be-used handwriting in the to-be-filled texture graph is determined in sequence, to obtain a to-be-compared texture graph of a preset size corresponding to the current to-be-compared text. In the process of splicing the to-be-compared texture graph based on all to-be-used handwritings, the to-be-filled texture graph can be scaled by an interpolation algorithm to ensure the continuity and consistency of the handwriting images in the to-be-compared texture graph.

[0077] The advantage of such an arrangement is that the to-be-used handwritings are arranged from the center of the to-be-filled texture graph outward in descending order of character frequency, which can ensure the uniformity of the feature distribution of the texture graph and improve the expression ability of the texture graph for typical features.

[0078] S240, based on the pre-trained digital twin network, a first vector corresponding to the first texture graph and a second vector corresponding to the second texture graph are determined respectively.

[0079] S250, based on the similarity of the first vector and the second vector, the evaluation attribute is determined, and the comparison result of the first to-be-compared text and the second to-be-compared text is determined.

[0080] The technical scheme of the embodiment of the present application acquires a first to-be-compared text and a second to-be-compared text, and constructs a first texture graph corresponding to the first to-be-compared text and a second texture graph corresponding to the second to-be-compared text; based on a pre-trained digital twin network, a first vector corresponding to the first texture graph and a second vector corresponding to the second texture graph are determined respectively; based on a similarity evaluation attribute of the first vector and the second vector, a comparison result of the first to-be-compared text and the second to-be-compared text is determined. In the technical scheme, by converting the to-be-compared text into a texture graph, the handwriting features of multiple texts in the to-be-compared text can be integrated, the feature dimension is improved from 256 dimensions of a single word to 2048 dimensions of a texture graph, further, through the shared weight mechanism of the digital twin network, the overfitting risk of extracting the texture graph can be reduced in a small sample scene, the handwriting features are enhanced, and the accuracy of handwriting identification of the first to-be-compared text and the second to-be-compared text is improved. The problem that the handwriting identification result is not accurate enough in a scene where only a small amount of reference handwriting exists is solved, and the effect of improving the accuracy of identifying whether two texts are handwriting of the same user is realized.

[0081] Embodiment three

[0082] Figure 3 A structural schematic diagram of a text comparison device provided by the third embodiment of the present application is shown in FIG. 3. Figure 3 As shown in the figure, the device comprises a texture graph construction module 310, a vector determination module 320, and a comparison result determination module 330.

[0083] The texture graph construction module 310 is configured to acquire a first to-be-compared text and a second to-be-compared text, and construct a first texture graph corresponding to the first to-be-compared text and a second texture graph corresponding to the second to-be-compared text.

[0084] The vector determination module 320 is configured to determine a first vector corresponding to the first texture graph and a second vector corresponding to the second texture graph based on a pre-trained digital twin network.

[0085] The comparison result determination module 330 is configured to determine a comparison result of the first to-be-compared text and the second to-be-compared text based on a similarity evaluation attribute of the first vector and the second vector.

[0086] The technical scheme of the embodiment of the present application acquires a first to-be-compared text and a second to-be-compared text, and constructs a first texture graph corresponding to the first to-be-compared text and a second texture graph corresponding to the second to-be-compared text; based on a pre-trained digital twin network, a first vector corresponding to the first texture graph and a second vector corresponding to the second texture graph are determined respectively; based on the similarity evaluation attribute of the first vector and the second vector, the comparison result of the first to-be-compared text and the second to-be-compared text is determined. In the technical scheme, the handwriting features of multiple texts in the to-be-compared texts can be integrated by converting the to-be-compared texts into texture graphs, the feature dimension is increased from 256 dimensions of a single word to 2048 dimensions of a texture graph, further, the overfitting risk of extracting the texture graph is reduced in a small sample scene by the shared weight mechanism of the digital twin network, the handwriting features are enhanced, and the accuracy of handwriting identification of the first to-be-compared text and the second to-be-compared text is improved. The problem that the handwriting identification result is not accurate enough in the scene where only a small amount of reference handwriting exists is solved by solving the problem that the prior art depends on the stroke features of a single word or the dependence on data labels in the handwriting identification process, and the effect of improving the accuracy of identifying whether two texts are the same user's handwriting is achieved.

[0087] Optionally, the texture graph construction module comprises: a to-be-processed image determination sub-module, configured to perform binaryzation processing on the current to-be-compared text to obtain a to-be-processed image corresponding to the current to-be-compared text, the current to-be-compared text being the first to-be-compared text or the second to-be-compared text;

[0088] The segmentation sub-module is configured to perform projection segmentation on the current to-be-compared text to obtain at least one to-be-processed handwriting; wherein the projection segmentation comprises horizontal projection segmentation, vertical projection segmentation and specific segmentation.

[0089] The texture graph determination sub-module is configured to construct a to-be-compared texture graph corresponding to the current to-be-compared text based on all the to-be-processed handwritings; wherein the to-be-compared texture graph is the first texture graph corresponding to the first to-be-compared text or the second texture graph corresponding to the second to-be-compared text.

[0090] Optionally, the texture graph determination sub-module comprises: a to-be-used handwriting determination unit, configured to perform data preprocessing on the current to-be-processed handwriting to obtain to-be-used handwriting; wherein the data preprocessing comprises at least one of data type conversion, missing value processing and data standardization.

[0091] The position determination unit is configured to determine the character frequency of the to-be-used handwriting in the current to-be-compared text, and determine the target position of the to-be-used handwriting in the pre-set to-be-filled texture graph according to the character frequency.

[0092] The texture graph determination unit fills each to-be-used handwriting into a corresponding target position in the to-be-filled texture graph, to obtain a to-be-compared texture graph corresponding to the current to-be-compared text.

[0093] Optionally, the position determination unit comprises a character frequency determination subunit configured to call a preset size to-be-filled texture graph constructed in advance, and to count character frequencies of all to-be-used handwritings in the current to-be-compared text.

[0094] The sorting subunit is configured to sort the to-be-used handwritings according to the character frequencies, to obtain a sorting result.

[0095] The position determination subunit is configured to preferentially perform character configuration from a central position of the to-be-filled texture graph in sequence according to the sorting result, to obtain target positions of the to-be-used handwritings in the to-be-filled texture graph.

[0096] Optionally, the text comparison device is configured to perform vector encoding on the first texture graph based on a first residual network branch to obtain a first vector, and perform vector encoding on the second texture graph based on a second residual network branch to obtain a second vector; wherein the first residual network branch and the second residual network branch share weights.

[0097] Optionally, the comparison result determination module comprises an evaluation attribute determination sub-module configured to perform similarity calculation on the first vector and the second vector based on a preset vector similarity algorithm, to obtain a similarity evaluation attribute between the first vector and the second vector.

[0098] The comparison result determination sub-module is configured to determine a comparison result of the first to-be-compared text and the second to-be-compared text based on the similarity evaluation attribute.

[0099] Optionally, the text comparison device is further configured to perform abnormal early warning when the similarity evaluation attribute is less than a preset similarity evaluation attribute, and to send the comparison result to an auditing system.

[0100] The text comparison device provided in the embodiments of the present application can perform the text comparison method provided in any of the embodiments of the present application, and has the corresponding function modules and beneficial effects of the execution method.

[0101] Embodiment Four

[0102] Figure 4A schematic diagram of the structure of an electronic device 10 according to an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (such as helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.

[0103] like Figure 4 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 can also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0104] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0105] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as text comparison methods.

[0106] In some embodiments, the text comparison method can be implemented as a computer program tangibly embodied in a computer readable storage medium, e.g., storage unit 18. In some embodiments, parts or all of the computer program can be loaded and / or installed onto electronic device 10 via, e.g., ROM 12 and / or communication unit 19. When the computer program is loaded onto RAM 13 and executed by processor 11, one or more steps of the text comparison method described above can be performed. Alternatively, in other embodiments, processor 11 can be configured to perform the text comparison method by way of other means, e.g., with the aid of firmware.

[0107] Various implementations of the systems and techniques described above can be realized in digital electronic circuitry, integrated circuitry, a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on a chip (SOC), a complex programmable logic device (CPLD), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include implementation in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be special or general purpose, coupled to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.

[0108] Computer programs used to implement the text comparison method of the present application can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the computer program running on the processor implements the functions / operations specified in the flowcharts and / or the block diagrams. The computer program can be executed entirely on a machine, partially on a machine, partially on a machine as part of a standalone software package, or entirely on a remote machine or server.

[0109] In the context of the present application, a computer-readable storage medium can be a tangible medium that can contain or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. A computer-readable storage medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium can be a machine-readable signal medium. More specific examples of a machine-readable storage medium will include one or more lines of a program of instructions in a transitory signal, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0110] To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the electronic device. Other kinds of devices can be used to provide for interaction with a user as well; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form, including acoustic, speech, or tactile input.

[0111] The systems and techniques described here can be implemented in a computing system that includes a back end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front end component (e.g., a user computer having a graphical user interface or a Web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back end, middleware, or front end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0112] The computing system can include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. Servers can be cloud servers, also known as cloud computing servers or cloud hosts, which are a host product in the cloud computing service system to solve the defects of great management difficulty and weak business scalability in traditional physical hosts and VPS services.

[0113] Embodiment five

[0114] The embodiment of the present application further provides a computer program product comprising a computer program which, when executed by a processor, implements the text comparison method provided in any embodiment of the present application.

[0115] The computer program product, in the implementation process, can be written in one or more programming languages or combinations thereof to implement computer program codes for performing the operations of the present application, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" language or similar programming languages. The program code can be executed entirely on a user computer, partially on a user computer, as an independent software package, partially on a user computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (for example, through the Internet using an Internet service provider).

[0116] It should be understood that the various forms of flow shown above can be reordered, added or deleted steps. For example, the steps described in the present application can be executed in parallel, sequentially or in different order, as long as the desired results of the technical solutions of the present application can be achieved, which are not limited herein.

[0117] The above specific embodiments do not constitute a limitation on the scope of protection of the present application. Those skilled in the art should understand that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent replacements and improvements made within the spirit and principles of the present application shall be included in the scope of protection of the present application.

Claims

1. A method of text alignment, characterized by, The method comprises: obtaining a first to-be-compared text and a second to-be-compared text, and constructing a first texture graph corresponding to the first to-be-compared text and a second texture graph corresponding to the second to-be-compared text; based on a pre-trained digital twin network, determining a first vector corresponding to the first texture graph and a second vector corresponding to the second texture graph; based on the similarity evaluation attribute of the first vector and the second vector, determining the comparison result of the first to-be-compared text and the second to-be-compared text.

2. The method of claim 1, wherein, The construction of the first texture graph corresponding to the first to-be-compared text and the second texture graph corresponding to the second to-be-compared text comprises: for the first to-be-compared text or the second to-be-compared text, performing binary processing on the current to-be-compared text to obtain a to-be-processed image corresponding to the current to-be-compared text; wherein the current to-be-compared text is the first to-be-compared text or the second to-be-compared text; performing projection segmentation on the to-be-processed image to obtain at least one to-be-processed handwriting; wherein the projection segmentation comprises horizontal projection segmentation, vertical projection segmentation and specific segmentation; based on all to-be-processed handwritings, constructing a to-be-compared texture graph corresponding to the current to-be-compared text; wherein the to-be-compared texture graph is the first texture graph corresponding to the first to-be-compared text or the second texture graph corresponding to the second to-be-compared text.

3. The method of claim 2, wherein, The construction of the to-be-compared texture graph corresponding to the current to-be-compared text based on all to-be-processed handwritings comprises: for each to-be-processed handwriting, performing data preprocessing on the current to-be-processed handwriting to obtain a to-be-used handwriting; wherein the data preprocessing comprises at least one of data type conversion, missing value processing and data standardization; determining the character frequency of the to-be-used handwriting in the current to-be-compared text, and determining the target position of the to-be-used handwriting in the pre-set to-be-filled texture graph according to the character frequency; filling each to-be-used handwriting into the corresponding target position in the to-be-filled texture graph to obtain the to-be-compared texture graph corresponding to the current to-be-compared text.

4. The method of claim 3, wherein, The determination of the character frequency of the to-be-used handwriting in the current to-be-compared text and the determination of the target position of the to-be-used handwriting in the pre-set to-be-filled texture graph according to the character frequency comprises: calling a pre-constructed to-be-filled texture graph of a preset size, and counting the character frequency of all to-be-used handwritings in the current to-be-compared text; sorting the character frequencies of each to-be-used handwriting to obtain a sorting result; according to the sorting result, preferentially configuring characters from the central position of the to-be-filled texture graph in sequence to obtain the target position of each to-be-used handwriting in the to-be-filled texture graph.

5. The method of claim 1, wherein, The digital twin network comprises a first residual network branch and a second residual network branch, and the determination of the first vector corresponding to the first texture graph and the second vector corresponding to the second texture graph based on the pre-trained digital twin network comprises: vector-encode the first texture map based on the first residual network branch to obtain a first vector and vector-encode the second texture map based on the second residual network branch to obtain a second vector; wherein the first residual network branch and the second residual network branch share weights.

6. The method of claim 1, wherein, The determining the alignment result of the first to-be-aligned text and the second to-be-aligned text based on the similarity evaluation attribute of the first vector and the second vector comprises: performing similarity calculation on the first vector and the second vector based on a pre-set vector similarity algorithm to obtain a similarity evaluation attribute between the first vector and the second vector; determining the alignment result of the first to-be-aligned text and the second to-be-aligned text based on the similarity evaluation attribute.

7. The method of claim 6, wherein, Further comprising: when the similarity evaluation attribute is less than a pre-set similarity evaluation attribute, performing an abnormality early warning and sending the alignment result to an auditing system.

8. A text alignment apparatus, characterized by comprising: Comprise: a texture map construction module configured to obtain a first to-be-aligned text and a second to-be-aligned text and construct a first texture map corresponding to the first to-be-aligned text and a second texture map corresponding to the second to-be-aligned text; a vector determination module configured to determine a first vector corresponding to the first texture map and a second vector corresponding to the second texture map based on a pre-trained digital twin network, respectively; an alignment result determination module configured to determine an alignment result of the first to-be-aligned text and the second to-be-aligned text based on a similarity evaluation attribute of the first vector and the second vector.

9. An electronic device, comprising: The electronic device comprises: at least one processor; and a memory connected in communication with the at least one processor; wherein the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the text alignment method in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer instructions for enabling the processor to implement the text alignment method in any one of claims 1-7 when executed. The computer readable storage medium stores computer instructions for enabling the processor to implement the text alignment method in any one of claims 1-7 when executed.