Method and apparatus for implementing pinyin vector representation, electronic device, and storage medium

By determining the correspondence between the initial and final vowels of Chinese characters and pinyin, and using the word vector model to calculate the initial and final vectors, the problem of inefficient pinyin vector representation is solved, and a fast and efficient pinyin vector representation is achieved.

CN114398874BActive Publication Date: 2025-07-18BEIJING MININGLAMP SOFTWARE SYST CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210016023.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-07
Publication Date
2025-07-18
Estimated Expiration
2042-01-07

AI Technical Summary

Technical Problem

In the prior art, the representation of the pinyin initial consonants and final vectors in Chinese is inefficient, consumes a lot of computing power and time, and lacks effective solutions.

Method used

By determining the initial and final correspondence between Chinese characters and their pinyin, using the preset word vector model, the initial or final vector of the object to be analyzed is calculated, including splitting the pinyin and storing the correspondence, and calculating the sub-vector and average values through the word vector to obtain the target vector.

Benefits of technology

It realizes the rapid determination of Chinese pinyin initial consonants and final vectors based on word vectors, making up for the gap in initial consonants and final particle sizes of word embedding technology, and improving the efficiency of pinyin vector representation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114398874B_ABST
    Figure CN114398874B_ABST
Patent Text Reader

Abstract

This application relates to a method and apparatus for implementing pinyin vector representation, an electronic device, and a storage medium. Among them, the method includes: determining the pinyin corresponding to each of a plurality of Chinese characters, where the pinyin includes: an initial and a final, or only includes a final; determining the target vector of the object to be analyzed through the character vector of the target Chinese character corresponding to the target pinyin including the object to be analyzed, where the object to be analyzed is the initial to be analyzed or the final to be analyzed, and the target pinyin is the pinyin including the object to be analyzed among all pinyins. This application determines the target vector of the object to be analyzed through the character vector of the target Chinese character corresponding to the target pinyin including the object to be analyzed, thereby achieving the purpose of being able to determine the initial vector and final vector of Chinese pinyin initials only with the character vectors of Chinese characters, and thus making up for the blank of the word embedding technology at the granularity of initials and finals.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of natural language processing, and in particular, to a method and device for implementing pinyin vector representation, an electronic device, and a storage medium. Background Art

[0002] In recent years, the word embedding method has swept the entire field of natural language processing, and NLP research based on deep learning has become increasingly popular. In the research of the Chinese language, researchers have paid more attention to word vectors, character vectors, and discourse vectors, and less attention has been paid to the vectors of initials and finals of Chinese pinyin.

[0003] In the process of implementing the present invention, the inventors found that: at present, there is less work on researching the vectors of initials and finals of Chinese pinyin, while character vectors, word vectors, and discourse vectors have received more attention. Such research requires a large corpus and requires a relatively high computing power to obtain good vector representations, which is costly, time-consuming, and inefficient.

[0004] In view of the technical problem of low efficiency in implementing pinyin vector representation in the related art, no effective solution has been provided yet. Summary of the Invention

[0005] To solve the above technical problem of low efficiency in implementing pinyin vector representation, this application provides a method and device for implementing pinyin vector representation, an electronic device, and a storage medium.

[0006] In a first aspect, an embodiment of this application provides a method for implementing pinyin vector representation, including:

[0007] Determine the pinyin corresponding to each of the multiple Chinese characters, where the pinyin includes: initials and finals, or only includes finals;

[0008] Determine the target vector of the object to be analyzed through the character vector of the target Chinese character corresponding to the target pinyin including the object to be analyzed, where the object to be analyzed is the initial to be analyzed or the final to be analyzed, and the target pinyin is the pinyin including the object to be analyzed among all the pinyins.

[0009] Optionally, in the method as described above, the determining the pinyin corresponding to each of the multiple Chinese characters includes:

[0010] Read the target Chinese character library to obtain all the Chinese characters in the target Chinese character library and the pinyin corresponding to each Chinese character;

[0011] After obtaining the pinyin corresponding to each Chinese character, the method further includes:

[0012] Split the pinyin, determine the initials and finals included in the pinyin, and determine the corresponding relationships among the Chinese characters, the pinyin, the initials, and the finals;

[0013] Traverse each of the Chinese characters, and store the Chinese characters, the pinyin corresponding to the Chinese characters, and the initials and finals included in the pinyin according to the corresponding relationships.

[0014] Optionally, as in the foregoing method, determining the target vector of the object to be analyzed through the word vector of the target Chinese character corresponding to the target pinyin including the object to be analyzed includes:

[0015] For each of the target Chinese characters, when it is determined according to the corresponding relationship that the target pinyin corresponding to the target Chinese character includes the initial to be analyzed, determine a first target sub-vector corresponding to the initial to be analyzed and the target Chinese character according to the word vector of the target Chinese character;

