Method, device and storage medium for calculating Chinese phonetic letter vector
By calculating the word vector and inverted index of Chinese words in the Chinese vocabulary and calculating the letter vector of each letter, the problem of not considering the granularity of Chinese pinyin letters in the existing technology is solved, and the embedding of Chinese pinyin letters is realized, and the representation ability of natural language processing is enhanced.
Patent Information
- Application Number
- CN202111308344.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-05
- Publication Date
- 2025-06-06
- Estimated Expiration
- 2041-11-05
AI Technical Summary
In the prior art, word embedding vectors do not consider the granularity of Chinese pinyin letters, and fail to effectively study Chinese pinyin embedding and Chinese pinyin letter embedding.
By reading the Chinese words in the Chinese vocabulary and their corresponding Chinese pinyin, converting them into word vectors, and obtaining the inverted index, and calculating the letter vector of each letter based on the inverted index and word vector.
The Chinese Pinyin letter embedding is realized, and the problem of word embedding vectors not taking into account the granularity of Chinese Pinyin letters is solved, and the Chinese Pinyin representation ability in natural language processing is enhanced.
Smart Images

Figure CN114048281B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computers, and in particular to a method, device and storage medium for calculating a Chinese phonetic letter vector. Background Art
[0002] From a grammatical perspective, Chinese includes Chinese words and Chinese characters. There are many works in the prior art that study Chinese word embedding and Chinese character embedding using word embedding models, but there is little research on Chinese pinyin embedding and Chinese pinyin letter embedding from the perspective of Chinese pinyin letter granularity. Summary of the invention
[0003] The embodiments of the present invention provide a method, device and storage medium for calculating Chinese phonetic letter vectors, so as to at least solve the technical problem that the word embedding vector does not consider the granularity of Chinese phonetic letters.
[0004] According to one aspect of an embodiment of the present invention, a method for calculating a Chinese pinyin letter vector is provided, comprising: reading all Chinese words and their corresponding Chinese pinyin in a Chinese vocabulary; converting the above Chinese words into word vectors of the Chinese words; obtaining an inverted index of all Chinese words in the above Chinese vocabulary, wherein the above inverted index comprises a plurality of first letters and a first word of each of the above first letters, the above first letter being a letter included in the above Chinese pinyin of the above Chinese word, and the above first word being a word including the above first letter; and calculating the letter vector of the above first letter according to the above inverted index and the word vector of the above Chinese word.
[0005] According to another aspect of an embodiment of the present invention, a device for calculating a Chinese pinyin letter vector is provided, comprising: a reading module for reading all Chinese words and their corresponding Chinese pinyin in a Chinese vocabulary; a conversion module for converting the above Chinese words into word vectors of the Chinese words; an acquisition module for acquiring an inverted index of all Chinese words in the above Chinese vocabulary, wherein the above inverted index comprises a plurality of first letters and a first word of each of the above first letters, the above first letter being a letter included in the above Chinese pinyin of the above Chinese word, and the above first word being a word including the above first letter; and a calculation module for calculating the letter vector of the above first letter based on the above inverted index and the word vector of the above Chinese word.
[0006] As an optional example, the calculation module includes: a second determination unit, used to determine each of the first letters as the current letter, and perform the following operations on the current letter: calculate the first vector of the current letter in each of the first words of the current letter; sum the first vectors to obtain a target vector; and divide the target vector by the number of the first words of the current letter to obtain the letter vector of the current letter.
[0007] As an optional example, the second determination unit is also used to: determine each of the first words as a current word, and perform the following operations on the current word: count the number of times the current letter appears in the pinyin letters of the current word to obtain a first target number of times; calculate the product of the word vector of the current word of the current letter and the first target number of times to obtain a target word vector; divide the target word vector by the number of all letters contained in the pinyin letters of the current word to obtain a first vector of the current letter in the current word.
[0008] As an optional example, the reading module includes: an acquisition unit, used to acquire the Chinese words and the Chinese pinyin of the Chinese words for all the Chinese words in the Chinese vocabulary, starting from the first Chinese word; a first processing unit, used to combine the read Chinese words and the Chinese pinyin of the Chinese words into a word-pinyin pair; and a second processing unit, used to traverse the Chinese vocabulary until the word-pinyin pairs of all the Chinese words are obtained.
[0009] As an optional example, the conversion module includes: an input unit, used to input the Chinese word into a word vector conversion model, wherein the word vector conversion model is a pre-trained model for converting words into word vectors; an output unit, used to use the output result of the word vector conversion model as the word vector of the Chinese word.
[0010] According to another aspect of the embodiments of the present invention, a storage medium is provided, in which a computer program is stored, wherein the computer program executes the above-mentioned Chinese phonetic letter vector calculation device when executed by a processor.
[0011] According to another aspect of an embodiment of the present invention, there is also provided an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the above-mentioned Chinese phonetic letter vector calculation device through the above-mentioned computer program.
[0012] The method for calculating the above-mentioned Chinese pinyin letter vector of the present application can be used for natural language processing of deep learning technology. In an embodiment of the present invention, by converting the above-mentioned Chinese words into word vectors of Chinese words; obtaining the inverted index of all Chinese words in the above-mentioned Chinese vocabulary; and calculating the letter vector of the above-mentioned first letter according to the above-mentioned inverted index and the word vector of the above-mentioned Chinese word, the letter vector of each letter can be calculated through the word vector after obtaining the word vector, thereby achieving the purpose of Chinese pinyin letter embedding, and further solving the technical problem that the word embedding vector does not consider the granularity of Chinese pinyin letters. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0014] Figure 1 is a flow chart of an optional method for calculating a Chinese phonetic letter vector according to an embodiment of the present invention;
[0015] Figure 2 is a flow chart of an acquisition module of an optional method for calculating a Chinese phonetic letter vector according to an embodiment of the present invention;
[0016] Figure 3 is a flow chart of a calculation module of an optional method for calculating a Chinese phonetic letter vector according to an embodiment of the present invention;
[0017] Figure 4 is a schematic structural diagram of an optional Chinese phonetic letter vector calculation device according to an embodiment of the present invention;
[0018] Figure 5 is a schematic diagram of an optional electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0019] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0020] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, device, system, product or equipment that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, devices, products or equipment.
[0021] According to a first aspect of an embodiment of the present invention, a method for calculating a Chinese phonetic letter vector is provided. Optionally, as follows: Figure 1As shown, the above method includes:
[0022] S102, reading all Chinese words and their corresponding Chinese pinyin in the Chinese word library;
[0023] S104, converting the Chinese words into word vectors of the Chinese words;
[0024] S106, obtaining an inverted index of all Chinese words in the Chinese word library, wherein the inverted index includes a plurality of first letters and a first word of each first letter, the first letter is a letter included in the Chinese pinyin of the Chinese word, and the first word is a word including the first letter;
[0025] S108, calculating the letter vector of the first letter according to the inverted index and the word vector of the Chinese word.
[0026] Optionally, in this embodiment, the Chinese word library can be one of the Chinese corpora, including all Chinese words and their corresponding Chinese pinyin. The Chinese words are converted into word vectors of Chinese words using a word vector algorithm, and the word vector algorithm includes but is not limited to methods such as word2vec, glove, ELMo and BERT. The first letter can be the letters involved in all Chinese pinyin, and each first letter corresponds to indexing one to multiple Chinese pinyins and Chinese words in which the first letter participates. The sub-vector of each first letter is calculated based on the word vectors of all Chinese words in which the first letter participates and the inverted index results of the first letter.
[0027] In the above method, the purpose of embedding Chinese phonetic letters is achieved by converting word vectors into phonetic letter vectors, thereby solving the technical problem that the word embedding vector does not consider the granularity of Chinese phonetic letters.
[0028] As an alternative example, Figure 2 As shown, obtaining the inverted index of all Chinese words in the Chinese vocabulary includes:
[0029] S202, reading all letters included in the Chinese pinyin of all Chinese words;
[0030] S204, determining all the read letters as the first letter;
[0031] S206, searching for the first word pinyin formed by each first letter of all Chinese words and the first word corresponding to the first word pinyin, and obtaining a target search result for each first letter;
[0032] S208, associating each first letter with its corresponding target search result to obtain an inverted index of all Chinese words in the Chinese vocabulary.
[0033] Optionally, in this embodiment, the inverted index result can be the first pinyin and the first word corresponding to each first letter. For example, the word library includes 3 words (yesterday, today, tomorrow, future), and the corresponding Chinese pinyin is (zuotian, jintian, mingtian, weilai). The results of all the first letters read are (a, e, g, i, j, l, m, n, o, t, u, w, z), and the inverted index result corresponding to the first letter a is a: yesterday (zuotian), today (jintian), tomorrow (mingtian), future (weilai); the inverted index result corresponding to the first letter e is e: future (weilai), and so on, all first letters are inverted indexed.
[0034] As an alternative example, Figure 3 As shown, the letter vector of the first letter is calculated based on the inverted index and the word vector of the Chinese word, including:
[0035] S302, determining each first letter as the current letter, and performing the following operations on the current letter:
[0036] Calculate the first vector of the current letter in each first word of the current letter;
[0037] Sum the first vector to obtain the target vector;
[0038] Divide the target vector by the number of the first word of the current letter to obtain the letter vector of the current letter.
[0039] Optionally, in this embodiment, each current letter has a first vector in the corresponding first word and the first vectors in all words are summed. For example, the first vector of the current letter a in the first word yesterday is Vyesterday, the first vector of the first word today is Vtoday, the first vector of the first word tomorrow is Vtomorrow, and the first vector of the first word in the future is Vfuture. The sum is Vyesterday + Vtoday + Vtomorrow + Vfuture to obtain the target vector. The number of first words of the current letter is the number of first words corresponding to the current letter in the inverted index result. The number of first words of the current letter a is 4. Dividing the target vector Vyesterday + Vtoday + Vtomorrow + Vfuture by the first number 4, the letter vector of the current letter is (Vyesterday + Vtoday + Vtomorrow + Vfuture) / 4.
[0040] As an optional example, calculating the first vector of the current letter in each first word of the current letter includes:
[0041] Determine each first word as the current word, and perform the following operations on the current word:
[0042] Count the number of times the current letter appears in the pinyin letters of the current word to obtain a first target number;
[0043] Calculate the product of the word vector of the current word of the current letter and the first target number to obtain the target word vector;
[0044] Compare the target word vector with the number of all letters contained in the pinyin letters of the current word to obtain the first vector of the current letter in the current word.
[0045] Optionally, in this embodiment, the first target number is the number of times the current letter appears in the Chinese pinyin corresponding to the current word. For example, if the current letter is a, the current word is yesterday, and the corresponding Chinese pinyin is (zuotian), the number of times the first letter a appears is 1, that is, the first target number is 1. Each first word corresponds to a word vector. For example, the word vector of the current word yesterday is vyesterday, and the product of the word vector vyesterday and the first target number of 1 is used as the target word vector. The number of all letters contained in the pinyin letters (zuotian) of the current word yesterday is 7. Finally, the target word vector vyesterday*1 is divided by the number 7, and the result is the first vector Vyesterday of the current letter in the current word = vyesterday*1 / 7.
[0046] As an optional example, reading all Chinese words and their corresponding Chinese pinyin in the Chinese word library includes:
[0047] For all Chinese words in the Chinese word library, starting from the first Chinese word, obtain the Chinese words and the Chinese pinyin of the Chinese words;
[0048] Combining the read Chinese words and the Chinese pinyin of the Chinese words into a word-pinyin pair;
[0049] Traverse the Chinese word library until all the word-pinyin pairs of Chinese words are obtained.
[0050] Optionally, in this embodiment, the word-pinyin pair of the Chinese word can be yesterday-zuotian, today-jintian, and the word-pinyin pairs of all Chinese words in the Chinese vocabulary are obtained and stored.
[0051] As an optional example, converting Chinese words into word vectors of Chinese words includes:
[0052] Inputting Chinese words into a word vector conversion model, wherein the word vector conversion model is a pre-trained model for converting words into word vectors;
[0053] The output results of the word vector conversion model are used as the word vectors of Chinese words.
[0054] Optionally, in this embodiment, the word vector conversion model includes embedding models such as word2vec, glove, ELMo and BERT, and a model is pre-selected as a conversion model for training Chinese words. The output result after conversion is in the form of <word, word vector> as the word vector of the Chinese word and is stored.
[0055] The method for calculating the Chinese phonetic letter vector in this embodiment includes the following steps:
[0056] S1: Read the Chinese dictionary, that is, read all the words and their corresponding Chinese pinyin in the Chinese dictionary and store them in the form of <word, word pinyin>.
[0057] S2: Train word vectors based on the Chinese corpus. That is, read the collected Chinese corpus, run the word vector algorithm to learn the word vectors of Chinese words, and store the Chinese word vector model in the form of <word, word vector>.
[0058] Furthermore, the word vector algorithms in S2 include but are not limited to embedding models such as word2vec, glove, ELMo and BERT.
[0059] S3: Perform inverted indexing on Chinese spelling letters and words, that is, invert the Chinese spelling letters with respect to the words that they participate in constituting the pinyin of the words.
[0060] Furthermore, for the convenience of description, a Chinese dictionary containing only four words {yesterday, today, tomorrow, future} is used for exemplary description, and the corresponding pinyin is {zuotian, jintian, mingtian, weilai}.
[0061] Furthermore, the inverted index of Chinese phonetic letters and words can be described as:
[0062] a: Yesterday (zuotian) -> Today (jintian) -> Tomorrow (mingtian) -> Future (weilai)
[0063] e: Future (weilai)
[0064] i: Yesterday (zuotian) -> Today (jintian) -> Tomorrow (mingtian) -> Future (weilai)
[0065] n: Yesterday (zuotian) -> Today (jintian) -> Tomorrow (mingtian) ......
[0066] In the above inverted index, the pinyin of yesterday, today, tomorrow and the future all contain the letter a, the pinyin of the future contains the letter e, the pinyin of yesterday, today, tomorrow and the future all contain the letter i, and the pinyin of yesterday, today and tomorrow contains the letter n.
[0067] S4: Combine the word vector in step S2 with the inverted index of the Chinese phonetic letters and words in step S4 to calculate the vector of the Chinese phonetic letters. The specific calculation method is as follows:
[0068]
[0069]
[0070] Furthermore, C i Represents Chinese phonetic letters, W j Represents the Chinese Pinyin letter C i The words that participate in forming the pinyin of the word, Represents the letter C i vector, Represents the letter C i Every word of W j The first vector, ∑wordW j in index(C i ) represents the sum of the first vector, index(C i ) represents the letter C i Inverted index after the associated word W j The number of Word W j The word vector of num(C i ,W j ) represents the Chinese phonetic letter C i In the word W j The number of times a character appears in Pinyin. j Word W j The number of letters in the Chinese Pinyin. For example, zuotian contains 7 letters. The same letters are counted repeatedly.
[0071] Furthermore, for the convenience of description, the calculation of the vectors of Chinese Pinyin letters a and i is taken as an example for exemplary description, such as the formula:
[0072]
[0073]
[0074] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should know that the present invention is not limited by the described action sequence, because according to the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.
[0075] According to another aspect of the embodiment of the present application, a device for calculating a Chinese phonetic letter vector is also provided, such as Figure 4 As shown, including:
[0076] A reading module 402 is used to read all Chinese words and their corresponding Chinese pinyin in the Chinese word library;
[0077] A conversion module 404, used to convert Chinese words into word vectors of Chinese words;
[0078] The acquisition module 406 is used to acquire an inverted index of all Chinese words in the Chinese word library, wherein the inverted index includes a plurality of first letters and a first word of each first letter, the first letter is a letter included in the Chinese pinyin of the Chinese word, and the first word is a word including the first letter;
[0079] The calculation module 408 is used to calculate the letter vector of the first letter according to the inverted index and the word vector of the Chinese word.
[0080] Optionally, in this embodiment, the Chinese word library can be one of the Chinese corpora, including all Chinese words and their corresponding Chinese pinyin. The Chinese words are converted into word vectors of Chinese words using a word vector algorithm, and the word vector algorithm includes but is not limited to methods such as word2vec, glove, ELMo and BERT. The first letter can be the letters involved in all Chinese pinyin, and each first letter corresponds to indexing one to multiple Chinese pinyins and Chinese words in which the first letter participates. The sub-vector of each first letter is calculated based on the word vectors of all Chinese words in which the first letter participates and the inverted index results of the first letter.
[0081] In the above device, the purpose of embedding Chinese phonetic letters is achieved by converting word vectors into phonetic letter vectors, thereby solving the technical problem that the word embedding vector does not consider the granularity of Chinese phonetic letters.
[0082] According to an optional example, the acquisition module includes:
[0083] A reading unit, used for reading all letters included in the Chinese pinyin of all Chinese words;
[0084] A first determining unit, used for determining all the read letters as the first letter;
[0085] A search unit, used to search for the first pinyin of each first letter in all Chinese words and the first words corresponding to the first pinyin, and obtain a target search result for each first letter;
[0086] The association unit is used to associate each first letter with its corresponding target search result to obtain an inverted index of all Chinese words in the Chinese word library.
[0087] Optionally, in this embodiment, the inverted index result can be the first pinyin and the first word corresponding to each first letter. For example, the word library includes 3 words (yesterday, today, tomorrow, future), and the corresponding Chinese pinyin is (zuotian, jintian, mingtian, weilai). The results of all the first letters read are (a, e, g, i, j, l, m, n, o, t, u, w, z), and the inverted index result corresponding to the first letter a is a: yesterday (zuotian), today (jintian), tomorrow (mingtian), future (weilai); the inverted index result corresponding to the first letter e is e: future (weilai), and so on, all first letters are inverted indexed.
[0088] According to an optional example, the calculation module includes:
[0089] The second determining unit is used to determine each first letter as a current letter, and perform the following operations on the current letter:
[0090] Calculate the first vector of the current letter in each first word of the current letter;
[0091] Sum the first vector to obtain the target vector;
[0092] Divide the target vector by the number of the first word of the current letter to obtain the letter vector of the current letter.
[0093] Optionally, in this embodiment, each current letter has a first vector in the corresponding first word and the first vectors in all words are summed. For example, the first vector of the current letter a in the first word yesterday is Vyesterday, the first vector of the first word today is Vtoday, the first vector of the first word tomorrow is Vtomorrow, and the first vector of the first word in the future is Vfuture. The sum is Vyesterday + Vtoday + Vtomorrow + Vfuture to obtain the target vector. The number of first words of the current letter is the number of first words corresponding to the current letter in the inverted index result. The number of first words of the current letter a is 4. Dividing the target vector Vyesterday + Vtoday + Vtomorrow + Vfuture by the first number 4, the letter vector of the current letter is (Vyesterday + Vtoday + Vtomorrow + Vfuture) / 4.
[0094] According to an optional example, the second determining unit is further configured to:
[0095] Determine each first word as the current word, and perform the following operations on the current word:
[0096] Count the number of times the current letter appears in the pinyin letters of the current word to obtain a first target number;
[0097] Calculate the product of the word vector of the current word of the current letter and the first target number to obtain the target word vector;
[0098] Compare the target word vector with the number of all letters contained in the pinyin letters of the current word to obtain the first vector of the current letter in the current word.
[0099] Optionally, in this embodiment, the first target number is the number of times the current letter appears in the Chinese pinyin corresponding to the current word. For example, if the current letter is a, the current word is yesterday, and the corresponding Chinese pinyin is (zuotian), the number of times the first letter a appears is 1, that is, the first target number is 1. Each first word corresponds to a word vector. For example, the word vector of the current word yesterday is vyesterday, and the product of the word vector vyesterday and the first target number of 1 is used as the target word vector. The number of all letters contained in the pinyin letters (zuotian) of the current word yesterday is 7. Finally, the target word vector vyesterday*1 is divided by the number 7, and the result is the first vector Vyesterday of the current letter in the current word = vyesterday*1 / 7.
[0100] According to an optional example, the reading module includes:
[0101] An acquisition unit, for acquiring Chinese words and Chinese pinyin of the Chinese words for all Chinese words in the Chinese word library, starting from the first Chinese word;
[0102] A first processing unit, configured to combine the read Chinese words and the Chinese pinyin of the Chinese words into a word-pinyin pair;
[0103] The second processing unit is used to traverse the Chinese word library until all the word-pinyin pairs of the Chinese words are obtained.
[0104] Optionally, in this embodiment, the word-pinyin pair of the Chinese word can be yesterday-zuotian, today-jintian, and the word-pinyin pairs of all Chinese words in the Chinese vocabulary are obtained and stored.
[0105] According to an optional example, the conversion module includes:
[0106] An input unit, used to input Chinese words into a word vector conversion model, wherein the word vector conversion model is a pre-trained model for converting words into word vectors;
[0107] The output unit is used to use the output result of the word vector conversion model as the word vector of the Chinese word.
[0108] Optionally, in this embodiment, the word vector conversion model includes embedding models such as word2vec, glove, ELMo and BERT, and a model is pre-selected as a conversion model for training Chinese words. The output result after conversion is in the form of <word, word vector> as the word vector of the Chinese word and is stored.
[0109] For other examples of this embodiment, please refer to the above examples and will not be repeated here.
[0110] Figure 5 is a structural block diagram of an optional electronic device according to an embodiment of the present application, such as Figure 5 As shown, it includes a processor 502, a communication interface 504, a memory 506 and a communication bus 508, wherein the processor 502, the communication interface 504 and the memory 506 communicate with each other through the communication bus 508, wherein,
[0111] Memory 506, used for storing computer programs;
[0112] The processor 502 is used to execute the computer program stored in the memory 506 to implement the following steps:
[0113] Read all Chinese words and their corresponding Chinese pinyin in the Chinese vocabulary;
[0114] Convert Chinese words into word vectors of Chinese words;
[0115] Obtain an inverted index of all Chinese words in a Chinese word library, wherein the inverted index includes a plurality of first letters and a first word of each first letter, the first letter is a letter included in the Chinese pinyin of the Chinese word, and the first word is a word including the first letter;
[0116] Calculate the letter vector of the first letter based on the inverted index and the word vector of the Chinese word.
[0117] Optionally, in this embodiment, the communication bus may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 The communication interface is used for communication between the above electronic device and other devices.
[0118] The memory may include RAM, or may include non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0119] As an example, the memory 506 may include, but is not limited to, the reading module 402, the conversion module 404, the acquisition module 406, and the calculation module 408 in the request processing device. In addition, it may also include, but is not limited to, other module units in the request processing device, which will not be repeated in this example.
[0120] The above-mentioned processor can be a general-purpose processor, which can include but not be limited to: CPU (Central Processing Unit), NP (Network Processor), etc.; it can also be DSP (Digital Signal Processing), ASIC (Application Specific Integrated Circuit), FPGA (Field-Programmable Gate Array) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0121] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments, and this embodiment will not be described in detail here.
[0122] It can be understood by those skilled in the art that Figure 5 The structure shown is for illustration only. The device for implementing the processing means for the above request may be a terminal device, which may be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (Mobile Internet Devices, MID), a PAD, and other terminal devices. Figure 5 The structure of the electronic device is not limited. Figure 5 More or fewer components (such as network interfaces, display devices, etc.) shown in, or having Figure 5 Different configurations shown.
[0123] A person of ordinary skill in the art can understand that all or part of the steps in the various devices of the above-mentioned embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium, which can include: a flash drive, ROM, RAM, a magnetic disk or an optical disk, etc.
[0124] According to another aspect of the embodiments of the present invention, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program executes the steps in the above-mentioned Chinese phonetic letter vector calculation device when executed by a processor.
[0125] Optionally, in this embodiment, a person of ordinary skill in the art may understand that all or part of the steps in the various devices of the above embodiments may be completed by instructing hardware related to the terminal device through a program, and the program may be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0126] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0127] If the integrated units in the above embodiments are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above computer-readable storage medium. Based on such understanding, the technical solution of the present invention, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling one or more computer devices (which can be personal computers, servers or network devices, etc.) to execute all or part of the steps of the apparatus of each embodiment of the present invention.
[0128] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0129] In the several embodiments provided in the present application, it should be understood that the disclosed client can be implemented in other ways. Among them, the device embodiments described above are only schematic, for example, the division of units is only a logical function division, and there may be other division methods in actual implementation, for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0130] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0131] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0132] The above are only preferred embodiments of the present invention. It should be pointed out that, for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for calculating the vector of Chinese phonetic letters, It is characterized in that include: Read all Chinese words and their corresponding Chinese pinyin in the Chinese vocabulary; Convert the Chinese words into word vectors of Chinese words; Obtain an inverted index of all Chinese words in the Chinese word library, wherein the inverted index includes a plurality of first letters and a first word of each of the first letters, the first letter being a letter included in the Chinese pinyin of the Chinese word, and the first word being a word including the first letter; Calculating the letter vector of the first letter according to the inverted index and the word vector of the Chinese word includes: Determine each of the first letters as the current letter, and perform the following operations on the current letter: calculate the first vector of the current letter in each of the first words of the current letter; sum the first vectors to obtain a target vector; and divide the target vector by the number of the first words of the current letter to obtain the letter vector of the current letter; The method of calculating the first vector of the current letter in each of the first words of the current letter includes: determining each of the first words as the current word, and performing the following operations on the current word: counting the number of times the current letter appears in the pinyin letters of the current word to obtain a first target number of times; calculating the product of the word vector of the current word of the current letter and the first target number of times to obtain a target word vector; and dividing the target word vector by the number of all letters contained in the pinyin letters of the current word to obtain the first vector of the current letter in the current word.
2. The method according to claim 1, It is characterized in that The step of obtaining the inverted index of all Chinese words in the Chinese vocabulary includes: Read all the letters included in the Chinese pinyin of all the Chinese words; Determine all the letters read as the first letters; Searching for the first word pinyin formed by each of the first letters in all the Chinese words and the first words corresponding to the first word pinyin, and obtaining a target search result for each of the first letters; Each of the first letters is associated with the corresponding target search result to obtain an inverted index of all Chinese words in the Chinese vocabulary.
3. The method according to any one of claims 1 or 2, It is characterized in that The method of reading all Chinese words and their corresponding Chinese pinyin in the Chinese word library includes: For all the Chinese words in the Chinese word library, starting from the first Chinese word, obtaining the Chinese words and the Chinese pinyin of the Chinese words; Combining the read Chinese words and the Chinese pinyin of the Chinese words into a word-pinyin pair; The Chinese word library is traversed until the word-pinyin pairs of all the Chinese words are obtained.
4. The method according to claim 3, It is characterized in that The step of converting the Chinese words into word vectors of Chinese words includes: Inputting the Chinese words into a word vector conversion model, wherein the word vector conversion model is a pre-trained model for converting words into word vectors; The output result of the word vector conversion model is used as the word vector of the Chinese word.
5. A device for calculating Chinese phonetic letter vectors, It is characterized in that include: A reading module is used to read all Chinese words and their corresponding Chinese pinyin in the Chinese word library; A conversion module, used for converting the Chinese words into word vectors of Chinese words; an acquisition module, configured to acquire an inverted index of all Chinese words in the Chinese word library, wherein the inverted index includes a plurality of first letters and a first word of each of the first letters, wherein the first letters are letters included in the Chinese pinyin of the Chinese words, and the first words are words including the first letters; A calculation module, used to calculate the letter vector of the first letter according to the inverted index and the word vector of the Chinese word, including: determining each of the first letters as the current letter, and performing the following operations on the current letter: calculating the first vector of the current letter in each of the first words of the current letter; summing the first vectors to obtain a target vector; dividing the target vector by the number of the first words of the current letter to obtain the letter vector of the current letter; the calculation of the first vector of the current letter in each of the first words of the current letter includes: determining each of the first words as the current word, and performing the following operations on the current word: counting the number of times the current letter appears in the pinyin letters of the current word to obtain a first target number of times; calculating the product of the word vector of the current letter and the first target number of times to obtain a target word vector; dividing the target word vector by the number of all letters contained in the pinyin letters of the current word to obtain the first vector of the current letter in the current word.
6. The device according to claim 5, It is characterized in that The acquisition module comprises: A reading unit, used for reading all letters included in the Chinese pinyin of all the Chinese words; A first determining unit, configured to determine all the read letters as the first letters; A search unit, used for searching the first word pinyin formed by each of the first letters in all the Chinese words and the first words corresponding to the first word pinyin, to obtain a target search result for each of the first letters; An associating unit is used to associate each of the first letters with the corresponding target search result to obtain an inverted index of all Chinese words in the Chinese vocabulary.
7. A computer-readable storage medium storing a computer program. It is characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 4 is executed.
8. An electronic device comprising a memory and a processor, It is characterized in that A computer program is stored in the memory, and the processor is configured to execute the method according to any one of claims 1 to 4 through the computer program.
Citation Information
Patent Citations
Word vector processing method and device
CN108874765A
Word vector calculation method and system, electronic equipment and storage medium
CN113255334A