WO2020143320A1 - 文本词向量获取方法、装置、计算机设备及存储介质 - Google Patents
文本词向量获取方法、装置、计算机设备及存储介质 Download PDFInfo
- Publication number
- WO2020143320A1 WO2020143320A1 PCT/CN2019/118244 CN2019118244W WO2020143320A1 WO 2020143320 A1 WO2020143320 A1 WO 2020143320A1 CN 2019118244 W CN2019118244 W CN 2019118244W WO 2020143320 A1 WO2020143320 A1 WO 2020143320A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- text
- word
- word segmentation
- vector
- result
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
- G06N3/0464—Convolutional networks [CNN, ConvNet]
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F17/00—Digital computing or data processing equipment or methods, specially adapted for specific functions
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
Definitions
- This application relates to the technical field of semantic parsing, and in particular to a text word vector acquisition method, device, computer equipment, and storage medium.
- the existing word vector representation algorithm only considers the neighboring word information of the word, so Based on the existing word vector representation algorithm, the amount of information is small, and the recognition accuracy is not high.
- Embodiments of the present application provide a text word vector acquisition method, device, computer equipment, and storage medium, which aim to solve the problem of segmenting text when using deep learning to process text data in the prior art, and then express the word as a word vector
- the method is used as a feature input, and the word vector characterization algorithm has a small amount of information and a problem of low recognition accuracy.
- an embodiment of the present application provides a text word vector acquisition method, including:
- to-be-processed text Receiving to-be-processed text, converting the to-be-processed text into word segments and word vectors to obtain word vectors corresponding to each word segmentation in the word segmentation result obtained by performing word segmentation on the to-be-processed text;
- the one-hot encoding vector corresponding to each word segmentation in the word segmentation result is spliced with the corresponding word vector to obtain a final word vector corresponding to each word segmentation in the word segmentation result.
- an embodiment of the present application provides a text word vector acquisition device, including:
- the word vector obtaining unit is used to receive the text to be processed, convert the text to be processed into word segmentation and word vector conversion, and obtain a word vector corresponding to each word segmentation in the word segmentation result obtained by performing the word segmentation on the text to be processed;
- a one-hot encoding unit configured to convert the word vector corresponding to each word segmentation in the word segmentation result into a one-hot encoding vector according to the underlying Dirichlet distribution theme model
- the final word vector acquisition unit is used to splice the one-hot encoding vector corresponding to each word segmentation in the word segmentation result with the corresponding word vector to obtain a final word vector corresponding to each word segment in the word segmentation result.
- an embodiment of the present application further provides a computer device, which includes a memory, a processor, and a computer program stored on the memory and executable on the processor, and the processor executes the computer
- the program implements the text word vector acquisition method described in the first aspect above.
- an embodiment of the present application also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor causes the processor to execute the first On the one hand, the text word vector acquisition method.
- FIG. 1 is a schematic diagram of an application scenario of a method for acquiring a text word vector provided by an embodiment of this application;
- FIG. 2 is a schematic flowchart of a method for acquiring a text word vector provided by an embodiment of the present application
- FIG. 3 is another schematic flowchart of a text word vector acquisition method provided by an embodiment of the present application.
- FIG. 4 is a schematic diagram of a sub-process of a method for acquiring a text word vector provided by an embodiment of the present application
- FIG. 5 is a schematic diagram of another sub-process of a method for acquiring a text word vector provided by an embodiment of this application;
- FIG. 6 is a schematic block diagram of an apparatus for acquiring a text word vector provided by an embodiment of this application.
- FIG. 7 is another schematic block diagram of an apparatus for acquiring a text word vector provided by an embodiment of this application.
- FIG. 8 is a schematic block diagram of a subunit of an apparatus for acquiring a text word vector provided by an embodiment of this application;
- FIG. 9 is a schematic block diagram of another subunit of a text word vector acquisition device provided by an embodiment of this application.
- FIG. 10 is a schematic block diagram of a computer device provided by an embodiment of the present application.
- FIG. 1 is a schematic diagram of an application scenario of a method for acquiring a text word vector provided by an embodiment of the present application.
- FIG. 2 is a schematic flowchart of a method for acquiring a text word vector provided by an embodiment of the present application. The method is applied to the server, and the method is executed by the application software installed in the server.
- the method includes steps S110-S130.
- S110 Receive text to be processed, convert the text to be processed into word segments and word vectors, and obtain a word vector corresponding to each word segmentation in a word segmentation result obtained by performing word segmentation on the text to be processed.
- the server when the user terminal uploads the text to be processed to the server, the server receives the text to be processed. Then, the server obtains the word vector corresponding to the text to be processed, so as to facilitate subsequent semantic analysis.
- step S110 includes:
- S111 Segment the text to be processed through a word segmentation model based on probability statistics to obtain a word segmentation result corresponding to the text to be processed;
- the segmentation model based on probability statistics is able to find the target word string W so that W satisfies: P(W
- C) MAX(P(Wa
- the word segmentation model, the word string W obtained by the above word segmentation model is the word string whose estimated probability is the largest.
- Word2Vec is a model for learning semantic knowledge from a large number of text corpora in an unsupervised manner, which can convert each word in the word segmentation result into a corresponding word vector, specifically can convert each word in the word segmentation result into a k Dimensional row vector.
- S120 Correspondingly convert the word vector corresponding to each word segmentation in the word segmentation result into a one-hot encoding vector according to the latent Dirichlet distribution theme model.
- the latent Dirichlet distribution topic model (Latent Dirichlet Allocation, abbreviated as LDA) is a document topic generation model, also known as a three-layer Bayesian probability model, which contains words, topics and documents. Layer structure.
- LDA latent Dirichlet Allocation
- the so-called generative model means that each word of an article is obtained through a process of "selecting a certain topic with a certain probability and selecting a certain word from this topic with a certain probability”. Documents to topics follow a polynomial distribution, and topics to words follow a polynomial distribution.
- LDA For each document in the corpus, LDA defines the following generation process:
- Each document in the corpus corresponds to a multinomial distribution (multinomialdistribution) of T topics (pre-determined by trial and error), and the multinomial distribution is recorded as ⁇ .
- Each topic corresponds to a polynomial distribution of V words in the vocabulary, and this polynomial distribution is recorded as ⁇ .
- step S120 includes:
- S121 Obtain the word segmentation result, and use each word segmentation in the word segmentation result as an input of a latent Dirichlet distribution topic model obtained by pre-training based on the corpus to obtain a theme corresponding to each word segmentation in the word segmentation result;
- the one-hot coding is one-hot coding, which regards each value of the discrete feature as a state. If there are N different values in a feature, then you can use This feature is abstracted into N different states. One-hot coding ensures that each value will only make one state in the "activated state", that is to say, only one of the N states has a state bit value of 1, and other states Bits are all 0. For example, suppose you take the academic qualifications as an example, and the categories you want to study are five categories: elementary school, middle school, university, master, and doctor.
- the unique hot coding vector can be obtained by the words corresponding to the topic in the large set of vocabulary.
- step S130 specifically includes:
- the one-hot encoding vector corresponding to each word segmentation in the word segmentation result is spliced to the head or tail of the corresponding word vector to obtain a final word vector corresponding to each word segmentation in the word segmentation result.
- the one-hot encoding vector corresponding to each word segmentation in the word segmentation result is stitched to the head or tail of the corresponding word vector, and the final word vector obtained by the expansion fully takes into account the topic information and is integrated into the word In the vector, it helps to improve the accuracy of subsequent natural language processing tasks.
- the word vector corresponding to each theme is a 1*300 vector
- the one-hot encoding vector corresponding to each theme is a 1*10 vector
- the two vectors are directly spliced to obtain a 1*310 vector.
- the word vector corresponding to the theme is first, and the one-hot encoding vector corresponding to the theme is second.
- the method further includes:
- the server obtains the word vector corresponding to the text to be processed and the one-hot encoding vector corresponding to the theme to form the final word vector corresponding to the text to be processed.
- the text matrix composed of vectors is input to the trained convolutional neural network model to obtain the text recognition vector.
- the details are as follows: the final word vector corresponding to each word segmentation in the word segmentation result is combined from top to bottom to obtain a text matrix; the text is used as Input the input layer of the trained convolutional neural network model to obtain multiple feature maps; input multiple feature maps into the pooling layer to obtain a one-dimensional row vector corresponding to the maximum value of each feature map; The one-dimensional line vector corresponding to the maximum value of a feature map is input to the fully connected layer to obtain a text recognition vector corresponding to the text for emotion recognition.
- the word vectors corresponding to each word segmentation in the word segmentation result are arranged in order from top to bottom to obtain the input matrix, and the input matrix is used as the input of the input layer in the trained convolutional neural network model to obtain multiple feature maps
- the input layer obtains several Feature Maps (Feature Map can be understood as feature maps) through convolution operation.
- the size of the convolution window is h ⁇ k, where h represents the number of vertical words and k represents the dimension of the vector. Through such a large convolution window, a number of Feature Maps with a column number of 1 will be obtained.
- the largest value proposed from the above one-dimensional Feature Maps can be used.
- This method of pooling can solve the problem of variable length sentence input (because no matter how many values are in the Feature Map, only the maximum value needs to be extracted), the final output of the pooling layer is the maximum value of each Feature Map, that is A one-dimensional vector.
- each node of the fully connected layer is connected to all the nodes of the previous layer, which is used to synthesize the features extracted by the pooling layer to obtain a 1*n text recognition vector, for example, a 1*310 text recognition vector is obtained.
- the convolutional neural network model can effectively extract the deeper features of the text to be emotion-recognized, so that the subsequent text emotion recognition is more accurate.
- step S143 the method further includes:
- the emotion recognition result is a positive emotion result, a neutral emotion result or a negative emotion result
- the title of the text file corresponding to the text to be processed is set as the first display color
- the title of the text file corresponding to the text to be processed is set as the third display color.
- the emotion recognition result of each text to be processed can be obtained at this time, wherein the emotion recognition result is a positive emotion result, a neutral emotion result or Negative emotion results.
- the file title of the text to be processed of different emotion recognition results can be effectively set to different colors, which is convenient for the user to distinguish intuitively according to the color of the file title.
- the text file title corresponding to the text to be processed is set as the first display color; for example, the first display color is red.
- the text file title corresponding to the text to be processed is set to a second display color; for example, the second display color is black.
- the title of the text file corresponding to the text to be processed is set to a third display color; for example, the third display color is green.
- This method realizes the integration of the topic information of the word into its vector representation, further enriches its information, and helps to improve the accuracy of subsequent natural language processing tasks.
- An embodiment of the present application further provides a text word vector acquisition device, which is used to execute any embodiment of the foregoing text word vector acquisition method.
- FIG. 6 is a schematic block diagram of an apparatus for acquiring a text word vector provided by an embodiment of the present application.
- the apparatus 100 for acquiring text word vectors may be configured in a server.
- the text word vector acquisition device 100 includes a word vector acquisition unit 110, a one-hot encoding unit 120, and a final word vector acquisition unit 130.
- the word vector acquisition unit 110 is configured to receive the text to be processed, and perform word segmentation and word vector conversion on the text to be processed to obtain a word vector corresponding to each word segmentation in the word segmentation result obtained by performing the word segmentation on the text to be processed.
- the server when the user terminal uploads the text to be processed to the server, the server receives the text to be processed. Then, the server obtains the word vector corresponding to the text to be processed, so as to facilitate subsequent semantic analysis.
- the word vector acquisition unit 110 includes:
- the word segmentation unit 111 is used to segment the text to be processed through a word segmentation model based on probability statistics to obtain a word segmentation result corresponding to the text to be processed;
- the word vector conversion unit 112 is configured to obtain a word vector corresponding to each word segmentation in the word segmentation result through a Word2Vec model for converting words into vectors.
- the segmentation model based on probability statistics is able to find the target word string W so that W satisfies: P(W
- C) MAX(P(Wa
- the word segmentation model, the word string W obtained by the above word segmentation model is the word string whose estimated probability is the largest.
- Word2Vec is a model for learning semantic knowledge from a large number of text corpora in an unsupervised manner, which can convert each word in the word segmentation result into a corresponding word vector, specifically can convert each word in the word segmentation result into a k Dimensional row vector.
- the one-hot encoding unit 120 is configured to convert the word vector corresponding to each word segmentation in the word segmentation result into a one-hot encoding vector according to the latent Dirichlet distribution theme model.
- the latent Dirichlet distribution topic model (Latent Dirichlet Allocation, abbreviated as LDA) is a document topic generation model, also known as a three-layer Bayesian probability model, which contains words, topics and documents. Layer structure.
- LDA latent Dirichlet Allocation
- the so-called generative model means that each word of an article is obtained through a process of "selecting a certain topic with a certain probability and selecting a certain word from this topic with a certain probability”. Documents to topics follow a polynomial distribution, and topics to words follow a polynomial distribution.
- LDA For each document in the corpus, LDA defines the following generation process:
- Each document in the corpus corresponds to a multinomial distribution (multinomialdistribution) of T topics (given in advance by trial and error), and the multinomial distribution is recorded as ⁇ .
- Each topic corresponds to a polynomial distribution of V words in the vocabulary, and this polynomial distribution is recorded as ⁇ .
- the one-hot encoding unit 120 includes:
- the topic obtaining unit 121 is used to obtain the word segmentation result, and use each word segmentation in the word segmentation result as an input of a latent Dirichlet distribution topic model obtained by pre-training according to the corpus, to obtain each word segmentation in the word segmentation result Corresponding theme;
- the one-hot encoding vector acquisition unit 122 is configured to separately encode the theme of each word segmentation in the word segmentation result to obtain a one-hot encoding vector corresponding to each word segmentation in the word segmentation result.
- the one-hot coding is one-hot coding, which regards each value of the discrete feature as a state. If there are N different values in a feature, then you can use This feature is abstracted into N different states. One-hot coding ensures that each value will only make one state in the "activated state", that is to say, only one of the N states has a state bit value of 1, and other states Bits are all 0. For example, suppose you take the academic qualifications as an example, and the categories you want to study are five categories: elementary school, middle school, university, master, and doctor.
- the unique hot coding vector can be obtained by the words corresponding to the topic in the large set of vocabulary.
- the final word vector obtaining unit 130 is configured to splice the one-hot encoding vector corresponding to each word segmentation in the word segmentation result with the corresponding word vector to obtain a final word vector corresponding to each word segmentation in the word segmentation result.
- the final word vector acquisition unit 130 is specifically used to:
- the one-hot encoding vector corresponding to each word segmentation in the word segmentation result is spliced to the head or tail of the corresponding word vector to obtain a final word vector corresponding to each word segmentation in the word segmentation result.
- the one-hot encoding vector corresponding to each word segmentation in the word segmentation result is spliced to the head or tail of the corresponding word vector, and the final word vector obtained by the expansion fully takes into account the topic information and is integrated into the word In the vector, it helps to improve the accuracy of subsequent natural language processing tasks.
- the word vector corresponding to each theme is a 1*300 vector
- the one-hot encoding vector corresponding to each theme is a 1*10 vector.
- the two vectors are directly spliced to obtain a 1*310 vector.
- the word vector corresponding to the theme is first, and the one-hot encoding vector corresponding to the theme is next.
- the apparatus 100 for acquiring a text word vector as shown in FIG. 7 further includes:
- the text matrix acquisition unit 141 is configured to combine the final word vectors corresponding to each word segmentation in the word segmentation result from top to bottom to obtain a text matrix;
- the text recognition vector acquisition unit 142 is used to input the text matrix into the trained convolutional neural network model to obtain a text recognition vector corresponding to the text to be processed;
- the sentiment classification unit 143 is used to classify the text recognition vector as an input of a text sentiment classifier to obtain a text sentiment recognition result.
- the server obtains the word vector corresponding to the text to be processed and the one-hot encoding vector corresponding to the theme to form the final word vector corresponding to the text to be processed.
- the text matrix composed of vectors is input to the trained convolutional neural network model to obtain the text recognition vector.
- the details are as follows: the final word vector corresponding to each word segmentation in the word segmentation result is combined from top to bottom to obtain a text matrix; the text is used as Input the input layer of the trained convolutional neural network model to obtain multiple feature maps; input multiple feature maps into the pooling layer to obtain a one-dimensional row vector corresponding to the maximum value of each feature map; The one-dimensional line vector corresponding to the maximum value of a feature map is input to the fully connected layer to obtain a text recognition vector corresponding to the text for emotion recognition.
- the word vectors corresponding to each word segmentation in the word segmentation result are arranged in order from top to bottom to obtain the input matrix, and the input matrix is used as the input of the input layer in the trained convolutional neural network model to obtain multiple feature maps
- the input layer obtains several Feature Maps (Feature Map can be understood as feature maps) through convolution operation.
- the size of the convolution window is h ⁇ k, where h represents the number of vertical words and k represents the dimension of the vector. Through such a large convolution window, a number of Feature Maps with a column number of 1 will be obtained.
- the largest value proposed from the above one-dimensional Feature Maps can be used.
- This method of pooling can solve the problem of variable length sentence input (because no matter how many values are in the Feature Map, only the maximum value needs to be extracted), the final output of the pooling layer is the maximum value of each Feature Map, that is A one-dimensional vector.
- each node of the fully connected layer is connected to all the nodes of the previous layer, which is used to synthesize the features extracted by the pooling layer to obtain a 1*n text recognition vector, for example, a 1*310 text recognition vector is obtained.
- the convolutional neural network model can effectively extract the deeper features of the text to be sentiment recognition, so that the subsequent text emotion recognition is more accurate.
- the device realizes the integration of the topic information of the word into its vector representation, further enriches its information amount, and helps to improve the accuracy of subsequent natural language processing tasks.
- the above text word vector acquisition device may be implemented in the form of a computer program, and the computer program may run on the computer device shown in FIG. 10.
- FIG. 10 is a schematic block diagram of a computer device provided by an embodiment of the present application.
- the computer device 500 is a server.
- the server may be an independent server or a server cluster composed of multiple servers.
- the computer device 500 includes a processor 502, a memory, and a network interface 505 connected through a system bus 501, where the memory may include a non-volatile storage medium 503 and an internal memory 504.
- the non-volatile storage medium 503 can store an operating system 5031 and a computer program 5032.
- the computer program 5032 When executed, it may cause the processor 502 to execute the text word vector acquisition method.
- the processor 502 is used to provide computing and control capabilities to support the operation of the entire computer device 500.
- the internal memory 504 provides an environment for running the computer program 5032 in the non-volatile storage medium 503.
- the processor 502 can cause the processor 502 to execute a text word vector acquisition method.
- the network interface 505 is used for network communication, such as the transmission of data information.
- the network interface 505 is used for network communication, such as the transmission of data information.
- FIG. 10 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device 500 to which the solution of the present application is applied.
- the specific computer device 500 may include more or fewer components than shown in the figures, or combine certain components, or have a different arrangement of components.
- the processor 502 is used to run the computer program 5032 stored in the memory, so as to implement the text word vector acquisition method in the embodiment of the present application.
- the embodiment of the computer device shown in FIG. 10 does not constitute a limitation on the specific configuration of the computer device.
- the computer device may include more or fewer components than shown in the figure. Or combine certain components, or arrange different components.
- the computer device may only include a memory and a processor. In such an embodiment, the structures and functions of the memory and the processor are consistent with the embodiment shown in FIG. 10, and details are not described herein again.
- the processor 502 may be a central processing unit (Central Processing Unit, CPU), and the processor 502 may also be other general-purpose processors, digital signal processors (Digital Signal Processor, DSP), Application specific integrated circuit (Application Specific Integrated Circuit, ASIC), ready-made programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
- the general-purpose processor may be a microprocessor or the processor may be any conventional processor.
- a computer-readable storage medium may be a non-volatile computer-readable storage medium.
- the computer-readable storage medium stores a computer program, where the computer program is executed by the processor to implement the text word vector acquisition method in the embodiments of the present application.
- the storage medium is a physical, non-transitory storage medium, for example, it can be a U disk, a mobile hard disk, a read-only memory (Read-Only Memory, ROM), a magnetic disk, or an optical disk and other various physical storages that can store program codes medium.
- ROM Read-Only Memory
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- Data Mining & Analysis (AREA)
- Software Systems (AREA)
- Mathematical Physics (AREA)
- General Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- Biomedical Technology (AREA)
- Evolutionary Computation (AREA)
- General Health & Medical Sciences (AREA)
- Molecular Biology (AREA)
- Computing Systems (AREA)
- Computational Linguistics (AREA)
- Biophysics (AREA)
- Artificial Intelligence (AREA)
- Life Sciences & Earth Sciences (AREA)
- Health & Medical Sciences (AREA)
- Databases & Information Systems (AREA)
- Machine Translation (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
本申请公开了文本词向量获取方法、装置、计算机设备及存储介质。该方法包括:接收待处理文本,将所述待处理文本进行分词及词向量转化,得到与所述待处理文本进行分词得到的分词结果中各分词对应的词向量;将所述分词结果中各分词对应的词向量根据潜在狄利克雷分布主题模型对应转化为独热编码向量;以及将所述分词结果中每一分词对应的独热编码向量与相应的词向量进行拼接,得到与所述分词结果中每一分词对应的最终词向量。
Description
本申请要求于2019年1月7日提交中国专利局、申请号为201910012554.6、申请名称为“文本词向量获取方法、装置、计算机设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
本申请涉及语义解析技术领域,尤其涉及一种文本词向量获取方法、装置、计算机设备及存储介质。
目前,一般使用深度学习处理文本类数据的时候需要对文本进行分词,进而将词表示为词向量方式作为特征输入;目前已有的词向量表征算法中只考虑到词的相邻词信息,故基于目前已有的词向量表征算法信息量少,识别准确率不高。
发明内容
本申请实施例提供了一种文本词向量获取方法、装置、计算机设备及存储介质,旨在解决现有技术中使用深度学习处理文本类数据的时对文本进行分词,进而将词表示为词向量方式作为特征输入,词向量表征算法信息量少,识别准确率不高的问题。
第一方面,本申请实施例提供了一种文本词向量获取方法,其包括:
接收待处理文本,将所述待处理文本进行分词及词向量转化,得到与所述待处理文本进行分词得到的分词结果中各分词对应的词向量;
将所述分词结果中各分词对应的词向量根据潜在狄利克雷分布主题模型对应转化为独热编码向量;以及
将所述分词结果中每一分词对应的独热编码向量与相应的词向量进行拼接,得到与所述分词结果中每一分词对应的最终词向量。
第二方面,本申请实施例提供了一种文本词向量获取装置,其包括:
词向量获取单元,用于接收待处理文本,将所述待处理文本进行分词及词 向量转化,得到与所述待处理文本进行分词得到的分词结果中各分词对应的词向量;
独热编码单元,用于将所述分词结果中各分词对应的词向量根据潜在狄利克雷分布主题模型对应转化为独热编码向量;以及
最终词向量获取单元,用于将所述分词结果中每一分词对应的独热编码向量与相应的词向量进行拼接,得到与所述分词结果中每一分词对应的最终词向量。
第三方面,本申请实施例又提供了一种计算机设备,其包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现上述第一方面所述的文本词向量获取方法。
第四方面,本申请实施例还提供了一种计算机可读存储介质,其中所述计算机可读存储介质存储有计算机程序,所述计算机程序当被处理器执行时使所述处理器执行上述第一方面所述的文本词向量获取方法。
为了更清楚地说明本申请实施例技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为本申请实施例提供的文本词向量获取方法的应用场景示意图;
图2为本申请实施例提供的文本词向量获取方法的流程示意图;
图3为本申请实施例提供的文本词向量获取方法的另一流程示意图;
图4为本申请实施例提供的文本词向量获取方法的子流程示意图;
图5为本申请实施例提供的文本词向量获取方法的另一子流程示意图;
图6为本申请实施例提供的文本词向量获取装置的示意性框图;
图7为本申请实施例提供的文本词向量获取装置的另一示意性框图;
图8为本申请实施例提供的文本词向量获取装置的子单元示意性框图;
图9为本申请实施例提供的文本词向量获取装置的另一子单元示意性框图;
图10为本申请实施例提供的计算机设备的示意性框图。
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
应当理解,当在本说明书和所附权利要求书中使用时,术语“包括”和“包含”指示所描述特征、整体、步骤、操作、元素和/或组件的存在,但并不排除一个或多个其它特征、整体、步骤、操作、元素、组件和/或其集合的存在或添加。
还应当理解,在此本申请说明书中所使用的术语仅仅是出于描述特定实施例的目的而并不意在限制本申请。如在本申请说明书和所附权利要求书中所使用的那样,除非上下文清楚地指明其它情况,否则单数形式的“一”、“一个”及“该”意在包括复数形式。
还应当进一步理解,在本申请说明书和所附权利要求书中使用的术语“和/或”是指相关联列出的项中的一个或多个的任何组合以及所有可能组合,并且包括这些组合。
请参阅图1和图2,图1是本申请实施例提供的文本词向量获取方法的应用场景示意图,图2是本申请实施例提供的文本词向量获取方法的流程示意图,该文本词向量获取方法应用于服务器中,该方法通过安装于服务器中的应用软件进行执行。
如图2所示,该方法包括步骤S110~S130。
S110、接收待处理文本,将所述待处理文本进行分词及词向量转化,得到与所述待处理文本进行分词得到的分词结果中各分词对应的词向量。
在本实施例中,当用户端上传了待处理文本至服务器时,服务器接收所述待处理文本。之后通过服务器获取所述待处理文本所对应的词向量,以便于后续进行语义分析。
在一实施例中,如图4所示,步骤S110包括:
S111、将所述待处理文本通过基于概率统计分词模型进行分词,得到与所述待处理文本对应的分词结果;
S112、通过用于将单词转化为向量的Word2Vec模型获取所述分词结果中各分词对应的词向量。
在本实施例中,对所述待处理文本进行分词时,是通过基于概率统计模型的分词方法进行分词。例如,令C=C1C2...Cm,C是待切分的汉字串,令W=W1W2...Wn,W是切分的结果,Wa,Wb,……,Wk是C的所有可能的切分方案。那么,基于概率统计的切分模型就是能够找到目的词串W,使得W满足:P(W|C)=MAX(P(Wa|C),P(Wb|C)...P(Wk|C))的分词模型,上述分词模型得到的词串W即估计概率为最大之词串。
即对一个待分词的子串S,按照从左到右的顺序取出全部候选词w
1、w
2、…、w
i、…、w
n;在词典中查出每个候选词的概率值P(wi),并记录每个候选词的全部左邻词;计算每个候选词的累积概率,同时比较得到每个候选词的最佳左邻词;如果当前词w
n是字串S的尾词,且累积概率P(wn)最大,则w
n就是S的终点词;从w
n开始,按照从右到左顺序,依次将每个词的最佳左邻词输出,即S的分词结果。
当获取了与所述待处理文本对应的分词结果,通过用于将词语转化为向量的Word2Vec模型对所述分词结果中每一分词进行转化,得到与每一分词对应的词向量。其中,Word2Vec是从大量文本语料中以无监督的方式学习语义知识的一种模型,能将分词结果中每一词语转化成对应的词向量,具体可将分词结果每一词语都转化为一个k维的行向量。
S120、将所述分词结果中各分词对应的词向量根据潜在狄利克雷分布主题模型对应转化为独热编码向量。
在本实施例中,潜在狄利克雷分布主题模型(Latent Dirichlet Allocation,简记为LDA)是一种文档主题生成模型,也称为一个三层贝叶斯概率模型,包含词、主题和文档三层结构。所谓生成模型,就是说,可认为一篇文章的每个词都是通过“以一定概率选择了某个主题,并从这个主题中以一定概率选择某个词语”这样一个过程得到。文档到主题服从多项式分布,主题到词服从多项式分布。
对于语料库中的每篇文档,LDA定义了如下生成过程:
1)对每一篇文档,从主题分布中抽取一个主题;
2)从上述被抽到的主题所对应的单词分布中抽取一个单词;
3)重复上述步骤1)-2)过程直至遍历文档中的每一个单词。
语料库中的每一篇文档与T(通过反复试验等方法事先给定)个主题的一个 多项分布(multinomialdistribution)相对应,将该多项分布记为θ。每个主题又与词汇表中的V个单词的一个多项分布相对应,将这个多项分布记为φ。
在一实施例中,如图5所示,步骤S120包括:
S121、获取所述分词结果,将所述分词结果中每一分词作为根据语料库预先训练所得到的潜在狄利克雷分布主题模型的输入,得到与所述分词结果中每一分词对应的主题;
S122、将所述分词结果中每一分词的主题分别进行独热编码,得到与所述分词结果中各分词一一对应的独热编码向量。
在本实施例中,独热编码即one-hot编码,其将离散型特征的每一种取值都看成一种状态,若某一特征中有N个不相同的取值,那么就可以将该特征抽象成N种不同的状态,one-hot编码保证了每一个取值只会使得一种状态处于“激活态”,也就是说这N种状态中只有一个状态位值为1,其他状态位都是0。举个例子,假设以学历为例,想要研究的类别为小学、中学、大学、硕士、博士五种类别,使用one-hot对其编码就会得到:小学->[1,0,0,0,0];中学->[0,1,0,0,0];大学->[0,0,1,0,0];硕士->[0,0,0,1,0];博士->[0,0,0,0,1]。
故在确定了每个分词对应主题后,可以以主题在词汇表大集合中所对应的词语而得到独热编码向量。
S130、将所述分词结果中每一分词对应的独热编码向量与相应的词向量进行拼接,得到与所述分词结果中每一分词对应的最终词向量。
在一实施例中,步骤S130中具体包括:
将所述分词结果中每一分词对应的独热编码向量拼接至相应的词向量的头部或尾部,得到与所述分词结果中每一分词对应的最终词向量。
在本实施例中,将所述分词结果中每一分词对应的独热编码向量拼接至相应的词向量的头部或尾部,而扩展得到的最终词向量,充分考虑到了主题信息并融入到词向量中,有助于后续自然语言处理任务准确率的提高。例如每一主题对应的词向量为1*300的向量,而每一主题对应的独热编码向量为1*10的向量,则将两向量直接拼接后得到一个1*310的向量。一般是主题对应的词向量在前,主题对应的独热编码向量在后。
在一实施例中,如图3所示,步骤S130之后还包括:
S141、将所述分词结果中每一分词对应的最终词向量从上至下进行组合得 到文本矩阵;
S142、将所述文本矩阵输入至已训练的卷积神经网络模型,得到所述待处理文本对应的文本识别向量;
S143、将所述文本识别向量作为文本情感分类器的输入以进行分类,得到文本情感识别结果。
在本实施例中,通过服务器获取所述待处理文本所对应的词向量及与主题对应的独热编码向量,以组成与所述待处理文本所对应的最终词向量时,将由多个最终词向量组成的文本矩阵输入至已训练的卷积神经网络模型,得到文本识别向量。通过将文本转化为文本识别向量,有效的提取了待进行情感识别文本的文本特征,便于根据文本特征进行情感识别。
在根据与所述待处理文本对应的最终词向量进行情感识别时,具体如下:将所述分词结果中每一分词对应的最终词向量从上至下进行组合得到文本矩阵;将所述文本作为所述已训练的卷积神经网络模型中输入层的输入,得到多个特征图;将多个特征图均输入池化层,得到每一特征图的最大值所对应一维行向量;将每一特征图的最大值所对应一维行向量输入至全连接层,得到与所述待进行情感识别文本对应的文本识别向量。
在本实施例中,将分词结果中各分词对应的词向量从上至下依次排列以得到输入矩阵,将输入矩阵作为已训练的卷积神经网络模型中输入层的输入,得到多个特征图;输入层通过卷积操作得到若干个Feature Map(Feature Map可以理解为特征图),卷积窗口的大小为h×k,其中h表示纵向词语的个数,而k表示向量的维数。通过这样一个大型的卷积窗口,将得到若干个列数为1的Feature Map。
在已训练的卷积神经网络模型的池化层中,可采用从上述多个一维的Feature Map中提出最大的值。通过这种池化方式可以解决可变长度的句子输入问题(因为不管Feature Map中有多少个值,只需要提取其中的最大值),最终池化层的输出为各个Feature Map的最大值,即一个一维的向量。
在已训练的卷积神经网络模型的全连接层中,全连接层的每一个结点都与上一层的所有结点相连,用于将池化层所提取到的特征综合起来,得到一个1*n的文本识别向量,例如得到一个1*310的文本识别向量。通过卷积神经网络模型能有效提取出待进行情感识别文本中更深层次的特征,使得后续的文本情感 识别更加准确。
在一实施例中,步骤S143之后还包括:
判断所述待处理文本的文本情感识别结果的情感识别结果;其中,所述情感识别结果为正向情感结果、中性情感结果或负向情感结果;
若所述待处理文本的文本情感识别结果为正向情感结果,将所述待处理文本对应的文本文件标题设置为第一显示颜色;
若所述待处理文本的文本情感识别结果为中性情感结果,将所述待处理文本对应的文本文件标题设置为第二显示颜色;
若所述待处理文本的文本情感识别结果为负向情感结果,将所述待处理文本对应的文本文件标题设置为第三显示颜色。
在本实施例中,当完成了对所述待处理文本的情感识别后,此时可以获取各待处理文本的情感识别结果,其中所述情感识别结果为正向情感结果、中性情感结果或负向情感结果,通过这一方式能有效将不同的情感识别结果的待处理文本的文件标题设置为不同的颜色,便于用户直观的根据文件标题的颜色进行区分。
若所述待处理文本的文本情感识别结果为正向情感结果,将所述待处理文本对应的文本文件标题设置为第一显示颜色;例如,所述第一显示颜色为红色。
若所述待处理文本的文本情感识别结果为中性情感结果,将所述待处理文本对应的文本文件标题设置为第二显示颜色;例如,所述第二显示颜色为黑色。
若所述待处理文本的文本情感识别结果为负向情感结果,将所述待处理文本对应的文本文件标题设置为第三显示颜色;例如,所述第三显示颜色绿色。
该方法实现了将词的主题信息融入到其向量表征中,进一步丰富其信息量,有助于后续自然语言处理任务准确率的提高。
本申请实施例还提供一种文本词向量获取装置,该文本词向量获取装置用于执行前述文本词向量获取方法的任一实施例。具体地,请参阅图6,图6是本申请实施例提供的文本词向量获取装置的示意性框图。该文本词向量获取装置100可以配置于服务器中。
如图6所示,文本词向量获取装置100包括词向量获取单元110、独热编码单元120、最终词向量获取单元130。
词向量获取单元110,用于接收待处理文本,将所述待处理文本进行分词及 词向量转化,得到与所述待处理文本进行分词得到的分词结果中各分词对应的词向量。
在本实施例中,当用户端上传了待处理文本至服务器时,服务器接收所述待处理文本。之后通过服务器获取所述待处理文本所对应的词向量,以便于后续进行语义分析。
在一实施例中,如图8所示,词向量获取单元110包括:
分词单元111,用于将所述待处理文本通过基于概率统计分词模型进行分词,得到与所述待处理文本对应的分词结果;
词向量转化单元112,用于通过用于将单词转化为向量的Word2Vec模型获取所述分词结果中各分词对应的词向量。
在本实施例中,对所述待处理文本进行分词时,是通过基于概率统计模型的分词方法进行分词。例如,令C=C1C2...Cm,C是待切分的汉字串,令W=W1W2...Wn,W是切分的结果,Wa,Wb,……,Wk是C的所有可能的切分方案。那么,基于概率统计的切分模型就是能够找到目的词串W,使得W满足:P(W|C)=MAX(P(Wa|C),P(Wb|C)...P(Wk|C))的分词模型,上述分词模型得到的词串W即估计概率为最大之词串。
即对一个待分词的子串S,按照从左到右的顺序取出全部候选词w
1、w
2、…、w
i、…、w
n;在词典中查出每个候选词的概率值P(wi),并记录每个候选词的全部左邻词;计算每个候选词的累积概率,同时比较得到每个候选词的最佳左邻词;如果当前词w
n是字串S的尾词,且累积概率P(wn)最大,则w
n就是S的终点词;从w
n开始,按照从右到左顺序,依次将每个词的最佳左邻词输出,即S的分词结果。
当获取了与所述待处理文本对应的分词结果,通过用于将词语转化为向量的Word2Vec模型对所述分词结果中每一分词进行转化,得到与每一分词对应的词向量。其中,Word2Vec是从大量文本语料中以无监督的方式学习语义知识的一种模型,能将分词结果中每一词语转化成对应的词向量,具体可将分词结果每一词语都转化为一个k维的行向量。
独热编码单元120,用于将所述分词结果中各分词对应的词向量根据潜在狄利克雷分布主题模型对应转化为独热编码向量。
在本实施例中,潜在狄利克雷分布主题模型(Latent Dirichlet Allocation,简 记为LDA)是一种文档主题生成模型,也称为一个三层贝叶斯概率模型,包含词、主题和文档三层结构。所谓生成模型,就是说,可认为一篇文章的每个词都是通过“以一定概率选择了某个主题,并从这个主题中以一定概率选择某个词语”这样一个过程得到。文档到主题服从多项式分布,主题到词服从多项式分布。
对于语料库中的每篇文档,LDA定义了如下生成过程:
1)对每一篇文档,从主题分布中抽取一个主题;
2)从上述被抽到的主题所对应的单词分布中抽取一个单词;
3)重复上述步骤1)-2)过程直至遍历文档中的每一个单词。
语料库中的每一篇文档与T(通过反复试验等方法事先给定)个主题的一个多项分布(multinomialdistribution)相对应,将该多项分布记为θ。每个主题又与词汇表中的V个单词的一个多项分布相对应,将这个多项分布记为φ。
在一实施例中,如图9所示,独热编码单元120包括:
主题获取单元121,用于获取所述分词结果,将所述分词结果中每一分词作为根据语料库预先训练所得到的潜在狄利克雷分布主题模型的输入,得到与所述分词结果中每一分词对应的主题;
独热编码向量获取单元122,用于将所述分词结果中每一分词的主题分别进行独热编码,得到与所述分词结果中各分词一一对应的独热编码向量。
在本实施例中,独热编码即one-hot编码,其将离散型特征的每一种取值都看成一种状态,若某一特征中有N个不相同的取值,那么就可以将该特征抽象成N种不同的状态,one-hot编码保证了每一个取值只会使得一种状态处于“激活态”,也就是说这N种状态中只有一个状态位值为1,其他状态位都是0。举个例子,假设以学历为例,想要研究的类别为小学、中学、大学、硕士、博士五种类别,使用one-hot对其编码就会得到:小学->[1,0,0,0,0];中学->[0,1,0,0,0];大学->[0,0,1,0,0];硕士->[0,0,0,1,0];博士->[0,0,0,0,1]。
故在确定了每个分词对应主题后,可以以主题在词汇表大集合中所对应的词语而得到独热编码向量。
最终词向量获取单元130,用于将所述分词结果中每一分词对应的独热编码向量与相应的词向量进行拼接,得到与所述分词结果中每一分词对应的最终词向量。
在一实施例中,最终词向量获取单元130具体用于:
将所述分词结果中每一分词对应的独热编码向量拼接至相应的词向量的头部或尾部,得到与所述分词结果中每一分词对应的最终词向量。
在本实施例中,将所述分词结果中每一分词对应的独热编码向量拼接至相应的词向量的头部或尾部,而扩展得到的最终词向量,充分考虑到了主题信息并融入到词向量中,有助于后续自然语言处理任务准确率的提高。例如每一主题对应的词向量为1*300的向量,而每一主题对应的独热编码向量为1*10的向量,则将两向量直接拼接后得到一个1*310的向量。一般是主题对应的词向量在前,主题对应的独热编码向量在后。
在一实施例中,如图7所示文本词向量获取装置100还包括:
文本矩阵获取单元141,用于将所述分词结果中每一分词对应的最终词向量从上至下进行组合得到文本矩阵;
文本识别向量获取单元142,用于将所述文本矩阵输入至已训练的卷积神经网络模型,得到所述待处理文本对应的文本识别向量;
情感分类单元143,用于将所述文本识别向量作为文本情感分类器的输入以进行分类,得到文本情感识别结果。
在本实施例中,通过服务器获取所述待处理文本所对应的词向量及与主题对应的独热编码向量,以组成与所述待处理文本所对应的最终词向量时,将由多个最终词向量组成的文本矩阵输入至已训练的卷积神经网络模型,得到文本识别向量。通过将文本转化为文本识别向量,有效的提取了待进行情感识别文本的文本特征,便于根据文本特征进行情感识别。
在根据与所述待处理文本对应的最终词向量进行情感识别时,具体如下:将所述分词结果中每一分词对应的最终词向量从上至下进行组合得到文本矩阵;将所述文本作为所述已训练的卷积神经网络模型中输入层的输入,得到多个特征图;将多个特征图均输入池化层,得到每一特征图的最大值所对应一维行向量;将每一特征图的最大值所对应一维行向量输入至全连接层,得到与所述待进行情感识别文本对应的文本识别向量。
在本实施例中,将分词结果中各分词对应的词向量从上至下依次排列以得到输入矩阵,将输入矩阵作为已训练的卷积神经网络模型中输入层的输入,得到多个特征图;输入层通过卷积操作得到若干个Feature Map(Feature Map可以 理解为特征图),卷积窗口的大小为h×k,其中h表示纵向词语的个数,而k表示向量的维数。通过这样一个大型的卷积窗口,将得到若干个列数为1的Feature Map。
在已训练的卷积神经网络模型的池化层中,可采用从上述多个一维的Feature Map中提出最大的值。通过这种池化方式可以解决可变长度的句子输入问题(因为不管Feature Map中有多少个值,只需要提取其中的最大值),最终池化层的输出为各个Feature Map的最大值,即一个一维的向量。
在已训练的卷积神经网络模型的全连接层中,全连接层的每一个结点都与上一层的所有结点相连,用于将池化层所提取到的特征综合起来,得到一个1*n的文本识别向量,例如得到一个1*310的文本识别向量。通过卷积神经网络模型能有效提取出待进行情感识别文本中更深层次的特征,使得后续的文本情感识别更加准确。
该装置实现了将词的主题信息融入到其向量表征中,进一步丰富其信息量,有助于后续自然语言处理任务准确率的提高。
上述文本词向量获取装置可以实现为计算机程序的形式,该计算机程序可以在如图10所示的计算机设备上运行。
请参阅图10,图10是本申请实施例提供的计算机设备的示意性框图。该计算机设备500是服务器。其中,服务器可以是独立的服务器,也可以是多个服务器组成的服务器集群。
参阅图10,该计算机设备500包括通过系统总线501连接的处理器502、存储器和网络接口505,其中,存储器可以包括非易失性存储介质503和内存储器504。
该非易失性存储介质503可存储操作系统5031和计算机程序5032。该计算机程序5032被执行时,可使得处理器502执行文本词向量获取方法。
该处理器502用于提供计算和控制能力,支撑整个计算机设备500的运行。
该内存储器504为非易失性存储介质503中的计算机程序5032的运行提供环境,该计算机程序5032被处理器502执行时,可使得处理器502执行文本词向量获取方法。
该网络接口505用于进行网络通信,如提供数据信息的传输等。本领域技术人员可以理解,图10中示出的结构,仅仅是与本申请方案相关的部分结构的 框图,并不构成对本申请方案所应用于其上的计算机设备500的限定,具体的计算机设备500可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。
其中,所述处理器502用于运行存储在存储器中的计算机程序5032,以实现本申请实施例中的文本词向量获取方法。
本领域技术人员可以理解,图10中示出的计算机设备的实施例并不构成对计算机设备具体构成的限定,在其他实施例中,计算机设备可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。例如,在一些实施例中,计算机设备可以仅包括存储器及处理器,在这样的实施例中,存储器及处理器的结构及功能与图10所示实施例一致,在此不再赘述。
应当理解,在本申请实施例中,处理器502可以是中央处理单元(Central Processing Unit,CPU),该处理器502还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。其中,通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
在本申请的另一实施例中提供计算机可读存储介质。该计算机可读存储介质可以为非易失性的计算机可读存储介质。该计算机可读存储介质存储有计算机程序,其中计算机程序被处理器执行时实现本申请实施例中的文本词向量获取方法。
所述存储介质为实体的、非瞬时性的存储介质,例如可以是U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、磁碟或者光盘等各种可以存储程序代码的实体存储介质。
所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,上述描述的设备、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到各种等效的修改或替换,这些修改或替换都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以权利要求的保护范围为准。
Claims (20)
- 一种文本词向量获取方法,包括:接收待处理文本,将所述待处理文本进行分词及词向量转化,得到与所述待处理文本进行分词得到的分词结果中各分词对应的词向量;将所述分词结果中各分词对应的词向量根据潜在狄利克雷分布主题模型对应转化为独热编码向量;以及将所述分词结果中每一分词对应的独热编码向量与相应的词向量进行拼接,得到与所述分词结果中每一分词对应的最终词向量。
- 根据权利要求1所述的文本词向量获取方法,其中,所述将所述分词结果中每一分词对应的独热编码向量与相应的词向量进行拼接,得到与所述分词结果中每一分词对应的最终词向量之后,还包括:将所述分词结果中每一分词对应的最终词向量从上至下进行组合得到文本矩阵;将所述文本矩阵输入至已训练的卷积神经网络模型,得到所述待处理文本对应的文本识别向量;将所述文本识别向量作为文本情感分类器的输入以进行分类,得到文本情感识别结果。
- 根据权利要求1所述的文本词向量获取方法,其中,所述将所述待处理文本进行分词及词向量转化,得到与所述待处理文本进行分词得到的分词结果中各分词对应的词向量,包括:将所述待处理文本通过基于概率统计分词模型进行分词,得到与所述待处理文本对应的分词结果;通过用于将单词转化为向量的Word2Vec模型获取所述分词结果中各分词对应的词向量。
- 根据权利要求1所述的文本词向量获取方法,其中,所述将所述分词结果中各分词对应的词向量根据潜在狄利克雷分布主题模型对应转化为独热编码向量,包括:获取所述分词结果,将所述分词结果中每一分词作为根据语料库预先训练所得到的潜在狄利克雷分布主题模型的输入,得到与所述分词结果中每一分词 对应的主题;将所述分词结果中每一分词的主题分别进行独热编码,得到与所述分词结果中各分词一一对应的独热编码向量。
- 根据权利要求1所述的文本词向量获取方法,其中,所述将所述分词结果中每一分词对应的独热编码向量与相应的词向量进行拼接,得到与所述分词结果中每一分词对应的最终词向量,包括:将所述分词结果中每一分词对应的独热编码向量拼接至相应的词向量的头部或尾部,得到与所述分词结果中每一分词对应的最终词向量。
- 根据权利要求2所述的文本词向量获取方法,其中,所述将所述文本矩阵输入至已训练的卷积神经网络模型,得到所述待处理文本对应的文本识别向量,包括:将所述文本作为所述已训练的卷积神经网络模型中输入层的输入,得到多个特征图;将多个特征图均输入池化层,得到每一特征图的最大值所对应一维行向量;将每一特征图的最大值所对应一维行向量输入至全连接层,得到与所述待进行情感识别文本对应的文本识别向量。
- 根据权利要求2所述的文本词向量获取方法,其中,所述将所述文本识别向量作为文本情感分类器的输入以进行分类,得到文本情感识别结果之后,还包括:判断所述待处理文本的文本情感识别结果的情感识别结果;其中,所述情感识别结果为正向情感结果、中性情感结果或负向情感结果;若所述待处理文本的文本情感识别结果为正向情感结果,将所述待处理文本对应的文本文件标题设置为第一显示颜色;若所述待处理文本的文本情感识别结果为中性情感结果,将所述待处理文本对应的文本文件标题设置为第二显示颜色;若所述待处理文本的文本情感识别结果为负向情感结果,将所述待处理文本对应的文本文件标题设置为第三显示颜色。
- 一种文本词向量获取装置,包括:词向量获取单元,用于接收待处理文本,将所述待处理文本进行分词及词向量转化,得到与所述待处理文本进行分词得到的分词结果中各分词对应的词 向量;独热编码单元,用于将所述分词结果中各分词对应的词向量根据潜在狄利克雷分布主题模型对应转化为独热编码向量;以及最终词向量获取单元,用于将所述分词结果中每一分词对应的独热编码向量与相应的词向量进行拼接,得到与所述分词结果中每一分词对应的最终词向量。
- 根据权利要求8所述的文本词向量获取装置,其中,还包括:文本矩阵获取单元,用于将所述分词结果中每一分词对应的最终词向量从上至下进行组合得到文本矩阵;文本识别向量获取单元,用于将所述文本矩阵输入至已训练的卷积神经网络模型,得到所述待处理文本对应的文本识别向量;情感分类单元,用于将所述文本识别向量作为文本情感分类器的输入以进行分类,得到文本情感识别结果。
- 根据权利要求8所述的文本词向量获取装置,其中,所述独热编码单元,包括:主题获取单元,用于获取所述分词结果,将所述分词结果中每一分词作为根据语料库预先训练所得到的潜在狄利克雷分布主题模型的输入,得到与所述分词结果中每一分词对应的主题;独热编码向量获取单元,用于将所述分词结果中每一分词的主题分别进行独热编码,得到与所述分词结果中各分词一一对应的独热编码向量。
- 一种计算机设备,包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现以下步骤:接收待处理文本,将所述待处理文本进行分词及词向量转化,得到与所述待处理文本进行分词得到的分词结果中各分词对应的词向量;将所述分词结果中各分词对应的词向量根据潜在狄利克雷分布主题模型对应转化为独热编码向量;以及将所述分词结果中每一分词对应的独热编码向量与相应的词向量进行拼接,得到与所述分词结果中每一分词对应的最终词向量。
- 根据权利要求11所述的计算机设备,其中,所述将所述分词结果中每 一分词对应的独热编码向量与相应的词向量进行拼接,得到与所述分词结果中每一分词对应的最终词向量之后,还包括:将所述分词结果中每一分词对应的最终词向量从上至下进行组合得到文本矩阵;将所述文本矩阵输入至已训练的卷积神经网络模型,得到所述待处理文本对应的文本识别向量;将所述文本识别向量作为文本情感分类器的输入以进行分类,得到文本情感识别结果。
- 根据权利要求11所述的计算机设备,其中,所述将所述待处理文本进行分词及词向量转化,得到与所述待处理文本进行分词得到的分词结果中各分词对应的词向量,包括:将所述待处理文本通过基于概率统计分词模型进行分词,得到与所述待处理文本对应的分词结果;通过用于将单词转化为向量的Word2Vec模型获取所述分词结果中各分词对应的词向量。
- 根据权利要求11所述的计算机设备,其中,所述将所述分词结果中各分词对应的词向量根据潜在狄利克雷分布主题模型对应转化为独热编码向量,包括:获取所述分词结果,将所述分词结果中每一分词作为根据语料库预先训练所得到的潜在狄利克雷分布主题模型的输入,得到与所述分词结果中每一分词对应的主题;将所述分词结果中每一分词的主题分别进行独热编码,得到与所述分词结果中各分词一一对应的独热编码向量。
- 根据权利要求11所述的计算机设备,其中,所述将所述分词结果中每一分词对应的独热编码向量与相应的词向量进行拼接,得到与所述分词结果中每一分词对应的最终词向量,包括:将所述分词结果中每一分词对应的独热编码向量拼接至相应的词向量的头部或尾部,得到与所述分词结果中每一分词对应的最终词向量。
- 根据权利要求12所述的计算机设备,其中,所述将所述文本矩阵输入至已训练的卷积神经网络模型,得到所述待处理文本对应的文本识别向量,包 括:将所述文本作为所述已训练的卷积神经网络模型中输入层的输入,得到多个特征图;将多个特征图均输入池化层,得到每一特征图的最大值所对应一维行向量;将每一特征图的最大值所对应一维行向量输入至全连接层,得到与所述待进行情感识别文本对应的文本识别向量。
- 根据权利要求12所述的计算机设备,其中,所述将所述文本识别向量作为文本情感分类器的输入以进行分类,得到文本情感识别结果之后,还包括:判断所述待处理文本的文本情感识别结果的情感识别结果;其中,所述情感识别结果为正向情感结果、中性情感结果或负向情感结果;若所述待处理文本的文本情感识别结果为正向情感结果,将所述待处理文本对应的文本文件标题设置为第一显示颜色;若所述待处理文本的文本情感识别结果为中性情感结果,将所述待处理文本对应的文本文件标题设置为第二显示颜色;若所述待处理文本的文本情感识别结果为负向情感结果,将所述待处理文本对应的文本文件标题设置为第三显示颜色。
- 一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序当被处理器执行以下操作:接收待处理文本,将所述待处理文本进行分词及词向量转化,得到与所述待处理文本进行分词得到的分词结果中各分词对应的词向量;将所述分词结果中各分词对应的词向量根据潜在狄利克雷分布主题模型对应转化为独热编码向量;以及将所述分词结果中每一分词对应的独热编码向量与相应的词向量进行拼接,得到与所述分词结果中每一分词对应的最终词向量。
- 根据权利要求18所述的计算机可读存储介质,其中,所述将所述分词结果中每一分词对应的独热编码向量与相应的词向量进行拼接,得到与所述分词结果中每一分词对应的最终词向量之后,还包括:将所述分词结果中每一分词对应的最终词向量从上至下进行组合得到文本矩阵;将所述文本矩阵输入至已训练的卷积神经网络模型,得到所述待处理文本 对应的文本识别向量;将所述文本识别向量作为文本情感分类器的输入以进行分类,得到文本情感识别结果。
- 根据权利要求18所述的计算机可读存储介质,其中,所述将所述待处理文本进行分词及词向量转化,得到与所述待处理文本进行分词得到的分词结果中各分词对应的词向量,包括:将所述待处理文本通过基于概率统计分词模型进行分词,得到与所述待处理文本对应的分词结果;通过用于将单词转化为向量的Word2Vec模型获取所述分词结果中各分词对应的词向量。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201910012554.6 | 2019-01-07 | ||
| CN201910012554.6A CN109885826A (zh) | 2019-01-07 | 2019-01-07 | 文本词向量获取方法、装置、计算机设备及存储介质 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2020143320A1 true WO2020143320A1 (zh) | 2020-07-16 |
Family
ID=66925624
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2019/118244 Ceased WO2020143320A1 (zh) | 2019-01-07 | 2019-11-14 | 文本词向量获取方法、装置、计算机设备及存储介质 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN109885826A (zh) |
| WO (1) | WO2020143320A1 (zh) |
Cited By (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20210027121A1 (en) * | 2019-07-22 | 2021-01-28 | Vmware, Inc. | Machine Learning-Based Techniques for Representing Computing Processes as Vectors |
| CN116127983A (zh) * | 2022-12-14 | 2023-05-16 | 马上消费金融股份有限公司 | 文本编码方法、装置、电子设备及存储介质 |
| US11928466B2 (en) | 2021-07-14 | 2024-03-12 | VMware LLC | Distributed representations of computing processes and events |
Families Citing this family (12)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN109885826A (zh) * | 2019-01-07 | 2019-06-14 | 平安科技(深圳)有限公司 | 文本词向量获取方法、装置、计算机设备及存储介质 |
| CN110442711B (zh) * | 2019-07-03 | 2023-06-30 | 平安科技(深圳)有限公司 | 文本智能化清洗方法、装置及计算机可读存储介质 |
| CN110532381B (zh) * | 2019-07-15 | 2023-09-26 | 中国平安人寿保险股份有限公司 | 一种文本向量获取方法、装置、计算机设备及存储介质 |
| CN112396484B (zh) * | 2019-08-16 | 2025-02-28 | 阿里巴巴集团控股有限公司 | 商品的验证方法及装置、存储介质和处理器 |
| CN112580358A (zh) * | 2019-09-30 | 2021-03-30 | 北京国双科技有限公司 | 文本信息提取方法、装置、存储介质及设备 |
| CN110852112B (zh) * | 2019-11-08 | 2023-05-05 | 语联网(武汉)信息技术有限公司 | 词向量嵌入方法及装置 |
| CN111178054A (zh) * | 2019-12-05 | 2020-05-19 | 国网浙江省电力有限公司杭州供电公司 | 基于神经网络语言模型向量化的文本处理方法 |
| CN114077820B (zh) * | 2020-08-18 | 2024-11-26 | 中国电信股份有限公司 | 面向网络规划的文本编码装置、系统以及方法 |
| CN113377965B (zh) * | 2021-06-30 | 2024-02-23 | 中国农业银行股份有限公司 | 感知文本关键词的方法及相关装置 |
| CN114662471B (zh) * | 2022-03-25 | 2026-03-24 | 中国经济信息社有限公司 | 用于稿件处理的词向量搭建方法和稿件处理方法和装置 |
| CN115239429A (zh) * | 2022-07-29 | 2022-10-25 | 广州华多网络科技有限公司 | 属性信息编码方法及其装置、设备、介质、产品 |
| CN118261153B (zh) * | 2024-04-02 | 2025-06-06 | 上海壁仞科技股份有限公司 | 模型编码、模型推理方法、装置、电子设备和存储介质 |
Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20170116203A1 (en) * | 2013-12-02 | 2017-04-27 | Qbase, LLC | Method of automated discovery of topic relatedness |
| CN107220232A (zh) * | 2017-04-06 | 2017-09-29 | 北京百度网讯科技有限公司 | 基于人工智能的关键词提取方法及装置、设备与可读介质 |
| CN108021546A (zh) * | 2016-11-03 | 2018-05-11 | 北京嘀嘀无限科技发展有限公司 | 一种短文本特征扩展方法、装置及服务器 |
| CN108121699A (zh) * | 2017-12-21 | 2018-06-05 | 北京百度网讯科技有限公司 | 用于输出信息的方法和装置 |
| CN108595425A (zh) * | 2018-04-20 | 2018-09-28 | 昆明理工大学 | 基于主题与语义的对话语料关键词抽取方法 |
| CN109885826A (zh) * | 2019-01-07 | 2019-06-14 | 平安科技(深圳)有限公司 | 文本词向量获取方法、装置、计算机设备及存储介质 |
Family Cites Families (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN106878347A (zh) * | 2017-04-28 | 2017-06-20 | 北京奇虎科技有限公司 | 信息处理方法、系统、移动终端和服务器 |
| CN108399228B (zh) * | 2018-02-12 | 2020-11-13 | 平安科技(深圳)有限公司 | 文章分类方法、装置、计算机设备及存储介质 |
| CN108491529B (zh) * | 2018-03-28 | 2021-11-16 | 百度在线网络技术(北京)有限公司 | 信息推荐方法及装置 |
| CN108563638B (zh) * | 2018-04-13 | 2021-08-10 | 武汉大学 | 一种基于主题识别和集成学习的微博情感分析方法 |
-
2019
- 2019-01-07 CN CN201910012554.6A patent/CN109885826A/zh active Pending
- 2019-11-14 WO PCT/CN2019/118244 patent/WO2020143320A1/zh not_active Ceased
Patent Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20170116203A1 (en) * | 2013-12-02 | 2017-04-27 | Qbase, LLC | Method of automated discovery of topic relatedness |
| CN108021546A (zh) * | 2016-11-03 | 2018-05-11 | 北京嘀嘀无限科技发展有限公司 | 一种短文本特征扩展方法、装置及服务器 |
| CN107220232A (zh) * | 2017-04-06 | 2017-09-29 | 北京百度网讯科技有限公司 | 基于人工智能的关键词提取方法及装置、设备与可读介质 |
| CN108121699A (zh) * | 2017-12-21 | 2018-06-05 | 北京百度网讯科技有限公司 | 用于输出信息的方法和装置 |
| CN108595425A (zh) * | 2018-04-20 | 2018-09-28 | 昆明理工大学 | 基于主题与语义的对话语料关键词抽取方法 |
| CN109885826A (zh) * | 2019-01-07 | 2019-06-14 | 平安科技(深圳)有限公司 | 文本词向量获取方法、装置、计算机设备及存储介质 |
Cited By (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20210027121A1 (en) * | 2019-07-22 | 2021-01-28 | Vmware, Inc. | Machine Learning-Based Techniques for Representing Computing Processes as Vectors |
| US11645539B2 (en) * | 2019-07-22 | 2023-05-09 | Vmware, Inc. | Machine learning-based techniques for representing computing processes as vectors |
| US11928466B2 (en) | 2021-07-14 | 2024-03-12 | VMware LLC | Distributed representations of computing processes and events |
| CN116127983A (zh) * | 2022-12-14 | 2023-05-16 | 马上消费金融股份有限公司 | 文本编码方法、装置、电子设备及存储介质 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN109885826A (zh) | 2019-06-14 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2020143320A1 (zh) | 文本词向量获取方法、装置、计算机设备及存储介质 | |
| CN112487168B (zh) | 知识图谱的语义问答方法、装置、计算机设备及存储介质 | |
| CN110673748B (zh) | 输入法中候选长句的提供方法及装置 | |
| WO2021135477A1 (zh) | 基于概率图模型的文本属性抽取方法、装置、计算机设备及存储介质 | |
| CN107506822B (zh) | 一种基于空间融合池化的深度神经网络方法 | |
| CN111709243A (zh) | 一种基于深度学习的知识抽取方法与装置 | |
| CN112052331A (zh) | 一种处理文本信息的方法及终端 | |
| CN110442741B (zh) | 一种基于张量融合和重排序的跨模态图文互搜方法 | |
| CN109918507B (zh) | 一种基于TextCNN改进的文本分类方法 | |
| CN114579605B (zh) | 表格问答数据处理方法、电子设备及计算机存储介质 | |
| CN111930894A (zh) | 长文本匹配方法及装置、存储介质、电子设备 | |
| US20240037335A1 (en) | Methods, systems, and media for bi-modal generation of natural languages and neural architectures | |
| US20230394240A1 (en) | Method and apparatus for named entity recognition, and non-transitory computer-readable recording medium | |
| CN111444346A (zh) | 一种用于文本分类的词向量对抗样本生成方法及装置 | |
| CN118298215A (zh) | 基于多模态提示学习的多标签图像分类方法及系统 | |
| WO2025242036A1 (zh) | 基于图文模态融合的文档信息抽取方法、装置及存储介质 | |
| CN115374786B (zh) | 实体和关系联合抽取方法及装置、存储介质和终端 | |
| CN115270809A (zh) | 基于多模态语义融合的中文关系抽取方法及系统 | |
| CN114792388A (zh) | 图像描述文字生成方法、装置及计算机可读存储介质 | |
| CN112446205B (zh) | 语句判别方法、装置、设备及存储介质 | |
| CN118430043A (zh) | 多模态情感识别模型训练方法、多模态情感识别方法及设备 | |
| CN111460169A (zh) | 语义表达式生成方法、装置及设备 | |
| CN110969005B (zh) | 一种确定实体语料之间的相似性的方法及装置 | |
| CN114896404A (zh) | 文档分类方法及装置 | |
| CN112347196B (zh) | 基于神经网络的实体关系抽取方法及装置 |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 19908355 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 19908355 Country of ref document: EP Kind code of ref document: A1 |