[0016] Determine a first target vector of the initial to be analyzed according to all the first target sub-vectors of the initial to be analyzed;

[0017] For each of the target Chinese characters, when it is determined according to the corresponding relationship that the target pinyin corresponding to the target Chinese character includes the final to be analyzed, determine a second target sub-vector corresponding to the final to be analyzed and the target Chinese character according to the word vector of the target Chinese character;

[0018] Determine a second target vector of the final to be analyzed according to all the second target sub-vectors of the final to be analyzed.

[0019] Optionally, as in the foregoing method, for each of the target Chinese characters, when it is determined according to the corresponding relationship that the target pinyin corresponding to the target Chinese character includes the initial to be analyzed, determining a first target sub-vector corresponding to the initial to be analyzed and the target Chinese character according to the word vector of the target Chinese character includes:

[0020] According to the corresponding relationship, determine the target pinyin and the target initial corresponding to the target Chinese character;

[0021] In a preset word vector model, query the word vector of the target Chinese character;

[0022] When the target initial is the initial to be analyzed, determine the word vector of the target Chinese character as the first target sub-vector corresponding to the initial to be analyzed and the target Chinese character.

[0023] Optionally, as in the foregoing method, determining a first target vector of the initial consonant to be analyzed based on all the first target sub-vectors of the initial consonant to be analyzed includes:

[0024] Calculating the average value of all the first target sub-vectors of the initial consonant to be analyzed to obtain the first target vector.

[0025] Optionally, as in the foregoing method, for each of the target Chinese characters, when determining the target pinyin corresponding to the target Chinese character according to the corresponding relationship and the target pinyin includes the final to be analyzed, determining a second target sub-vector corresponding to the final to be analyzed and the target Chinese character based on the character vector of the target Chinese character includes:

[0026] Determining the target pinyin and the target final corresponding to the target Chinese character according to the corresponding relationship;

[0027] Querying the character vector of the target Chinese character in a preset character vector model;

[0028] When the target final is the final to be analyzed, determining the character vector of the target Chinese character as the second target sub-vector corresponding to the final to be analyzed and the target Chinese character.

[0029] Optionally, as in the foregoing method, determining a second target vector of the final to be analyzed based on all the second target sub-vectors of the final to be analyzed includes:

[0030] Calculating the average value of all the second target sub-vectors of the final to be analyzed to obtain the second target vector.

[0031] In a second aspect, an embodiment of the present application provides an apparatus for determining a Chinese pinyin vector, including:

[0032] A first determination module, configured to determine the pinyin corresponding to each of a plurality of Chinese characters, where the pinyin includes: an initial consonant and a final, or only includes a final;

[0033] A second determination module, configured to determine a target vector of the object to be analyzed through the character vector of the target Chinese character corresponding to the target pinyin including the object to be analyzed, where the object to be analyzed is an initial consonant to be analyzed or a final to be analyzed, and the target pinyin is the pinyin including the object to be analyzed among all the pinyins.

[0034] In a third aspect, an embodiment of the present application provides an electronic device, including: a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;

[0035] The memory is used to store a computer program;

[0036] The processor is used to implement the method described in any one of the foregoing items when executing the computer program.

[0037] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, where the storage medium includes a stored program, and when the program runs, it executes the method described in any one of the preceding items.

[0038] This solution can be applied to prediction and optimization in the field of marketing intelligence technology. The above technical solutions provided by the embodiments of the present application have the following advantages compared with the prior art: In the method of this embodiment, by including the word vector of the target Chinese character corresponding to the target pinyin of the object to be analyzed, the target vector of the object to be analyzed is determined, and thus the purpose of determining the initial consonant vector and the final vowel vector of the Chinese pinyin initial consonant can be achieved only by the word vector of the Chinese character, thereby making up for the blank of the word embedding technology at the granularity of the initial consonant and the final vowel. Description of the Drawings

[0039] The drawings here are incorporated into the specification and constitute a part of this specification, showing embodiments consistent with the present invention, and are used together with the specification to explain the principles of the present invention.

[0040] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, for those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.

[0041] Figure 1 It is a schematic flowchart of a method for implementing pinyin vector representation provided by an embodiment of the present application;

[0042] Figure 2 It is a schematic flowchart of a method for implementing pinyin vector representation provided by another embodiment of the present application;

[0043] Figure 3 It is a schematic flowchart of a method for implementing pinyin vector representation provided by another embodiment of the present application;

[0044] Figure 4 It is a block diagram of a device for implementing pinyin vector representation provided by another embodiment of the present application;

[0045] Figure 5 It is a schematic structural diagram of an electronic device provided by an embodiment of the present application. Detailed Embodiments

[0046] To make the objectives, technical solutions, and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Apparently, the described embodiments are some, but not all, of the embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present application without creative efforts shall fall within the scope of protection of the present application.

