A text recognition method and apparatus
Patent Information
- Application Number
- CN202110743926.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-01
- Publication Date
- 2026-09-25
- Estimated Expiration
- 2041-07-01
AI Technical Summary
[0003]但是对于一些文本,比如汉字,它是一种强表义的语言文字,汉字词语内部的结构信息包含了丰富的语义特征,word2vec模型不能很好地利用汉字词语内部的结构信息,使得文本识别的精确度较低
[0017]本申请实施例提供了一种文本识别方法和装置,可以获取目标文本,所述目标文本包括至少一个文本单元;针对所述目标文本中各个文本单元,按照所述文本单元的书写顺序规则,对所述文本单元进行笔画拆分处理,得到所述目标文本的笔画表示;基于所述笔画表示,构建所述目标文本的语义特征信息;基于所述语义特征信息,预测所述目标文本属于每个预设文本类型的概率;根据所述概率,从所述预设文本类型中确定所述目标文本对应的目标文本类型。本申请实施例可以基于目标文本的笔画表示来构建其语义特征信息,进而预测其文本类型,通过笔画表示,可以很好地利用文本词语内部的结构信息,使得构建得到的语义特征信息的表征力更强,有利于提高文本识别的准确度。
Smart Images

Figure CN113420565B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, specifically to a text recognition method and apparatus. Background Technology
[0002] With the development of computer technology, text recognition is gradually becoming one of the most classic research directions in the field of artificial intelligence. Current text recognition methods generally convert the text to be recognized directly into word vectors through word2vec (word to vector) models, and then mine the text to be recognized based on the word vectors.
[0003] However, for some texts, such as Chinese characters, which are a strongly semantic language, the structural information within Chinese words contains rich semantic features. The word2vec model cannot make good use of the structural information within Chinese words, resulting in low accuracy in text recognition. Summary of the Invention
[0004] This application provides a text recognition method and apparatus that can improve the accuracy of text recognition.
[0005] This application provides a text recognition method, including: Obtain target text, wherein the target text includes at least one text unit; For each text unit in the target text, the text unit is decomposed into strokes according to the writing order rules of the text unit to obtain the stroke representation of the target text; Based on the stroke representation, the semantic feature information of the target text is constructed; Based on the semantic feature information, predict the probability that the target text belongs to each preset text type; Based on the probability, the target text type corresponding to the target text is determined from the preset text types.
[0006] Accordingly, embodiments of this application provide a text recognition device, including: An acquisition unit is used to acquire target text, wherein the target text includes at least one text unit; The stroke splitting unit is used to perform stroke splitting processing on each text unit in the target text according to the writing order rules of the text units, so as to obtain the stroke representation of the target text. A construction unit is used to construct semantic feature information of the target text based on the stroke representation; The prediction unit is used to predict the probability that the target text belongs to each preset text type based on the semantic feature information; The determining unit is configured to determine the target text type corresponding to the target text from the preset text types based on the probability.
[0007] Optionally, in some embodiments of this application, the stroke splitting unit may include a character decomposition subunit and a stroke splitting subunit, as follows: The character decomposition subunit is used to decompose the text unit into characters to obtain at least one character component of the text unit; The stroke splitting subunit is used to perform stroke splitting processing on each character component of the text unit according to the writing order rules of the text unit, so as to obtain the stroke representation of the target text.
[0008] Optionally, in some embodiments of this application, the stroke representation includes at least one stroke; the construction unit may include a first acquisition subunit, a generation subunit, and an extraction subunit, as follows: The first acquisition subunit is used to acquire the encoding information corresponding to each stroke of the target text; A subunit is generated to generate a stroke-encoded string of the target text based on the encoding information. The extraction subunit is used to extract features from the stroke-encoded string of the target text to obtain the semantic feature information of the target text.
[0009] Optionally, in some embodiments of this application, the generating subunit may be specifically used to construct an initial stroke encoding string of the target text according to the encoding information and the writing order rules of each text unit in the target text; and to perform string truncation on the initial stroke encoding string based on a preset string length to obtain at least one stroke encoding string of the target text.
[0010] Optionally, in some embodiments of this application, the extraction subunit may be specifically used to extract features from each stroke encoding string of the target text to obtain semantic sub-features corresponding to each stroke encoding string of the target text; and to fuse the semantic sub-features corresponding to each stroke encoding string to obtain the semantic feature information of the target text.
[0011] Optionally, in some embodiments of this application, the step "fusing the semantic sub-features corresponding to each stroke encoding string to obtain the semantic feature information of the target text" may include: Attention processing is performed on each stroke encoding string to obtain the attention weight corresponding to each stroke encoding string; Based on the attention weights, the semantic sub-features corresponding to each stroke encoding string are fused to obtain the semantic feature information of the target text.
[0012] Optionally, in some embodiments of this application, the prediction unit may include a second acquisition subunit, a calculation subunit, and a determination subunit, as follows: The second acquisition subunit is used to acquire the reference text corresponding to each preset text type; The calculation subunit is used to calculate the similarity between the semantic feature information of the target text and the semantic feature information of the reference text corresponding to each preset text type; A sub-unit is defined to determine the probability that the target text belongs to each preset text type based on the similarity.
[0013] Optionally, in some embodiments of this application, the construction unit may be specifically used to construct the semantic feature information of the target text based on the stroke representation through a text recognition model.
[0014] Optionally, in some embodiments of this application, the text recognition device may further include a training unit, which is used to train the text recognition model, as follows: The training unit is used to acquire training data, which includes sample text and the expected probability of the sample text belonging to each preset text type. For each text unit in the sample text, stroke decomposition is performed according to the writing order rules of the text units to obtain the stroke representation of the sample text. Based on the stroke representation, semantic feature information of the sample text is constructed using a preset text recognition model. Based on the semantic feature information of the sample text, the actual probability of the sample text belonging to each preset text type is predicted. The parameters of the preset text recognition model are adjusted according to the actual probability and the expected probability to obtain the text recognition model.
[0015] An electronic device provided in this application includes a processor and a memory. The memory stores multiple instructions, and the processor loads the instructions to execute the steps in the text recognition method provided in this application.
[0016] Furthermore, this application embodiment also provides a storage medium storing a computer program thereon, wherein the computer program, when executed by a processor, implements the steps in the text recognition method provided in this application embodiment.
[0017] This application provides a text recognition method and apparatus that can acquire target text, which includes at least one text unit; for each text unit in the target text, perform stroke decomposition processing according to the writing order rules of the text unit to obtain the stroke representation of the target text; construct semantic feature information of the target text based on the stroke representation; predict the probability that the target text belongs to each preset text type based on the semantic feature information; and determine the target text type corresponding to the target text from the preset text types according to the probability. This application embodiment can construct its semantic feature information based on the stroke representation of the target text, and then predict its text type. Through stroke representation, the structural information inside the text words can be well utilized, making the constructed semantic feature information more representative and improving the accuracy of text recognition. Attached Figure Description
[0018] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1a This is a schematic diagram of a scenario for the text recognition method provided in an embodiment of this application; Figure 1b This is a flowchart of the text recognition method provided in the embodiments of this application; Figure 1c This is an illustrative diagram of the text recognition method provided in the embodiments of this application; Figure 1d This is another illustrative diagram of the text recognition method provided in the embodiments of this application; Figure 1e This is another flowchart of the text recognition method provided in the embodiments of this application; Figure 1f This is an illustrative diagram of the text recognition method provided in the embodiments of this application; Figure 2 This is another flowchart of the text recognition method provided in the embodiments of this application; Figure 3 This is a schematic diagram of the structure of the text recognition device provided in the embodiments of this application; Figure 4 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0020] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0021] This application provides a text recognition method and apparatus. Specifically, the text recognition apparatus can be integrated into an electronic device, such as a terminal or server.
[0022] It is understood that the text recognition method of this embodiment can be executed on a terminal, on a server, or jointly by a terminal and a server. The above examples should not be construed as limiting this application.
[0023] like Figure 1a As shown, the text recognition method is performed jointly by a terminal and a server as an example. The text recognition system provided in this application includes a terminal 10 and a server 11, etc.; the terminal 10 and the server 11 are connected through a network, such as through a wired or wireless network, etc., wherein the text recognition device can be integrated into the server.
[0024] Server 11 can be used to: acquire target text, which includes at least one text unit; perform stroke decomposition processing on each text unit in the target text according to the writing order rules of the text unit to obtain the stroke representation of the target text; construct semantic feature information of the target text based on the stroke representation; predict the probability that the target text belongs to each preset text type based on the semantic feature information; determine the target text type corresponding to the target text from the preset text types according to the probability; and send the target text type to terminal 10. Server 11 can be a single server, a server cluster composed of multiple servers, or a cloud server. In the text recognition method or apparatus disclosed in this application, multiple servers can form a blockchain, and the server is a node on the blockchain.
[0025] Terminal 10 can receive target text types sent by server 11 and process the target text accordingly. For example, in an operating system, if a user publishes target text and the text type is identified as a complaint, customer service feedback can be prioritized for the user who published the target text in order to address the user's problem promptly and improve user experience. Terminal 10 can include mobile phones, smart TVs, tablets, laptops, or personal computers (PCs). A client can also be set on terminal 10, which can be an application client or a browser client, etc.
[0026] The steps of the server 11 recognizing text described above can also be performed by the terminal 10.
[0027] The text recognition method provided in this application relates to natural language processing in the field of artificial intelligence. This application can improve the accuracy of text recognition.
[0028] Artificial intelligence (AI) is the theory, methods, technology, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science that attempts to understand the essence of intelligence and produce a new kind of intelligent machine that can react in a way similar to human intelligence. AI studies the design principles and implementation methods of various intelligent machines, enabling them to have perception, reasoning, and decision-making capabilities. AI technology is a comprehensive discipline involving a wide range of fields, encompassing both hardware and software technologies. AI software technologies mainly include computer vision, speech processing, natural language processing, as well as machine learning / deep learning, autonomous driving, and intelligent transportation.
[0029] Natural Language Processing (NLP) is an important area within computer science and artificial intelligence. It studies the theories and methods for enabling effective communication between humans and computers using natural language. NLP is a science that integrates linguistics, computer science, and mathematics. Therefore, research in this field involves natural language—the language people use in daily life—and thus it has a close connection with linguistic research. NLP technologies typically include text processing, semantic understanding, machine translation, question answering, and knowledge graphs.
[0030] Detailed descriptions are provided below respectively. It should be noted that the description order of the following embodiments does not serve as a limitation on the preferred order of the embodiments.
[0031] This embodiment will be described from the perspective of a text recognition apparatus, which may specifically be integrated in an electronic device, and the electronic device may be a server, a terminal, or other devices.
[0032] The text recognition method according to the embodiments of the present application can be applied to various text recognition scenarios. For example, when an instant messaging platform needs to provide feedback to questions from millions of users, the text recognition method provided in this embodiment can be used to quickly perform text recognition on massive questions, filter out texts of complaint type therefrom, and provide quick feedback for complaint-type texts, so as to improve user experience. The text recognition method provided in this embodiment can enhance the representation capability of the extracted semantic feature information, which is beneficial to improving the accuracy of text recognition.
[0033] As Figure 1b shows, the specific process of the text recognition method can be as follows: 101. Acquire a target text, wherein the target text includes at least one text unit.
[0034] Wherein, the target text is a text whose text type is to be determined, and may have multiple language types, for example, it may be Chinese (Chinese characters), which is not limited in this embodiment. The target text may be a word or a single character, and may include one or more text units. After the target text is acquired, text division may be performed on it to obtain at least one text unit of the target text. For example, if the target text is "大人", after text division is performed thereon, two text units "大" and "人" can be obtained.
[0035] Wherein, there may be various text types, such as complaint-type text, text containing sensitive information, etc.
[0036] Specifically, if the target text is Chinese, the text unit may be a single Chinese character.
[0037] In current related technologies of character recognition, generally a word2vec (word to vector) model can be used to extract features from a text, and then text recognition is performed based on feature information.
[0038] word2vec is an NLP (Nature Language Processing) tool, which is characterized by its ability to convert words into vector representations. This allows quantitative measurement of the relationships between words and excavation of the connections between words. The training model of word2vec is essentially a neural network with a single hidden layer, whose input is a vocabulary vector encoded by One-Hot encoding, and whose output is also a vocabulary vector encoded by One-Hot encoding.
[0039] Although the word2vec algorithm can learn useful word vectors, it only describes the contextual structure information of words. For some texts, such as Chinese text, Chinese is a language with strong semantic expression, especially in data in the cybersecurity field, there are many variant expressions of words. For example, for the two words "小姐" (young lady / prostitute, depending on context) and "小女且", lawbreakers often deliberately write the latter through "shape deformation" to evade interception systems. word2vec cannot effectively utilize the internal structural information of Chinese words, and thus cannot identify that "小女且" is a shape-deformed variant of "小姐". The text recognition method provided by the present application can construct semantic feature information through the stroke representation of text, better characterize the "shape" feature of Chinese words, generate higher-quality word vectors, and further provide a larger amount of information for subsequent deep neural networks.
[0040] 102. For each text unit in the target text, perform stroke splitting processing on the text unit according to the writing order rule of the text unit, to obtain the stroke representation of the target text.
[0041] In a specific embodiment, the target text is "大人" (adult), which includes two text units "大" and "人". Stroke splitting processing can be performed on "大" and "人" according to the writing order rule of these two characters. For example, the first stroke of the text unit "大" is horizontal, the second stroke is left-falling, and the third stroke is right-pressing, so the stroke representation corresponding to the text unit "大" is "一ノ丶"; the first stroke of the text unit "人" is left-falling, and the second stroke is right-pressing, so the stroke representation corresponding to the text unit "人" is "ノ丶". Therefore, the stroke representation of the target text "大人" can be obtained as "一ノ丶 ノ丶".
[0042] Wherein, a Chinese word group is split into individual Chinese characters, then each character is represented by strokes respectively, and then the stroke representation of the word is formed.
[0043] Optionally, in this embodiment, the step of "performing stroke splitting processing on the text unit according to the writing order rule of the text unit to obtain the stroke representation of the target text" may include: performing character decomposition on the text unit to obtain at least one character component of the text unit; performing stroke splitting processing on each character component of the text unit according to the writing order rule of the text unit to obtain a stroke representation of the target text.
[0044] wherein, for some text units, the text unit can be composed of a plurality of parts, that is, the text unit has a plurality of character components. For example, for the text unit "智", performing character decomposition thereon can obtain three character components, which are "矢", "口" and "日" respectively, or can obtain two character components, which are "知" and "日" respectively, as Figure 1c shown. After the character components are obtained, stroke splitting processing is performed on the character components according to the writing order rule.
[0045] 103: constructing semantic feature information of the target text based on the stroke representation.
[0046] optionally, in this embodiment, the stroke representation includes at least one stroke; the step of "constructing semantic feature information of the target text based on the stroke representation" may comprise: acquiring encoding information corresponding to each stroke of the target text; generating a stroke encoding string of the target text according to the encoding information; performing feature extraction on the stroke encoding string of the target text to obtain semantic feature information of the target text.
[0047] wherein, the encoding information corresponding to each stroke may specifically be identification information of each stroke, and the encoding information may have various forms, for example, may be numbers, or may be letters, etc.
[0048] for Chinese, strokes of text can comprise horizontal (heng), vertical (shu), left-falling (pie), right-falling (na) and turning (zhe). In a specific embodiment, as Figure 1d shown, the encoding information corresponding to the five strokes of horizontal, vertical, left-falling, right-falling and turning are respectively recorded as numbers 1, 2, 3, 4 and 5, in addition, the shapes corresponding to horizontal, vertical, left-falling, right-falling and turning can be as Figure 1d shown.
[0049] in one embodiment, the target text is "大人", and the corresponding stroke representation is "一ノ丶ノ丶", from Figure 1d it can be known that the encoding information corresponding to the horizontal stroke "一" is 1, the encoding information corresponding to the left-falling stroke "ノ" is 3, and the encoding information corresponding to the right-falling stroke "丶" is 4, so the stroke encoding string thereof can specifically be "13434".
[0050] Wherein, the feature extraction of the stroke encoding string may specifically be convolution processing, pooling processing, etc., which is not limited in this embodiment.
[0051] Optionally, in this embodiment, the step of "generating a stroke encoding string of the target text according to the encoding information" may include: Constructing an initial stroke encoding string of the target text according to the encoding information and in accordance with the writing order rule of each text unit in the target text; Truncating the initial stroke encoding string based on a preset string length to obtain at least one stroke encoding string of the target text.
[0052] Wherein, the initial stroke encoding string may specifically be an encoding sequence composed of encoding information corresponding to each stroke in the stroke representation of the target text. Specifically, each piece of encoding information in the encoding sequence corresponds to each stroke in the stroke representation one-to-one, and the stroke representation may also be regarded as a stroke sequence.
[0053] Wherein, the length of the initial stroke encoding string may be the number of strokes of the target text. In some embodiments, the stroke encoding string may include the initial stroke encoding string, wherein the initial stroke encoding string is the longest string among the stroke encoding strings.
[0054] Wherein, the preset string length can be set according to actual situations, which is not limited in this embodiment. Generally, the preset string length is not greater than the length of the initial stroke encoding string. Optionally, the preset string length may not be fixed, that is, it may change dynamically.
[0055] Specifically, truncating the initial stroke encoding string based on the preset string length can also be regarded as sliding a preset window on the initial stroke encoding string to truncate the initial stroke encoding string, so as to obtain a stroke encoding string with the preset string length. The length of the preset window is the preset string length.
[0056] For example, the preset string length may be greater than 2 and not exceed the length of the initial stroke encoding string. For the target text "大人", its stroke representation is "一ノ丶ノ丶", and the initial stroke encoding string can be "13434", the preset string length can be set to 3, 4 and 5. Based on the preset string length, truncating the initial stroke encoding string can obtain 3-stroke stroke encoding strings: 134, 343, 434, 4-stroke stroke encoding strings: 1343, 3434, and the 5-stroke stroke encoding string: 13434, that is, the stroke encoding strings corresponding to n-gram strokes of the target text are obtained.
[0057] The text recognition method provided by the present application can extract semantic units of Chinese characters by constructing stroke encoding strings of different lengths, that is, by constructing "n-gram strokes". For example, the two words "forest" and "wood" share many 4-gram strokes corresponding to the character "wood", so the two words have a high correlation. Compared with word decomposition at the granularity of Chinese characters and radicals, n-gram strokes are a kind of semantic structure that is not manually summarized and is automatically counted by algorithms.
[0058] In a specific embodiment, the process of constructing the stroke encoding string of the target text is as Figure 1e shown. If the target text is "adult", after word segmentation, each text unit of the target text can be obtained, which are two text units "big" and "person" respectively; then, stroke retrieval (in other words, stroke splitting processing) is performed on each text unit of the target text to obtain the stroke sequence corresponding to the target text unit (stroke sequence, that is, the stroke representation described in the above embodiment), then encoding information can be used to represent the stroke sequence. Specifically, the encoding information corresponding to each stroke in the stroke sequence can be obtained, and then the encoding information corresponding to each stroke is combined to obtain the encoding sequence of the target text (that is, the initial stroke encoding string described in the above embodiment); through a sliding window with a preset string length, n-gram stroke encoding strings are intercepted on the initial stroke encoding string. For example, if the encoding sequence of the target text is "13434", sliding on the encoding sequence through sliding windows with string lengths of 3, 4 and 5 can obtain 3-stroke encoding strings 134, 343 and 434, 4-stroke encoding strings 1343 and 3434, and 5-stroke encoding string 13434.
[0059] Optionally, in this embodiment, the step of "performing feature extraction on the stroke encoding string of the target text to obtain the semantic feature information of the target text" may include: performing feature extraction on each stroke encoding string of the target text to obtain semantic sub-features corresponding to each stroke encoding string of the target text; fusing the semantic sub-features corresponding to each stroke encoding string to obtain the semantic feature information of the target text.
[0060] Wherein, there are multiple fusion methods for the semantic sub-features corresponding to each stroke encoding string, and this embodiment does not limit this. For example, the fusion method may be weighting operation, etc.
[0061] For example, in the above embodiment, for the target text "adult", 6 stroke coding strings can be obtained, feature extraction is performed on the 6 stroke coding strings respectively to obtain 6 semantic sub-features, and then feature fusion, such as weighted fusion, is performed on the semantic sub-features to obtain semantic feature information of the target text.
[0062] Optionally, in this embodiment, the step "fusing semantic sub-features corresponding to each stroke coding string to obtain semantic feature information of the target text" may include: performing attention processing on each stroke coding string to obtain an attention weight corresponding to each stroke coding string; fusing the semantic sub-features corresponding to each stroke coding string according to the attention weights to obtain the semantic feature information of the target text.
[0063] Wherein, a self-attention model can be used to generate the attention weight corresponding to each stroke coding string.
[0064] Wherein, the attention processing may be hyperbolic tangent processing, nonlinear mapping processing, etc., which is not limited in this embodiment.
[0065] 104. Based on the semantic feature information, predict the probability that the target text belongs to each preset text type.
[0066] Wherein, a classifier can be used to predict the text type of the target text. Specifically, the classifier may be a Support Vector Machine (SVM), a recurrent neural network, or a Deep Neural Network (DNN), etc., which is not limited in this embodiment.
[0067] In an embodiment, the preset text types may include a complaint type and a non-complaint type.
[0068] Optionally, in this embodiment, the step "based on the semantic feature information, predicting the probability that the target text belongs to each preset text type" may include: obtaining reference texts corresponding to each preset text type; calculating the similarity between the semantic feature information of the target text and the semantic feature information of the reference text corresponding to each preset text type; determining the probability that the target text belongs to each preset text type according to the similarity.
[0069] The greater the similarity between the target text and the reference text corresponding to the preset text type, the greater the probability that the target text belongs to the preset text type; conversely, the smaller the similarity between the target text and the reference text corresponding to the preset text type, the smaller the probability that the target text belongs to the preset text type.
[0070] The step of "calculating the similarity between the semantic feature information of the target text and the semantic feature information of the reference texts corresponding to each preset text type" may include: Calculate the vector distance between the semantic feature vector of the target text and the semantic feature vector of the reference text corresponding to each preset text type; Based on the vector distance, the similarity between the target text and the reference text corresponding to each preset text type is determined.
[0071] The vector distance can be cosine distance, Euclidean distance, etc., and this embodiment does not limit it. The vector distance can characterize the similarity between two semantic feature vectors. The larger the vector distance, the smaller the similarity between the two semantic feature vectors, and correspondingly, the smaller the similarity between the target text and the reference text corresponding to the preset text type; conversely, the smaller the vector distance, the greater the similarity between the two semantic feature vectors, and correspondingly, the greater the similarity between the target text and the reference text corresponding to the preset text type.
[0072] Optionally, in this embodiment, the step "constructing semantic feature information of the target text based on the stroke representation" may include: Based on the stroke representation, the semantic feature information of the target text is constructed using a text recognition model. The step "based on the semantic feature information, predicting the probability that the target text belongs to each preset text type" may include: Based on the semantic feature information, the text recognition model predicts the probability that the target text belongs to each preset text type.
[0073] The text recognition model can be a neural network, such as cw2vec (Chinese word to vector). It is understood that the text recognition model in this embodiment is not limited to the types listed above.
[0074] CW2Vec is an improvement on the skip-gram (Continuous Skip-gram Model). The CW2Vec model uses the n-gram stroke features of words instead of words for training. The CW2Vec model is as follows: Figure 1fAs shown. Its training objective is to infer the context based on the central word. During training, if the sample text is "smog" and its context text is "governance" and "urgent", the cw2vec model can obtain the stroke representation of the sample text "smog", and then construct n-grams (including 3-grams, 4-grams, 5-grams, etc.) based on the encoding information corresponding to each stroke in the stroke representation. That is, it constructs stroke encoding strings of different lengths, and then performs feature extraction on the stroke encoding strings to obtain the target text "smog". The semantic feature information of "smog" is obtained by acquiring the feature information corresponding to the context text "governance" and "urgent" of the target text "smog". The feature information corresponding to "governance" and "urgent" is then fused to obtain the fused feature information. The actual similarity between the semantic feature information of the target text "smog" and the fused feature information is then calculated. Based on the actual similarity and the preset expected similarity, the loss value corresponding to the semantic feature information of the target text is determined. The parameters of the cw2vec model are adjusted based on the loss value to obtain the trained cw2vec model.
[0075] In some embodiments, the step of "fusing the feature information corresponding to 'governance' and 'urgent' to obtain fused feature information" may specifically include: Obtain the weights corresponding to the two terms "governance" and "urgent". Based on the weights, the feature information corresponding to "governance" and "urgent" is weighted and calculated to obtain the fused feature information.
[0076] Here, s1 can be used to represent the weight corresponding to "governance", s2 can be used to represent the weight corresponding to "urgent", the feature information corresponding to "governance" can be denoted as v1, and the feature information corresponding to "urgent" can be denoted as v2. Then the fused feature information can be expressed as: s1*v1+s2*v2.
[0077] In other embodiments, the feature information corresponding to "governance" and "urgent" is fused. Specifically, the feature information corresponding to "governance" and the feature information corresponding to "urgent" can be concatenated to obtain the fused feature information. For example, the feature information corresponding to "governance" can be concatenated after the feature information corresponding to "urgent", or the feature information corresponding to "urgent" can be concatenated after the feature information corresponding to "governance". This embodiment does not limit this.
[0078] The cw2vec algorithm utilizes both the internal structure of Chinese words and their contextual information to design its loss function, thus obtaining higher-quality Chinese word vectors.
[0079] It should be noted that the text recognition model is trained from multiple labeled training data. In this embodiment, the training data includes multiple sample texts, and the label refers to the expected probability that the sample text belongs to each preset text type. The text recognition model can be trained by other devices and then provided to the text recognition device, or it can be trained by the text recognition device itself.
[0080] If the text recognition device performs the training itself, then before the step "constructing the semantic feature information of the target text based on the stroke representation using the text recognition model", the following may also be included: Acquire training data, which includes sample text and the expected probability that the sample text belongs to each preset text type; For each text unit in the sample text, the text unit is decomposed into strokes according to the writing order rules of the text unit to obtain the stroke representation of the sample text; Based on the stroke representation, the semantic feature information of the sample text is constructed using a preset text recognition model. Based on the semantic feature information of the sample text, predict the actual probability that the sample text belongs to each preset text type; Based on the actual probability and the expected probability, the parameters of the preset text recognition model are adjusted to obtain the text recognition model.
[0081] The training process involves first calculating the actual probability of a sample text belonging to each preset text type. Then, the backpropagation algorithm is used to adjust the parameters of the preset text recognition model. Based on the actual probability of the sample text belonging to each preset text type and the corresponding expected probability, the parameters of the preset text recognition model are optimized so that the actual probability of the sample text belonging to each preset text type approaches the expected probability, resulting in the trained text recognition model. Specifically, the loss value between the calculated actual probability of the sample text belonging to each preset text type and the expected probability can be less than a preset value. This preset value can be set according to the actual situation.
[0082] Specifically, the loss value between the actual probability and the expected probability of the sample text belonging to each preset text type can be calculated using the cross-entropy loss function, the mean squared error loss function, etc., and this embodiment does not impose any restrictions on this.
[0083] The training data can be composed of complaint texts from users on an instant messaging platform. These complaint texts are then segmented to obtain sample texts.
[0084] In one specific embodiment, for tasks such as calculating the semantic similarity of Chinese characters, the text recognition method of this application (denoted as the Substoke model) can be compared with other methods such as the CBOW model (Continuous Bag-of-Words Model) and the Skipgram model (Continuous Skip-gram Model). Specifically, the parameter settings are: 5 iterations, minimum word frequency of 10, word vector dimension of 100, number of negative samples of 5, window size of 5, learning rate of 0.025 for the Skipgram model, 0.05 for the CBOW model, and 0.025 for the Substoke model. Additionally, the minimum length of the stroke encoding string corresponding to the n-gram stroke is 3, and the maximum is 18. The experimental results are shown in Table 1 below. Table 1
[0085] There are two evaluation task files, labeled wordsim-240 and wordsim-296. In Table 1, substoke-average represents the word vectors used, which are obtained by averaging the semantic sub-features of the stroke-encoded strings of n-gram strokes. Substoke-context represents the word vectors used, which are obtained by constructing word vectors from the stroke representations of the context words.
[0086] Table 1 shows that, in the task of calculating the semantic similarity of Chinese characters, the Substoke model generally outperforms the Skipgram and CBOW models. Specifically, on Wordsim-240, both word vectors from Substoke perform better than those from Word2vec. On Wordsim-296, Substoke-context performs relatively worse, but Substoke-average is significantly better. Overall, the CW2vec algorithm outperforms Word2vec.
[0087] 105. Based on the probability, determine the target text type corresponding to the target text from the preset text types.
[0088] Specifically, the preset text type with the highest probability can be used as the target text type corresponding to the target text.
[0089] For example, if the probability that the target text belongs to the complaint type is 0.7, and the probability that it belongs to the non-complaint text type is 0.2, then the target text can be determined to be a complaint type text.
[0090] It can be seen from the above that this embodiment can obtain a target text, wherein the target text includes at least one text unit; for each text unit in the target text, stroke splitting processing is performed on the text unit according to the writing order rule of the text unit to obtain a stroke representation of the target text; semantic feature information of the target text is constructed based on the stroke representation; based on the semantic feature information, a probability that the target text belongs to each preset text type is predicted; and according to the probability, a target text type corresponding to the target text is determined from the preset text types. The embodiment of the present application can construct semantic feature information of a target text based on the stroke representation thereof, and further predict the text type thereof. Through the stroke representation, the structural information inside text words can be well utilized, so that the constructed semantic feature information has stronger representation capability, which is beneficial to improving the accuracy of text recognition.
[0091] According to the method described in the previous embodiments, the following further detailed description will be given by taking an example where the text recognition device is specifically integrated in a server.
[0092] An embodiment of the present application provides a text recognition method, as Figure 2 shown, the specific process of the text recognition method can be as follows: 201. A server acquires a target text, wherein the target text includes at least one text unit.
[0093] Wherein, the target text is a text whose text type is to be determined, and can have multiple language types, for example, it can be Chinese (Chinese characters), which is not limited in this embodiment. The target text can be a word or a single character, and can include one or more text units. After the target text is obtained, text division can be performed on the target text to obtain at least one text unit of the target text. For example, if the target text is "大人", after text division, two text units "大" and "人" can be obtained.
[0094] The text recognition method provided in the present application can construct semantic feature information through the stroke representation of text, well characterize the "form" feature of Chinese words, generate higher-quality word vectors, and further provide a larger amount of information for a subsequent deep neural network.
[0095] 202. For each text unit in the target text, a server performs stroke splitting processing on the text unit according to a writing order rule of the text unit to obtain a stroke representation of the target text; the stroke representation includes at least one stroke.
[0096] In a specific embodiment, the target text is "大人 (adult)", which comprises two text units "大 (big / large)" and "人 (person)". The stroke splitting processing may be performed on "大" and "人" according to the writing order rule of the two characters. For example, the first stroke of the text unit "大" is "horizontal", the second stroke is "left-falling", and the third stroke is "right-falling", so the stroke representation corresponding to the text unit "大" is "一ノ丶"; the first stroke of the text unit "人" is "left-falling" and the second stroke is "right-falling", so the stroke representation corresponding to the text unit "人" is "ノ丶". Therefore, the stroke representation of the target text "大人" can be obtained as "一ノ丶 ノ丶".
[0097] Wherein, a Chinese word phrase is split into individual Chinese characters, then each character is represented by strokes respectively, and then the stroke representation of the word is formed.
[0098] 203. A server acquires encoding information corresponding to each stroke of the target text.
[0099] Wherein, the encoding information corresponding to each stroke may specifically be identification information of each stroke, and the encoding information may have various forms, for example, it may be numbers, or may be letters, etc.
[0100] 204. The server generates a stroke encoding string of the target text according to the encoding information.
[0101] Optionally, in this embodiment, the step of "generating the stroke encoding string of the target text according to the encoding information" may comprise: constructing an initial stroke encoding string of the target text according to the encoding information and in accordance with the writing order rule of each text unit in the target text; performing string interception on the initial stroke encoding string based on a preset string length to obtain at least one stroke encoding string of the target text.
[0102] Wherein, the initial stroke encoding string may specifically be an encoding sequence formed by encoding information corresponding to each stroke in the stroke representation of the target text. Specifically, each piece of encoding information in the encoding sequence corresponds to each stroke in the stroke representation one to one, and the stroke representation may also be specifically regarded as a stroke sequence.
[0103] Specifically, performing string interception on the initial stroke encoding string based on a preset string length can also be regarded as sliding a preset window on the initial stroke encoding string to perform string interception on the initial stroke encoding string, so as to obtain a stroke encoding string with the preset string length. The length of the preset window is the preset string length.
[0104] 205. The server extracts features from the stroke-encoded string of the target text to obtain the semantic feature information of the target text.
[0105] Optionally, in this embodiment, the step "extracting features from the stroke-encoded string of the target text to obtain the semantic feature information of the target text" may include: Feature extraction is performed on each stroke encoding string of the target text to obtain the semantic sub-features corresponding to each stroke encoding string of the target text; The semantic sub-features corresponding to each stroke encoding string are fused to obtain the semantic feature information of the target text.
[0106] There can be multiple ways to fuse the semantic sub-features corresponding to each stroke encoding string, and this embodiment does not limit this. For example, the fusion method can be a weighted operation, etc.
[0107] 206. Based on the semantic feature information, the server predicts the probability that the target text belongs to each preset text type.
[0108] 207. The server determines the target text type corresponding to the target text from the preset text types based on the probability.
[0109] Specifically, the preset text type with the highest probability can be used as the target text type corresponding to the target text.
[0110] As can be seen from the above, this embodiment can obtain target text through a server. The target text includes at least one text unit. For each text unit in the target text, stroke decomposition processing is performed on the text unit according to the writing order rules of the text unit to obtain the stroke representation of the target text. The stroke representation includes at least one stroke. The encoding information corresponding to each stroke of the target text is obtained. Based on the encoding information, the stroke encoding string of the target text is generated. Feature extraction is performed on the stroke encoding string of the target text to obtain the semantic feature information of the target text. Based on the semantic feature information, the probability of the target text belonging to each preset text type is predicted. Based on the probability, the target text type corresponding to the target text is determined from the preset text types. This embodiment can construct its semantic feature information based on the stroke representation of the target text, and then predict its text type. Through stroke representation, the structural information inside the text words can be well utilized, making the representational power of the constructed semantic feature information stronger, which is conducive to improving the accuracy of text recognition.
[0111] To better implement the above methods, embodiments of this application also provide a text recognition device, such as... Figure 3As shown, the text recognition device may include an acquisition unit 301, a stroke segmentation unit 302, a construction unit 303, a prediction unit 304, and a determination unit 305, as follows: (1) Obtain unit 301; The acquisition unit 301 is used to acquire target text, which includes at least one text unit.
[0112] (2) Stroke splitting unit 302; The stroke splitting unit 302 is used to perform stroke splitting processing on each text unit in the target text according to the writing order rules of the text units, so as to obtain the stroke representation of the target text.
[0113] Optionally, in some embodiments of this application, the stroke splitting unit may include a character decomposition subunit and a stroke splitting subunit, as follows: The character decomposition subunit is used to decompose the text unit into characters to obtain at least one character component of the text unit; The stroke splitting subunit is used to perform stroke splitting processing on each character component of the text unit according to the writing order rules of the text unit, so as to obtain the stroke representation of the target text.
[0114] (3) Constructing unit 303; The construction unit 303 is used to construct the semantic feature information of the target text based on the stroke representation.
[0115] Optionally, in some embodiments of this application, the stroke representation includes at least one stroke; the construction unit may include a first acquisition subunit, a generation subunit, and an extraction subunit, as follows: The first acquisition subunit is used to acquire the encoding information corresponding to each stroke of the target text; A subunit is generated to generate a stroke-encoded string of the target text based on the encoding information. The extraction subunit is used to extract features from the stroke-encoded string of the target text to obtain the semantic feature information of the target text.
[0116] Optionally, in some embodiments of this application, the generating subunit may be specifically used to construct an initial stroke encoding string of the target text according to the encoding information and the writing order rules of each text unit in the target text; and to perform string truncation on the initial stroke encoding string based on a preset string length to obtain at least one stroke encoding string of the target text.
[0117] Optionally, in some embodiments of this application, the extraction subunit may be specifically used to extract features from each stroke encoding string of the target text to obtain semantic sub-features corresponding to each stroke encoding string of the target text; and to fuse the semantic sub-features corresponding to each stroke encoding string to obtain the semantic feature information of the target text.
[0118] Optionally, in some embodiments of this application, the step "fusing the semantic sub-features corresponding to each stroke encoding string to obtain the semantic feature information of the target text" may include: Attention processing is performed on each stroke encoding string to obtain the attention weight corresponding to each stroke encoding string; Based on the attention weights, the semantic sub-features corresponding to each stroke encoding string are fused to obtain the semantic feature information of the target text.
[0119] (4) Prediction unit 304; The prediction unit 304 is used to predict the probability that the target text belongs to each preset text type based on the semantic feature information.
[0120] Optionally, in some embodiments of this application, the prediction unit may include a second acquisition subunit, a calculation subunit, and a determination subunit, as follows: The second acquisition subunit is used to acquire the reference text corresponding to each preset text type; The calculation subunit is used to calculate the similarity between the semantic feature information of the target text and the semantic feature information of the reference text corresponding to each preset text type; A subunit is defined to determine the probability that the target text belongs to each preset text type based on the similarity.
[0121] (5) Determine unit 305; The determining unit 305 is used to determine the target text type corresponding to the target text from the preset text types based on the probability.
[0122] Optionally, in some embodiments of this application, the construction unit may be specifically used to construct the semantic feature information of the target text based on the stroke representation through a text recognition model.
[0123] Optionally, in some embodiments of this application, the text recognition device may further include a training unit, which is used to train the text recognition model, as follows: The training unit is used to acquire training data, which includes sample text and the expected probability of the sample text belonging to each preset text type. For each text unit in the sample text, stroke decomposition is performed according to the writing order rules of the text units to obtain the stroke representation of the sample text. Based on the stroke representation, semantic feature information of the sample text is constructed using a preset text recognition model. Based on the semantic feature information of the sample text, the actual probability of the sample text belonging to each preset text type is predicted. The parameters of the preset text recognition model are adjusted according to the actual probability and the expected probability to obtain the text recognition model.
[0124] As can be seen from the above, this embodiment can acquire target text through acquisition unit 301, the target text including at least one text unit; for each text unit in the target text, stroke splitting unit 302 performs stroke splitting processing on the text unit according to the writing order rules of the text unit to obtain the stroke representation of the target text; based on the stroke representation, construction unit 303 constructs semantic feature information of the target text; based on the semantic feature information, prediction unit 304 predicts the probability that the target text belongs to each preset text type; and based on the probability, determination unit 305 determines the target text type corresponding to the target text from the preset text types. This embodiment can construct its semantic feature information based on the stroke representation of the target text, and then predict its text type. Through stroke representation, the structural information inside the text words can be well utilized, making the constructed semantic feature information more representative and helping to improve the accuracy of text recognition.
[0125] This application also provides an electronic device, such as... Figure 4 The diagram shows a structural schematic of an electronic device involved in an embodiment of this application. This electronic device can be a terminal or a server, specifically: The electronic device may include components such as a processor 401 with one or more processing cores, a memory 402 with one or more computer-readable storage media, a power supply 403, and an input unit 404. Those skilled in the art will understand that... Figure 4 The electronic device structure shown does not constitute a limitation on the electronic device and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Wherein: The processor 401 is the control center of the electronic device. It connects various parts of the electronic device via various interfaces and lines. By running or executing software programs and / or modules stored in the memory 402, and by calling data stored in the memory 402, it performs various functions and processes data, thereby enabling overall monitoring and control of the electronic device. Optionally, the processor 401 may include one or more processing cores; preferably, the processor 401 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 401.
[0126] The memory 402 can be used to store software programs and modules. The processor 401 executes various functional applications and data processing by running the software programs and modules stored in the memory 402. The memory 402 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, application programs required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 402 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 402 may also include a memory controller to provide the processor 401 with access to the memory 402.
[0127] The electronic device also includes a power supply 403 that supplies power to the various components. Preferably, the power supply 403 can be logically connected to the processor 401 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply 403 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0128] The electronic device may also include an input unit 404, which can be used to receive input digital or character information, and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
[0129] Although not shown, the electronic device may also include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 401 in the electronic device loads the executable files corresponding to the processes of one or more applications into the memory 402 according to the following instructions, and the processor 401 runs the applications stored in the memory 402 to realize various functions, as follows: A target text is obtained, the target text comprising at least one text unit; for each text unit in the target text, the text unit is split into strokes according to the writing order rules of the text unit to obtain the stroke representation of the target text; based on the stroke representation, semantic feature information of the target text is constructed; based on the semantic feature information, the probability of the target text belonging to each preset text type is predicted; according to the probability, the target text type corresponding to the target text is determined from the preset text types.
[0130] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0131] As can be seen from the above, this embodiment can acquire target text, which includes at least one text unit; for each text unit in the target text, according to the writing order rules of the text unit, the text unit is split into strokes to obtain the stroke representation of the target text; based on the stroke representation, semantic feature information of the target text is constructed; based on the semantic feature information, the probability of the target text belonging to each preset text type is predicted; according to the probability, the target text type corresponding to the target text is determined from the preset text types. This embodiment can construct semantic feature information of the target text based on the stroke representation, and then predict its text type. Through stroke representation, the structural information inside the text words can be well utilized, making the constructed semantic feature information more representative and improving the accuracy of text recognition.
[0132] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0133] Therefore, embodiments of this application provide a storage medium storing a plurality of instructions that can be loaded by a processor to execute steps in any of the text recognition methods provided in embodiments of this application. For example, the instructions can execute the following steps: A target text is obtained, the target text comprising at least one text unit; for each text unit in the target text, the text unit is split into strokes according to the writing order rules of the text unit to obtain the stroke representation of the target text; based on the stroke representation, semantic feature information of the target text is constructed; based on the semantic feature information, the probability of the target text belonging to each preset text type is predicted; according to the probability, the target text type corresponding to the target text is determined from the preset text types.
[0134] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0135] The storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0136] Since the instructions stored in the storage medium can execute the steps of any of the text recognition methods provided in the embodiments of this application, the beneficial effects that any of the text recognition methods provided in the embodiments of this application can achieve can be realized. For details, please refer to the previous embodiments, which will not be repeated here.
[0137] According to one aspect of this application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the methods provided in the various alternative implementations of the above-described text recognition aspect.
[0138] The foregoing has provided a detailed description of a text recognition method and apparatus provided in the embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The description of the above embodiments is only for the purpose of helping to understand the method and its core ideas. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A text recognition method, characterized in that, include: Obtain target text, wherein the target text includes at least one text unit; For each text unit in the target text, the text unit is decomposed into strokes according to the writing order rules of the text unit to obtain the stroke representation of the target text; the stroke representation includes at least one stroke. Obtain the encoding information corresponding to each stroke of the target text; Based on the encoding information, the initial stroke encoding string of the target text is constructed according to the writing order rules of each text unit in the target text; Based on a preset string length, the initial stroke code string is truncated to obtain at least one stroke code string of the target text; Feature extraction is performed on each stroke encoding string of the target text to obtain the semantic sub-features corresponding to each stroke encoding string of the target text; Attention processing is performed on each stroke encoding string to obtain the attention weight corresponding to each stroke encoding string; Based on the attention weights, the semantic sub-features corresponding to each stroke encoding string are fused to obtain the semantic feature information of the target text; Based on the semantic feature information, predict the probability that the target text belongs to each preset text type; Based on the probability, the target text type corresponding to the target text is determined from the preset text types.
2. The method according to claim 1, characterized in that, The step of performing stroke decomposition processing on the text units according to the writing order rules of the text units to obtain the stroke representation of the target text includes: The text unit is decomposed into characters to obtain at least one character component of the text unit; According to the writing order rules of the text unit, the strokes of each character component of the text unit are split to obtain the stroke representation of the target text.
3. The method according to claim 1, characterized in that, The step of predicting the probability that the target text belongs to each preset text type based on the semantic feature information includes: Get the reference text corresponding to each preset text type; Calculate the similarity between the semantic feature information of the target text and the semantic feature information of the reference text corresponding to each preset text type; Based on the similarity, the probability that the target text belongs to each preset text type is determined.
4. The method according to claim 1, characterized in that, The semantic feature information is extracted through a text recognition model.
5. The method according to claim 4, characterized in that, Also includes: Acquire training data, which includes sample text and the expected probability that the sample text belongs to each preset text type; For each text unit in the sample text, the text unit is decomposed into strokes according to the writing order rules of the text unit to obtain the stroke representation of the sample text; Based on the stroke representation, the semantic feature information of the sample text is constructed using a preset text recognition model. Based on the semantic feature information of the sample text, predict the actual probability that the sample text belongs to each preset text type; Based on the actual probability and the expected probability, the parameters of the preset text recognition model are adjusted to obtain the text recognition model.
6. A text recognition device, characterized in that, include: An acquisition unit is used to acquire target text, wherein the target text includes at least one text unit; The stroke decomposition unit is used to perform stroke decomposition processing on each text unit in the target text according to the writing order rules of the text units, so as to obtain the stroke representation of the target text; the stroke representation includes at least one stroke. A construction unit is used to obtain the encoding information corresponding to each stroke of the target text; construct an initial stroke encoding string of the target text according to the encoding information and the writing order rules of each text unit in the target text; and perform string truncation on the initial stroke encoding string based on a preset string length to obtain at least one stroke encoding string of the target text. Feature extraction is performed on each stroke-encoded string of the target text to obtain semantic sub-features corresponding to each stroke-encoded string of the target text; attention processing is performed on each stroke-encoded string to obtain attention weights corresponding to each stroke-encoded string; based on the attention weights, the semantic sub-features corresponding to each stroke-encoded string are fused to obtain the semantic feature information of the target text. The prediction unit is used to predict the probability that the target text belongs to each preset text type based on the semantic feature information; The determining unit is configured to determine the target text type corresponding to the target text from the preset text types based on the probability.
7. The apparatus according to claim 6, characterized in that, The stroke decomposition unit includes a character decomposition subunit and a stroke decomposition subunit: The character decomposition subunit is used to decompose the text unit into characters to obtain at least one character component of the text unit; The stroke splitting subunit is used to perform stroke splitting processing on each character component of the text unit according to the writing order rules of the text unit, so as to obtain the stroke representation of the target text.
8. The apparatus according to claim 6, characterized in that, The prediction unit includes a second acquisition subunit, a calculation subunit, and a determination subunit: The second acquisition subunit is used to acquire the reference text corresponding to each preset text type; The calculation subunit is used to calculate the similarity between the semantic feature information of the target text and the semantic feature information of the reference text corresponding to each preset text type; The determining subunit is used to determine the probability that the target text belongs to each preset text type based on the similarity.
9. The apparatus according to claim 6, characterized in that, The semantic feature information is extracted through a text recognition model.
10. The apparatus according to claim 9, characterized in that, The device further includes a training unit, which is used to acquire training data, including sample text and the expected probability of the sample text belonging to each preset text type; for each text unit in the sample text, the text unit is split into strokes according to the writing order rules of the text unit to obtain the stroke representation of the sample text; and the semantic feature information of the sample text is constructed based on the stroke representation through a preset text recognition model. Based on the semantic feature information of the sample text, the actual probability of the sample text belonging to each preset text type is predicted; according to the actual probability and the expected probability, the parameters of the preset text recognition model are adjusted to obtain the text recognition model.
11. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the method of any one of claims 1 to 5.
12. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1 to 5.
13. A computer program product comprising computer instructions, characterized in that, When the computer instructions are executed by the processor, they implement the method of any one of claims 1 to 5.
Citation Information
Patent Citations
Language model training method and device
CN110619120A
Text detection method and device, similarity calculation method and device, model training method and device
CN111221960A