Disclosure of Invention
The invention mainly aims to provide a German old font identification method, which aims to solve the technical problem of character identification and conversion of German old font publications.
In order to achieve the above object, the present invention provides a method for identifying an old german font, comprising the following steps:
acquiring an original sample to be recognized, converting the sample to be recognized into a text to be recognized in a target format, and inputting the text to be recognized into an RBF neural recognition network;
recognizing each single character in the text to be recognized by adopting a preset character training method in the RBF neural recognition network to obtain a recognition result of each single character;
and generating a recognized text according to the recognition result.
In one embodiment, the step of generating the recognized text according to the recognition result further includes:
and arranging the single characters of the recognition result according to the pre-stored character sequence of the text to be recognized so as to generate the recognized text.
In one embodiment, after the step of generating the recognized text according to the recognition result, the method further includes:
and outputting the recognized text to the set corresponding area.
In one embodiment, before the step of recognizing each single character in the text to be recognized by using the preset character training method in the RBF neural recognition network and outputting the recognition result of each single character, the method further includes:
based on the created RBF neural recognition network, acquiring a corresponding recognition original text for constructing a preset character training method in the RBF neural network, wherein the RBF neural network is divided into an input layer, a hidden layer and an output layer.
In order to achieve the above object, the present invention provides a german old font identifying apparatus, comprising: a memory, a processor and a computer program stored on the memory and executable on the processor, the computer program, when executed by the processor, implementing the steps of the german old font recognition method as described above.
The present invention also provides a computer-readable storage medium, characterized in that the computer-readable storage medium has stored thereon a german old font recognition program, which when executed by a processor implements the steps of the german old font recognition method as described above.
The German old font identification method provided by the embodiment of the invention comprises the steps of obtaining an original sample to be identified, converting the sample to be identified into a text to be identified in a target format, and inputting the text to be identified into an RBF neural identification network; recognizing each single character in the text to be recognized by adopting a preset character training method in the RBF neural recognition network to obtain a recognition result of each single character; and generating a recognized text according to the recognition result. The original detection sample is converted into the detection sample in the target format, the RBF neural network corresponding to the input value performs font identification conversion operation, and the conversion result is output based on the character sequence of the original text, so that the beneficial effects of automatic identification and conversion of the German old font are realized.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The main solution of the embodiment of the invention is as follows: acquiring an original sample to be recognized, converting the sample to be recognized into a text to be recognized in a target format, and inputting the text to be recognized into an RBF neural recognition network; recognizing each single character in the text to be recognized by adopting a preset character training method in the RBF neural recognition network to obtain a recognition result of each single character; and generating a recognized text according to the recognition result.
Since german countries historically employed character systems based on gothic letters, prints are represented by the franktur font and its variants; handwriting is represented by sutterlin fonts which are different from the latin alphabet fonts which are popular in the world nowadays, so that reading is difficult, and reading such documents in a translation process is time-consuming, labor-consuming and prone to errors.
The invention provides a solution, after the detected original text is preprocessed into the detection sample with the target format, the character information of the detection sample is identified and converted in a preset RBF neural network mode, and the conversion result is output according to the character sequence of the original text, thereby realizing the beneficial effect of automatically identifying and outputting the German old font.
As shown in fig. 1, fig. 1 is a schematic structural diagram of a terminal \ device in a hardware operating environment according to an embodiment of the present invention.
The terminal of the embodiment of the invention can be a PC, and can also be a mobile terminal device with a display function, such as a smart phone, a tablet computer, an electronic book reader, an MP3(Moving Picture Experts Group Audio Layer III, a portable computer, and the like.
As shown in fig. 1, the terminal may include: a processor 1001, such as a CPU, a network interface 1004, a user interface 1003, a memory 1005, a communication bus 1002. Wherein a communication bus 1002 is used to enable connective communication between these components. The user interface 1003 may include a Display screen (Display), an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface, a wireless interface. The network interface 1004 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface). The memory 1005 may be a high-speed RAM memory or a non-volatile memory (e.g., a magnetic disk memory). The memory 1005 may alternatively be a storage device separate from the processor 1001.
Those skilled in the art will appreciate that the terminal structure shown in fig. 1 is not intended to be limiting and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components.
In the terminal shown in fig. 1, the network interface 1004 is mainly used for connecting to a backend server and performing data communication with the backend server; the user interface 1003 is mainly used for connecting a client (user side) and performing data communication with the client; the memory 1005, which is a kind of computer storage medium, includes therein a german old font recognition program, and the processor 1001 may be configured to call the german old font recognition program stored in the memory 1005 and perform the following operations:
acquiring an original sample to be recognized, converting the sample to be recognized into a text to be recognized in a target format, and inputting the text to be recognized into an RBF neural recognition network;
recognizing each single character in the text to be recognized by adopting a preset character training method in the RBF neural recognition network to obtain a recognition result of each single character;
and generating a recognized text according to the recognition result.
In one embodiment, the processor 1001 may call the german old font recognition program stored in the memory 1005, and further perform the following operations:
and arranging the single characters of the recognition result according to the pre-stored character sequence of the text to be recognized so as to generate the recognized text.
In one embodiment, the processor 1001 may call the german old font recognition program stored in the memory 1005, and further perform the following operations:
and outputting the recognized text to the set corresponding area.
In one embodiment, the processor 1001 may call the german old font recognition program stored in the memory 1005, and further perform the following operations:
based on the created RBF neural recognition network, acquiring a corresponding recognition original text for constructing a preset character training method in the RBF neural network, wherein the RBF neural network is divided into an input layer, a hidden layer and an output layer.
Referring to fig. 2, fig. 2 is a schematic flowchart of a german old font identification method according to a first embodiment of the present invention, where the german old font identification method includes:
step S10, acquiring an original sample to be recognized, converting the sample to be recognized into a text to be recognized in a target format, and inputting the text to be recognized into an RBF neural recognition network;
acquiring an original sample file to be detected based on a German old font, and executing preprocessing operation on the detected original sample, wherein the preprocessing operation comprises the operations of noise reduction, binaryzation, character segmentation, size normalization and the like on the original sample file to generate a detection sample in a target format; the detection samples in the target format are samples of a large number of single characters which are suitable for the following classifier training samples. The source of the original sample file to be detected can be obtained by scanning a printed publication with German old fonts to obtain an original sample in the form of a picture or directly obtained from a document of an electronic resource. And if the format of the original sample file to be detected is inconsistent with the picture format matched with the preprocessing operation, converting the original sample file to be detected into a corresponding format, and then executing the preprocessing operation on the original sample picture to be detected.
Step S20, recognizing each single character in the text to be recognized by adopting a preset character training method in the RBF neural recognition network to obtain a recognition result of each single character;
according to a detection sample in a target format generated by an original sample to be detected which is subjected to preprocessing operation, inputting the detection sample into a pre-established RBF neural recognition network, and recognizing according to a classifier training result configured in the RBF neural network. And the identification content comprises the steps of inputting the detection sample into an input layer of the RBF neural network, identifying in an identification mode which is configured and generated by training in the RBF neural network, and converting the recognized middle character information of the detection sample into the existing Latin letter font after the identification is finished. The specific identification and conversion method comprises the following steps: disassembling each single character in the text to be recognized, and comparing each disassembled single character with the characters in each detection sample in the preset character training method one by one to confirm the single character and the consistent character in each detection sample, namely recognizing the character in the sample to be recognized by the character in each detection sample; and outputting the corresponding existing characters of the single characters based on the comparison result according to the comparison result.
Step S30, a recognized text is generated according to the recognition result.
And generating a recognized text according to the recognized characters in a preset mode, wherein the recognized text comprises a text type, a text generation mode and the like, and the specific operation mode of the recognized text is related to the set text generation mode. In addition, when the recognized text is generated from the recognition result, the recognized character sequence needs to be adjusted and output according to the sequence of the characters in the original sample to be detected corresponding to the detection sample. And before preprocessing, the detection sample stores the content of the character sequence based on the original sample to be detected corresponding to the detection sample, namely, arranging each single character of the recognition result according to the pre-stored character sequence of the text to be recognized so as to generate the recognized text.
And adjusting the converted character sequence based on the character sequence and outputting the character sequence to a corresponding area. Namely, after the step of generating the recognized text according to the recognition result, the method further comprises the following steps: and outputting the recognized text to the set corresponding area. The corresponding area comprises a display page, a newly-built text or a storage area and the like, and the specific output format of the corresponding area is related to the corresponding application mode of the detection sample.
In addition, before the step of adjusting the recognized characters of the detection samples to the character sequence corresponding to the original samples and outputting the characters to the corresponding areas for display, the method further comprises:
and taking the character node in the detection sample as a reference, and storing the position of the character node in the detection original sample corresponding to the detection sample.
After an original sample to be detected is obtained, preprocessing operation is carried out to generate a detection sample in a target format, the character sequence of the original sample to be detected is read, information of the character sequence is stored, and the stored character sequence is used as a converted character sequence template.
In this embodiment, after the obtained original sample to be detected is preprocessed, the preprocessed original sample is input to a pre-created RBF neural recognition network for recognition and character conversion, and the output characters are adjusted according to the character sequence of the original sample to be detected, so as to achieve the beneficial effect of automatically recognizing and converting old german fonts.
Further, referring to fig. 3, fig. 3 is a flowchart illustrating a second embodiment of the german old font identification method according to the present invention, and based on the first embodiment shown in fig. 2, before step 20, the method further includes:
step S40, acquiring a corresponding recognition original text based on the created RBF neural recognition network, and constructing a preset character training method in the RBF neural network, wherein the RBF neural network is divided into an input layer, a hidden layer and an output layer. (ii) a
And acquiring an identification original sample file, preprocessing the identification original sample file, generating an identification detection file in a target format, and constructing an identification classifier of the RBF neural network in a preset mode. The identification detection file with the target format includes extracting each character of the file to a corresponding storage area for storage, and the character information in the identification detection file is various expression modes of various existing german characters, the storage mode is to store the same meaning characters as one group, and the mark of each group of characters is the most common german character, and the character training method of the RBF neural network is constructed through the original character grouping storage mode, the generation mode of the character training method can refer to fig. 4, fig. 4 is a schematic diagram of a layered structure of the RBF neural network, and the specific construction mode is as follows:
an input layer: the input of the RBF network is a training sample feature matrix X obtained by subjecting the preprocessed identification detection file to a dimension reduction method (such as PCA, LDA), wherein each column of X is feature data of a training sample subjected to dimension reduction, and the number of columns of X is the number of the training samples. The number of nodes of the input layer is X line number (characteristic dimension of the sample after dimensionality reduction).
Hidden layer: the hidden layer carries out nonlinear transformation on the input data X through the kernel function, so that the transformed data are easier to linearly divide. The RBF neural network refers to a network in which the kernel function of the hidden layer is a radial basis function. The invention chooses to use the most common radial basis function, the gaussian function, as the kernel function. Based on the calculation mode of the gaussian function, without limiting the width parameter of the kernel function, for an input vector X (any column in input data X), an expression output by the ith node of the hidden layer is as follows:
equation 1:
wherein c is
iCore-centric to the ith node of the hidden layer, σ
2Is the width parameter of the kernel function.
Equation 2: implicit layer node number ═ 10 × max { input layer node number, output layer node number } +1, where the "+ 1" term represents a bias node (whose value is 1);
an output layer: each column in the output matrix Y of the output layer corresponds to a class of samples represented by a corresponding column of the training sample feature matrix X, and the value of each column is a digital value of the class in a group of digital codes obtained by orthogonally encoding all classes (e.g., a-letter code of 1000 … … 0, b-letter code of 01000 … … 0, etc.). The number of nodes of the output layer is the length (number of digits) of the orthogonal code, and the value of each node corresponds to the corresponding number of digits in the codeThe value is obtained. The output of the output layer (i.e., the output of the entire network) is represented by an output matrix B to the hidden layer (each column of which is B in equation (1))i) Equation 3 is obtained by the following linear transformation: and Y is WB, wherein W is a transformation matrix (weight matrix) from the hidden layer to the output layer.
In addition, based on the training process of the RBF classifier, the training process can be further divided into training from an input layer to a hidden layer and training from the hidden layer to an output layer, as follows:
training of input layer to hidden layer:
the main objective is to determine c in formula (1)iAnd σ2The value of (c). The invention selects N (N is the number of nodes of the hidden layer) cluster centers from training samples by adopting a K-means clustering algorithm as the core center c of the N nodes of the hidden layeriIn most RBF training strategies, σ2Generally, it is obtained by a gradient descent method or the like. In contrast, the invention adopts an empirical method to select the sigma2I.e. selecting its value as all core centers ciThe square of the average distance between. The method omits the pair sigma2The training process of value selection is simple and easy to implement, and a good effect is achieved in practice.
Hidden layer to output layer training:
mainly used for determining the value of the weight matrix W. According to equation (3) and the least squares method, W can be simply obtained from the following equation:
equation 4): w is YBT(BBT+λI)-1And the selection of the lambda value can be realized by a generalized cross validation mode.
In addition, an embodiment of the present invention further provides a computer-readable storage medium, where the german old font identification program is stored on the computer-readable storage medium.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) as described above and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.