[0047] According to one aspect of the embodiments of the present application, a method for implementing pinyin vector representation is provided. Optionally, in this embodiment, the above method for implementing pinyin vector representation may be applied to a hardware environment composed of a terminal and a server. The server is connected to the terminal through a network and can be used to provide services (such as data processing services, data analysis services, etc.) for the terminal or a client installed on the terminal. A database may be set up on the server or independently of the server to provide data storage services for the server.

[0048] The above network may include, but is not limited to, at least one of the following: a wired network, a wireless network. The above wired network may include, but is not limited to, at least one of the following: a wide area network, a metropolitan area network, a local area network. The above wireless network may include, but is not limited to, at least one of the following: WIFI (Wireless Fidelity), Bluetooth. The terminal is not limited to a PC, a mobile phone, a tablet computer, etc.

[0049] The method for implementing pinyin vector representation in the embodiments of the present application may be executed by the server, or may be executed by the terminal, or may be jointly executed by the server and the terminal. Among them, when the terminal executes the method for implementing pinyin vector representation in the embodiments of the present application, it may also be executed by a client installed thereon.

[0050] Taking the method for implementing pinyin vector representation in this embodiment executed by the server as an example, Figure 1 A method for implementing pinyin vector representation provided for the embodiments of the present application includes the following steps:

[0051] Step S101, determine the pinyin corresponding to each of multiple Chinese characters, where the pinyin includes: an initial and a final, or only includes a final;

[0052] The method for implementing pinyin vector representation in this embodiment may be applied to a scenario where it is necessary to determine the initial vector of the initials or the final vector of the finals in Chinese pinyin, or may also be a scenario where other information of Chinese pinyin is determined for vector analysis. For other types of information, the above method for implementing pinyin vector representation is equally applicable without contradiction.

[0053] The multiple Chinese characters may be part or all of the Chinese characters in a preset character library. After the multiple Chinese characters are determined, each of the multiple Chinese characters may be determined.

[0054] After each Chinese character is determined, the pinyin corresponding to each Chinese character can be determined. For example: 国-guo;安-an, etc. When the Chinese character is 国, the pinyin includes the initial consonant g and the final vowel uo, and when the Chinese character is 安, the pinyin does not have the initial consonant, but only includes the final vowel an.

[0055] Step S102, determining a target vector of the object to be analyzed by including a character vector of a target Chinese character corresponding to a target pinyin of the object to be analyzed, wherein the object to be analyzed is an initial consonant to be analyzed or a final consonant to be analyzed, and the target pinyin is a pinyin including the object to be analyzed among all pinyins.

[0056] After determining the pinyin corresponding to each Chinese character, the target pinyin including the object to be analyzed can be determined. The target pinyin can be the pinyin of the target Chinese character including the object to be analyzed in the corresponding pinyin. For example, when the object to be analyzed is an, the target pinyin can be tian, tan, etc., and the corresponding target Chinese characters can be 天, 田, 甜, 谈, 弹, 贪, etc.

[0057] After each target Chinese character is determined, the character vector of each target Chinese character can be determined through a preset Chinese character vector model.

[0058] After determining the word vector of the target Chinese character, the target vector of the object to be analyzed can be determined based on each word vector. In the word vector, each Chinese character is represented by an N-dimensional vector. Therefore, each target vector can also be represented by an N-dimensional vector. For example, the weight of each word vector in all word vectors corresponding to the object to be analyzed can be determined first, and then all word vectors can be weighted according to the weight to obtain the target weight.

[0059] The method in this embodiment determines the target vector of the object to be analyzed by including the word vector of the target Chinese character corresponding to the target pinyin of the object to be analyzed, thereby achieving the purpose of determining the initial consonant vector and the final consonant vector of the Chinese pinyin initial consonant only by the word vector of the Chinese character, thereby filling the gap in the granularity of initial consonants and final consonants in word embedding technology.

[0060] As an optional implementation, as in the above method, the step S101 of determining the pinyin corresponding to each of the multiple Chinese characters includes the following steps:

[0061] The target Chinese character library is read to obtain all Chinese characters in the target Chinese character library and the pinyin corresponding to each Chinese character.

[0062] The multiple Chinese characters can be all the Chinese characters in the target Chinese character library. Optionally, the target Chinese character library can be a Chinese dictionary.

[0063] After determining the target Chinese character library, all the Chinese characters in it can be read. Generally, when the target Chinese character library is a Chinese dictionary, each Chinese character is marked with its corresponding pinyin. Therefore, the pinyin corresponding to each Chinese character can be obtained.

[0064] For example, read the Chinese dictionary and store the Chinese characters in the Chinese dictionary and their pinyins in the form of map_HZ_PY <Chinese character, pinyin>.

[0065] After obtaining the pinyin corresponding to each Chinese character in the step S101, the method further includes the following steps:

[0066] Step S201: Split the pinyin to determine the initials and finals included in the pinyin, and determine the corresponding relationships among the Chinese character, pinyin, initials, and finals.

[0067] Optionally, the target files of the initials and finals of Chinese pinyin can be obtained in advance. That is, read the initials and finals of Chinese pinyin from the target files and store them. Optionally, the initials can be stored in the initials data table list_SM <initials>, and the finals can be stored in the finals data table list_YM <finals>.

[0068] After determining the pinyin, the initials in the pinyin can be determined by matching according to the characters corresponding to each initial in the above initials data table. When no corresponding initial is matched in the pinyin by the characters corresponding to each initial in the initials data table, it is determined that the pinyin does not include an initial, and the initial can be a null value. After determining the initials, the characters not matched in the pinyin can be directly determined as the finals, or the finals in the pinyin can be determined by matching according to the characters corresponding to each final in the above finals data table.

[0069] Step S202: Traverse each Chinese character and store the Chinese character, the pinyin corresponding to the Chinese character, and the initials and finals included in the pinyin according to the corresponding relationships.

[0070] After determining the pinyin, initials, and finals corresponding to each Chinese character, the Chinese character pinyin, initials, and finals can be stored according to the corresponding relationships.

[0071] For example, combining the initials and finals of Chinese pinyin obtained in the previous steps, and the Chinese characters and their pinyins obtained in the previous steps, split the pinyin into initials and finals, and store them in a corresponding manner in the form of map_HZ_PY_SYM <Chinese character, pinyin, initials, finals>.

[0072] Through the method in this embodiment, the corresponding relationships among Chinese characters, pinyin, initials, and finals can be determined. Furthermore, it is convenient to determine the corresponding relationships between initials and finals and Chinese characters respectively in the later stage, so as to determine the vectors of initials and finals according to the word vectors of Chinese characters.

[0073] As an alternative implementation, in the method as described above, the step S102 of determining the target vector of the object to be analyzed by including the word vector of the target Chinese character corresponding to the target pinyin of the object to be analyzed includes the following steps:

[0074] Step S301, for each target Chinese character, when it is determined according to the corresponding relationship that the target pinyin corresponding to the target Chinese character includes the initial to be analyzed, determine the first target sub-vector corresponding to the initial to be analyzed and the target Chinese character according to the word vector of the target Chinese character.

[0075] Step S302, determine the first target vector of the initial to be analyzed according to all the first target sub-vectors of the initial to be analyzed.

[0076] For each target Chinese character among all the target Chinese characters, the target pinyin corresponding to the target Chinese character and the target finals in the target pinyin, or the target initial and target finals, can be determined according to the corresponding relationship as described above.

[0077] Then it can be judged whether the target pinyin includes the initial to be analyzed. When the target pinyin includes the initial to be analyzed, the first target sub-vector corresponding to the initial to be analyzed can be determined according to the word vector of the target Chinese character.

[0078] The first target sub-vector can be the vector corresponding to the initial to be analyzed and any target Chinese character. Further, when the target Chinese character does not include the initial to be analyzed, the first target sub-vector can be 0.

[0079] After determining all the first target sub-vectors corresponding to the initial to be analyzed, the first target vector of the initial to be analyzed can be obtained according to all the first target sub-vectors.

[0080] Step S303, for each target Chinese character, when it is determined according to the corresponding relationship that the target pinyin corresponding to the target Chinese character includes the final to be analyzed, determine the second target sub-vector corresponding to the final to be analyzed and the target Chinese character according to the word vector of the target Chinese character;

[0081] Step S304, determine the second target vector of the final to be analyzed according to all the second target sub-vectors of the final to be analyzed.

[0082] For each target Chinese character among all the target Chinese characters, the target pinyin corresponding to the target Chinese character and the target finals in the target pinyin, or the target initial and target finals, can be determined according to the corresponding relationship as described above.

[0083] Then, it can be determined whether the target pinyin includes the rhyme to be analyzed. When the rhyme to be analyzed is included, the second target sub-vector of the rhyme to be analyzed can be determined according to the character vector of the target Chinese character.

[0084] The second target sub-vector can be the vector corresponding to the rhyme to be analyzed and any target Chinese character. Further, when the target Chinese character does not include the rhyme to be analyzed, the second target sub-vector can be 0.

[0085] After determining all the second target sub-vectors corresponding to the rhyme to be analyzed, the second target vector of the rhyme to be analyzed can be obtained according to all the second target sub-vectors.

[0086] Such as Figure 2 shown, as an optional implementation manner, for each target Chinese character in the method as described above, when it is determined according to the corresponding relationship that the target pinyin includes the initial to be analyzed, the first target sub-vector corresponding to the initial to be analyzed and the target Chinese character is determined according to the character vector of the target Chinese character, including the following steps:

[0087] Step S401, determine the target pinyin and the target initial corresponding to the target Chinese character according to the corresponding relationship;

[0088] Step S402, query the character vector of the target Chinese character in the preset character vector model;

[0089] Step S403, when the target initial is the initial to be analyzed, determine the character vector of the target Chinese character as the first target sub-vector corresponding to the initial to be analyzed and the target Chinese character.

[0090] After storing the Chinese characters, pinyins, initials, and rhymes in correspondence according to the Chinese characters, after determining the target Chinese character, the target pinyin, the target initial, and the target rhyme corresponding to the target Chinese character can be determined.

[0091] Optionally, a publicly available Chinese character vector model can be obtained in advance. That is, obtain a trained Chinese character vector model (which needs to include all Chinese characters and ensure the accuracy of the data). In the Chinese character vector model, each Chinese character is represented by an N-dimensional vector, with a total of M Chinese characters. Among them, N is an integer greater than 1, and M is an integer greater than 1.

[0092] Read the Chinese character vector model obtained in the previous steps, and store the Chinese characters in the form of list_HZ<Chinese character>, and store its corresponding character vector in matrix form matrix_HZ_Vector[M×N].

[0093] In the case of having a preset character vector model, it is possible to query according to the target Chinese character in the character vector model. When a candidate Chinese character corresponding to the target Chinese character is found, the character vector of the candidate Chinese character can be used as the character vector of the target Chinese character.

[0094] For example, find hz_1 (i.e., the target Chinese character) from list_HZ and align it to matrix_HZ_Vector, and extract the character vector of hz_1, hz_Vector_1 (i.e., the character vector of the target Chinese character).

[0095] In the case where the target initial is the initial to be analyzed, the character vector of the target Chinese character is determined as the first target sub-vector corresponding to the initial to be analyzed and the target Chinese character.

[0096] Through the method in this embodiment, it is possible to quickly determine the character vectors corresponding to each Chinese character and the initials.

[0097] As an alternative implementation, as described in the foregoing method, step S302 determines the first target vector of the initial to be analyzed according to all the first target sub-vectors of the initial to be analyzed, including the following steps:

[0098] Step S501, calculate the average value of all the first target sub-vectors of the initial to be analyzed to obtain the first target vector.

[0099] Since only when the target pinyin includes the initial to be analyzed can the first target sub-vector corresponding to the initial to be analyzed and the target Chinese character be determined according to the character vector of the target Chinese character. Therefore, all target Chinese characters whose pinyin contains the initial to be analyzed can be determined among all Chinese characters, and then all the first target sub-vectors corresponding to the initial to be analyzed can be determined according to the first target sub-vectors corresponding to the initial to be analyzed and each target Chinese character respectively.

[0100] Optionally, after determining all the first target sub-vectors of the initial to be analyzed, the average value of all the first target sub-vectors can be calculated to obtain the first target vector.

[0101] As Figure 3 shown, as an alternative implementation, as described in the foregoing method, step S303 for each target Chinese character, in the case where it is determined according to the corresponding relationship that the target pinyin includes the final to be analyzed, determines the second target sub-vector corresponding to the final to be analyzed and the target Chinese character according to the character vector of the target Chinese character, including the following steps:

[0102] Step S601, according to the corresponding relationship, determine the target pinyin and the target final corresponding to the target Chinese character;

[0103] Step S602, in the preset character vector model, query the character vector of the target Chinese character;

[0104] Step S603, when the target final is the final to be analyzed, determine the character vector of the target Chinese character as the second target sub-vector.

[0105] After storing Chinese characters, pinyins, finals, and the corresponding finals according to Chinese characters, after determining the target Chinese character, the target pinyin, target final, and target final corresponding to the target Chinese character can be determined.

[0106] Optionally, a publicly available Chinese character vector model can be obtained in advance. That is, obtain a trained Chinese character vector model (which needs to contain all Chinese characters and ensure the accuracy of the data). In the Chinese character vector model, each Chinese character is represented by an N-dimensional vector, with a total of M Chinese characters. Wherein, N is an integer greater than 1, and M is an integer greater than 1.

[0107] Read the Chinese character vector model obtained in the previous step, and store the Chinese characters in the form of list_HZ<Chinese character>, and store its corresponding character vector in matrix form matrix_HZ_Vector[M×N].

[0108] In the case of having a pre-set character vector model, the target Chinese character can be queried in the character vector model. When the candidate Chinese character corresponding to the target Chinese character is found, the character vector of the candidate Chinese character can be used as the character vector of the target Chinese character;

[0109] For example, find hz_1 (i.e., the target Chinese character) from list_HZ and align it to matrix_HZ_Vector, and take out the character vector of hz_1, hz_Vector_1 (i.e., the character vector of the target Chinese character).

[0110] When the target final is the final to be analyzed, determine the character vector of the target Chinese character as the second target sub-vector corresponding to the final to be analyzed and the target Chinese character.

[0111] Through the method in this embodiment, the character vector corresponding to each Chinese character and the final can be quickly determined.

[0112] As an optional implementation manner, as in the foregoing method, according to all the second target sub-vectors of the final to be analyzed, determine the second target vector of the final to be analyzed, including the following steps:

[0113] Step S701, calculate the average value of all the second target sub-vectors of the final to be analyzed to obtain the second target vector.

[0114] Since only when the target pinyin includes the initial or final sound to be analyzed can the second target sub-vector corresponding to the initial or final sound to be analyzed and the target Chinese character be determined according to the character vector of the target Chinese character. Therefore, all target Chinese characters whose pinyin contains the initial or final sound to be analyzed can be determined among all Chinese characters, and then all second target sub-vectors corresponding to the initial or final sound to be analyzed can be determined according to the second target sub-vectors corresponding to the initial or final sound to be analyzed and each target Chinese character respectively.

[0115] Optionally, after all second target sub-vectors of the initial or final sound to be analyzed are determined, the average value of all second target sub-vectors can be calculated to obtain the second target vector.

[0116] As described below, an application example of any of the foregoing embodiments is provided:

[0117] This patent provides a method for calculating the initial and final sound vectors of Chinese pinyin based on a Chinese character vector model, which can calculate the initial sound vector and final sound vector of Chinese pinyin based on a pre-trained character vector.

[0118] This patent provides a solution for a method for calculating the initial and final sound vectors of Chinese pinyin based on a Chinese character vector model:

[0119] A method for calculating the initial and final sound vectors of Chinese pinyin based on a Chinese character vector model includes the following steps:

[0120] A1: Obtain a Chinese pinyin initial and final sound file. That is, read the initial sounds and final sounds of Chinese pinyin from the file and store them: the initial sounds are stored in the initial sound table list_SM<initial sound>, and the final sounds are stored in the final sound table list_YM<final sound>.

[0121] A2: Read a Chinese dictionary and store the Chinese characters and their pinyins in the Chinese dictionary in the form of map_HZ_PY<Chinese character, pinyin>.

[0122] A3: Combine the initial sounds and final sounds of Chinese pinyin obtained in step A1, and the Chinese characters and their pinyins obtained in step A2, split the Chinese character pinyin into initial sounds and final sounds, and store them in the form of map_HZ_PY_SYM<Chinese character, pinyin, initial sound, final sound>.

[0123] A4: Obtain a publicly available Chinese character vector model. That is, obtain a pre-trained Chinese character vector model from a public channel (which needs to contain all Chinese characters and the source is authoritative). In the character vector model, each Chinese character is represented by an N-dimensional vector, and there are a total of M Chinese characters.

[0124] A5: Read the Chinese character vector model obtained in step A4, and store the Chinese characters in the form of list_HZ<Chinese character>, and its corresponding character vector is stored in matrix form matrix_HZ_Vector[M×N].

[0125] A6: Traverse the 1st Chinese character to the Mth Chinese character in map_HZ_PY_SYM in the following steps until the calculation of the sub-vectors of the initial consonants and final vowels, or only the final vowels, of all Chinese characters is completed, and finally calculate the initial consonant vectors of each initial consonant and the final vowel vectors of each final vowel of the Chinese pinyin:

[0126] A6.1: Traverse the Chinese characters in map_HZ_PY_SYM, and take out the first Chinese character hz_1 and its pinyin py_1, initial consonant sm_1, and final vowel ym_1;

[0127] A6.2: Find hz_1 from list_HZ and align it to matrix_HZ_Vector, and take out the character vector of the Chinese character hz_1, hz_Vector_1;

[0128] A6.3: The calculation method of the vector of the initial consonant sm_1 is as follows:

[0129] sm_Vector(sm_1) = (sm_Vector(sm_1) + hz_Vector_1) / ((num(sm_1) + 1);

[0130] Wherein, if py_1 contains an initial consonant, then num(sm_1) = 1, and the occurrence times cs(sm_1) of the initial consonant sm_1 is counted + 1; if py_1 does not contain an initial consonant, directly skip step S6.3;

[0131] A6.4: The calculation method of the vector of the final vowel ym_1 is as follows:

[0132] ym_Vector(sm_1) = (ym_Vector(ym_1) + hz_Vector_1) / ((num(ym_1) + 1);

[0133] And count the occurrence times cs(ym_1) of the final vowel ym_1 + 1;

[0134] A7: Repeat the above step A6 count times. count takes any integer greater than 1000. The larger the count, the more convergent the vectors of the initial consonants or final vowels are, that is, the values in sm_Vector will become more and more stable as the number of count increases during the iteration process.

[0135] For example, taking the case where the initial consonants only include list_SM={g, j, l, p, w, zhong}, the finals only include list_SM={an, ai, ei, ing, ong, uo}, the characters only include {安,干,国,净,来,平,未,中}, map_HZ_PY_SYM={<安, an, “空”, an>, <干, gan, g, an>, <国, guo, g, uo>, <净, jing, j, ing>, <来, lai, l, ai>, <平, ping, ping, an>, <未, wei, w, ei>, <中, zhong, zh, ong>} as an example, an implementation use case is used to demonstrate the process of step A6.

[0136] (1) Traversal: <安, an,空,an>

[0137] ym_Vector(an)=hz_Vector_An / 1, count(an)=1;

[0138] Traverse <干, gan, g, an>;

[0139] sm_Vector(g)=hz_Vector_stem / (1+1), count(g)=1;

[0140] ym_Vector(an)+=hz_Vector_stem / (1+1), count(an)=2;

[0141] Traverse <国, guo, g, uo>;

[0142] sm_Vector(g)=hz_Vector_国 / (1+1), count(g)=2;

[0143] ym_Vector(uo)+=hz_Vector_国 / (1+1), count(uo)=1;

[0144] Traverse <jing, jing, j, ing>;

[0145] sm_Vector(j)=hz_Vector_net / (1+1), count(j)=1;

[0146] ym_Vector(ing)+=hz_Vector_net / (1+1), count(ing)=1;….

[0147] like Figure 4 As shown, according to an embodiment of another aspect of the present application, a device for determining a Chinese phonetic vector is also provided, comprising:

[0148] The first determination module 1 is configured to determine the pinyin corresponding to each of the multiple Chinese characters, where the pinyin includes: an initial consonant and a final, or only includes a final.

[0149] The second determination module 2 is configured to determine the target vector of the object to be analyzed by including the character vector of the target Chinese character corresponding to the target pinyin of the object to be analyzed, where the object to be analyzed is the initial consonant to be analyzed or the final to be analyzed.

[0150] Specifically, for the specific process of each module in the device according to the embodiments of the present invention to implement its functions, reference may be made to the relevant descriptions in the method embodiments, which will not be elaborated here.

[0151] According to another embodiment of the present application, an electronic device is further provided, including: as Figure 5 shown, the electronic device may include: a processor 1501, a communication interface 1502, a memory 1503, and a communication bus 1504. Among them, the processor 1501, the communication interface 1502, and the memory 1503 communicate with each other through the communication bus 1504.

[0152] The memory 1503 is used to store a computer program;

[0153] The processor 1501 is configured to implement the steps of the above method embodiments when executing the program stored on the memory 1503.

[0154] The bus mentioned in the above electronic device may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This bus may be divided into an address bus, a data bus, a control bus, etc. For the sake of representation, only a thick line is shown in the figure, but it does not mean that there is only one bus or one type of bus.

[0155] The communication interface is used for communication between the above electronic device and other devices.

[0156] The memory may include a Random Access Memory (RAM), and may also include a Non-Volatile Memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located far from the aforementioned processor.

[0157] The above-mentioned processor may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0158] The embodiments of the present application also provide a computer-readable storage medium. The storage medium includes a stored program, wherein when the program runs, it executes the method steps of the above-mentioned method embodiments.

[0159] It should be noted that in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variation thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising one..." does not exclude the presence of additional identical elements in the process, method, article or device comprising the element.

[0160] The above are only specific embodiments of the present invention, enabling those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be obvious to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to these embodiments shown herein, but rather to the broadest scope consistent with the principles and novel features claimed herein.

Claims

1. A method for implementing pinyin vector representation, characterized in that, Including: Determining the pinyin corresponding to each of the multiple Chinese characters, including: reading a target Chinese character library to obtain all the Chinese characters in the target Chinese character library and the pinyin corresponding to each Chinese character, where the pinyin includes: an initial consonant and a final sound, or only includes a final sound; Splitting the pinyin to determine the initial consonant and final sound included in the pinyin, and determining the corresponding relationship among the Chinese character, the pinyin, the initial consonant, and the final sound; Traversing each Chinese character and storing the Chinese character, the pinyin corresponding to the Chinese character, and the initial consonant and final sound included in the pinyin according to the corresponding relationship; Determining a target vector of the object to be analyzed through the word vector of the target Chinese character corresponding to the target pinyin including the object to be analyzed, including: for each target Chinese character, when it is determined according to the corresponding relationship that the target pinyin corresponding to the target Chinese character includes the initial consonant to be analyzed, determining a first target sub-vector corresponding to the initial consonant to be analyzed and the target Chinese character according to the word vector of the target Chinese character; determining a first target vector of the initial consonant to be analyzed according to all the first target sub-vectors of the initial consonant to be analyzed; for each target Chinese character, when it is determined according to the corresponding relationship that the target pinyin corresponding to the target Chinese character includes the final sound to be analyzed, determining a second target sub-vector corresponding to the final sound to be analyzed and the target Chinese character according to the word vector of the target Chinese character; determining a second target vector of the final sound to be analyzed according to all the second target sub-vectors of the final sound to be analyzed; where the object to be analyzed is an initial consonant to be analyzed or a final sound to be analyzed, and the target pinyin is the pinyin including the object to be analyzed among all the pinyins.

2. The method according to claim 1, characterized in that, For each target Chinese character, when it is determined according to the corresponding relationship that the target pinyin corresponding to the target Chinese character includes the initial consonant to be analyzed, determining a first target sub-vector corresponding to the initial consonant to be analyzed and the target Chinese character according to the word vector of the target Chinese character, includes: Determining the target pinyin and the target initial consonant corresponding to the target Chinese character according to the corresponding relationship; Querying the word vector of the target Chinese character in a preset word vector model; When the target initial consonant is the initial consonant to be analyzed, determining the word vector of the target Chinese character as the first target sub-vector corresponding to the initial consonant to be analyzed and the target Chinese character.

3. The method according to claim 1, wherein Determining a first target vector of the initial consonant to be analyzed according to all the first target sub-vectors of the initial consonant to be analyzed, includes: Calculating the average value of all the first target sub-vectors of the initial consonant to be analyzed to obtain the first target vector.

4. The method according to claim 1, characterized in that, For each target Chinese character, when it is determined according to the corresponding relationship that the target pinyin corresponding to the target Chinese character includes the final sound to be analyzed, determining a second target sub-vector corresponding to the final sound to be analyzed and the target Chinese character according to the word vector of the target Chinese character, includes: Determine the target pinyin and target finals corresponding to the target Chinese character according to the corresponding relationship; In a preset Chinese character vector model, query the Chinese character vector of the target Chinese character; When the target finals are the to-be-analyzed finals, determine the Chinese character vector of the target Chinese character as the second target sub-vector corresponding to the to-be-analyzed finals and the target Chinese character.

5. The method according to claim 1 or 4, characterized in that, The determining the second target vector of the to-be-analyzed finals according to all the second target sub-vectors of the to-be-analyzed finals includes: Perform an average value calculation on all the second target sub-vectors of the to-be-analyzed finals to obtain the second target vector.

6. An apparatus for implementing pinyin vector representation, characterized in that, Include: A first determination module, configured to determine the pinyin corresponding to each Chinese character in a plurality of Chinese characters, including: reading a target Chinese character library to obtain all the Chinese characters in the target Chinese character library and the pinyin corresponding to each Chinese character, where the pinyin includes: an initial consonant and a final, or only includes a final; Further include a module, configured to split the pinyin, determine the initial consonant and final included in the pinyin, and determine the corresponding relationship between the Chinese character, the pinyin, the initial consonant and the final; traverse each Chinese character, and store the Chinese character, the pinyin corresponding to the Chinese character, and the initial consonant and final included in the pinyin according to the corresponding relationship; A second determination module, configured to determine the target vector of the to-be-analyzed object by using the Chinese character vector corresponding to the target pinyin including the to-be-analyzed object, including: for each target Chinese character, when it is determined according to the corresponding relationship that the target pinyin corresponding to the target Chinese character includes the to-be-analyzed initial consonant, determine the first target sub-vector corresponding to the to-be-analyzed initial consonant and the target Chinese character according to the Chinese character vector of the target Chinese character; determine the first target vector of the to-be-analyzed initial consonant according to all the first target sub-vectors of the to-be-analyzed initial consonant; for each target Chinese character, when it is determined according to the corresponding relationship that the target pinyin corresponding to the target Chinese character includes the to-be-analyzed final, determine the second target sub-vector corresponding to the to-be-analyzed final and the target Chinese character according to the Chinese character vector of the target Chinese character; determine the second target vector of the to-be-analyzed final according to all the second target sub-vectors of the to-be-analyzed final; where the to-be-analyzed object is the to-be-analyzed initial consonant or the to-be-analyzed final, and the target pinyin is the pinyin including the to-be-analyzed object among all the pinyins.

7. An electronic device, characterized in that, Include: A processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus; The memory is used for storing a computer program; The processor is configured to implement the method according to any one of claims 1 to 5 when executing the computer program.

8. A computer-readable storage medium, characterized in that, The storage medium includes a stored program, where the program executes the method according to any one of claims 1 to 5 when running.

Citation Information

Patent Citations

  • Text processing method and device, and electronic equipment

    CN110189744A

  • Letter vector calculation method and system, storage medium and electronic equipment

    CN113743053A