A text processing method, device, computer device, and storage medium

By constructing and decomposing the word vector matrix of text, the problem that text semantics cannot be directly reflected in the prior art is solved, and more efficient natural language processing is achieved.

CN115048941BActive Publication Date: 2025-07-25DOUYIN VISION CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210740581.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-28
Publication Date
2025-07-25
Estimated Expiration
2042-06-28

AI Technical Summary

Technical Problem

When existing natural language processing technology extracts text keywords, the compression matrix cannot directly reflect text semantics, resulting in inefficiency.

Method used

By constructing the initial word vector matrix of the target text and performing singular value decomposition, the target decomposition matrix is obtained to represent the weight of the text semantics in multiple vector dimensions, thereby determining the semantic keywords.

Benefits of technology

The efficiency of natural language processing is improved, and the semantic keywords of the text can be directly determined based on the compressed matrix.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115048941B_ABST
    Figure CN115048941B_ABST
Patent Text Reader

Abstract

The present disclosure provides a text processing method, apparatus, computer device, and storage medium. Among them, the method includes: obtaining keywords included in a target text and determining word vectors corresponding to the keywords; wherein the word vectors include vector elements corresponding to multiple vector dimensions respectively; constructing an initial word vector matrix corresponding to the target text based on the word vectors corresponding to the keywords; performing singular value decomposition processing on the initial word vector matrix to obtain a target decomposition matrix; the target decomposition matrix is used to represent weights corresponding to the semantics of the target text under multiple vector dimensions respectively; determining semantic keywords corresponding to the target text based on the target decomposition matrix. Embodiments of the present disclosure can directly determine semantic keywords reflecting the semantics of the target text according to the target decomposition matrix, thereby improving the efficiency of natural language processing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of natural language processing, and in particular, to a text processing method, apparatus, computer device, and storage medium. Background Art

[0002] In the process of natural language processing, a computer can receive natural language input by a user, and perform a series of operations such as processing and calculating the natural language through algorithms defined by humans inside, so as to simulate the understanding of natural language by humans, and finally return the result expected by the user.

[0003] In the process of using natural language processing technology to extract keywords from text, usually a text matrix is first constructed according to the words in the text and the appearance frequency of each word in each sentence, and then the above text matrix is compressed. Since the compressed matrix cannot directly reflect the semantics of the text, it is impossible to directly determine the keywords in the text based on the compressed matrix. Summary of the Invention

[0004] Embodiments of the present disclosure at least provide a text processing method, apparatus, computer device, and storage medium.

[0005] In a first aspect, an embodiment of the present disclosure provides a text processing method, including:

[0006] Obtain keywords included in a target text, and determine word vectors corresponding to the keywords; wherein, the word vectors include: vector elements corresponding to multiple vector dimensions;

[0007] Based on the word vectors corresponding to the keywords, construct an initial word vector matrix corresponding to the target text;

[0008] Perform singular value decomposition processing on the initial word vector matrix to obtain a target decomposition matrix; the target decomposition matrix is used to represent weights corresponding to the semantics of the target text under multiple vector dimensions;

[0009] Based on the target decomposition matrix, determine semantic keywords corresponding to the target text.

[0010] In an optional implementation manner, the obtaining keywords included in the target text includes:

[0011] Perform word segmentation processing on the target text to obtain initial words included in the target text;

[0012] Screen out the keywords from each of the initial words according to a preset screening rule.

[0013] In an alternative embodiment, constructing the initial word vector matrix corresponding to the target text based on the word vectors corresponding to the keywords includes:

[0014] Constructing the initial word vector matrix corresponding to the target text based on the number of times each of the keywords appears in the target text and the word vectors corresponding to the keywords.

[0015] In an alternative embodiment, constructing the initial word vector matrix corresponding to the target text based on the number of times each of the keywords appears in the target text and the word vectors corresponding to the keywords includes:

[0016] Taking the total number of times the keyword appears in the target text as the number of rows of the initial word vector matrix and taking the number of dimensions of the vector as the number of columns of the initial word vector matrix, and performing splicing processing on the word vectors corresponding to the keywords respectively to obtain the initial word vector matrix;

[0017] Wherein, the number of times the word vector corresponding to any keyword appears in the initial word vector matrix is the same as the number of times it appears in the target text.

[0018] In an alternative embodiment, the target decomposition matrix includes decomposition vectors corresponding to at least one semantics;

[0019] Determining the semantic keywords corresponding to the target text based on the target decomposition matrix includes:

[0020] For each of the at least one semantics, determining the semantic keywords corresponding to the semantics from the alternative words based on the decomposition vector corresponding to the semantics and the word vectors corresponding to the multiple alternative words;

[0021] Determining the semantic keywords corresponding to the at least one semantics respectively as the semantic keywords corresponding to the target text.

[0022] In an alternative embodiment, for each of the at least one semantics, determining the semantic keywords corresponding to the semantics from the alternative words based on the decomposition vector corresponding to the semantics and the word vectors corresponding to the multiple alternative words includes:

[0023] For each of the at least one semantics, determining the similarity information between the decomposition vector corresponding to the semantics and the word vectors corresponding to the respective alternative words;

[0024] Determine the semantic keyword corresponding to this semantic from multiple alternative words based on the similarity information between the word vectors corresponding to the multiple alternative words and the decomposition vector corresponding to this semantic.

[0025] In an optional implementation, the method further includes:

[0026] Generate a compressed text corresponding to the target text based on the semantic keyword corresponding to the target text.

[0027] In a second aspect, an embodiment of the present disclosure further provides a text processing apparatus, including:

[0028] An acquisition module, configured to acquire keywords included in a target text and determine word vectors corresponding to the keywords; wherein, the word vectors include: vector elements corresponding to multiple vector dimensions respectively;

[0029] A construction module, configured to construct an initial word vector matrix corresponding to the target text based on the word vectors corresponding to the keywords;

[0030] A processing module, configured to perform singular value decomposition processing on the initial word vector matrix to obtain a target decomposition matrix; the target decomposition matrix is used to represent the weights corresponding to the semantics of the target text under multiple vector dimensions respectively;

[0031] A determination module, configured to determine a semantic keyword corresponding to the target text based on the target decomposition matrix.

[0032] In a third aspect, an embodiment of the present disclosure further provides a computer device, including: a processor, a memory, and a bus, where the memory stores machine-readable instructions executable by the processor. When the computer device runs, the processor communicates with the memory through the bus, and when the machine-readable instructions are executed by the processor, the steps in the first aspect, or any possible implementation manner in the first aspect are executed.

[0033] In a fourth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is run by a processor, the steps in the first aspect, or any possible implementation manner in the first aspect are executed.

[0034] The text processing method provided by the embodiments of the present disclosure uses word vectors corresponding to keywords in the target text to construct an initial word vector matrix corresponding to the target text. The target decomposition matrix obtained after compressing the initial word vector matrix can represent the weights corresponding to the semantics of the target text in multiple vector dimensions. In this way, according to each semantics of the target text corresponding to the target decomposition matrix and the weights corresponding to the semantics of the target text in multiple vector dimensions respectively, semantic keywords corresponding to each semantics can be determined, that is, semantic keywords reflecting the semantics of the target text can be directly determined according to the compressed matrix, thereby improving the efficiency of natural language processing.

[0035] To make the above objects, features, and advantages of the present disclosure more obvious and understandable, the following specifically enumerates preferred embodiments and, in conjunction with the accompanying drawings, makes a detailed description as follows. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] To more clearly illustrate the technical solutions of the embodiments of the present disclosure, the accompanying drawings required for use in the embodiments will be briefly introduced below. The accompanying drawings herein are incorporated into the specification and constitute a part of this specification. These drawings show embodiments consistent with the present disclosure and, together with the specification, are used to explain the technical solutions of the present disclosure. It should be understood that the following drawings only show some embodiments of the present disclosure and should not be regarded as limiting the scope. For those of ordinary skill in the art, other related drawings can be obtained based on these drawings without creative efforts.

[0037] Figure 1 Shows a flowchart of a text processing method provided by an embodiment of the present disclosure;

[0038] Figure 2 Shows a flowchart of another text processing method provided by an embodiment of the present disclosure;

[0039] Figure 3 Shows a schematic diagram of a text processing device provided by an embodiment of the present disclosure;

[0040] Figure 4 Shows a schematic diagram of a computer device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0041] To make the objectives, technical solutions, and advantages of the embodiments of the present disclosure clearer, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present disclosure. Apparently, the described embodiments are only a part rather than all of the embodiments of the present disclosure. Components of the embodiments of the present disclosure described and illustrated herein generally may be arranged and designed in a variety of different configurations. Therefore, the detailed description of the embodiments of the present disclosure provided herein is not intended to limit the scope of the claimed present disclosure, but merely represents selected embodiments of the present disclosure. All other embodiments obtained by those skilled in the art based on the embodiments of the present disclosure without creative efforts shall fall within the scope of protection of the present disclosure.

[0042] It has been found through research that in the process of using natural language processing technology to extract keywords from text, usually, a text matrix is first constructed based on the words in the text and the occurrence frequencies of each word in each sentence, and then the text matrix is subjected to singular value decomposition to obtain a compressed matrix. The obtained compressed matrix is difficult to directly reflect the semantics of the text. To determine the keywords in the text, other natural language models need to be used to further process the compressed matrix, resulting in low efficiency of natural language processing.

[0043] Based on this, the present disclosure provides a text processing method provided by the embodiments of the present disclosure. By using the word vectors corresponding to the keywords in the target text to construct an initial word vector matrix corresponding to the target text, the target decomposition matrix obtained after compressing the initial word vector matrix can represent the weights corresponding to the semantics of the target text in multiple vector dimensions. Thus, according to each semantics of the target text corresponding to the target decomposition matrix and the weights corresponding to the semantics of the target text in multiple vector dimensions, semantic keywords corresponding to each semantics can be determined, that is, semantic keywords reflecting the semantics of the target text can be directly determined according to the compressed matrix, thereby improving the efficiency of natural language processing.

[0044] Regarding the defects of the above solutions and the proposed solutions, they are all the results obtained by the inventors after practice and careful research. Therefore, the process of discovering the above problems and the solutions proposed by the present disclosure below for the above problems should be the contributions made by the inventors to the present disclosure during the process of the present disclosure.

[0045] It should be noted that similar reference numerals and letters denote similar items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings.

[0046] For ease of understanding this embodiment, first, a text processing method disclosed in the embodiments of the present disclosure will be introduced in detail. The execution subject of the text processing method provided in the embodiments of the present disclosure is generally a computer device with certain computing capabilities.

[0047] Next, taking the execution subject as a server as an example, the text processing method provided in the embodiments of the present disclosure will be described.

[0048] See Figure 1 As shown, it is a flowchart of a text processing method provided in the embodiments of the present disclosure. The method includes S101 to S104, where:

[0049] S101: Obtain the keywords included in the target text and determine the word vectors corresponding to the keywords; where the word vectors include: vector elements corresponding to multiple vector dimensions.

[0050] In the embodiments of the present disclosure, the target text can be any text used for natural language processing. For example, it can be an article, or it can be a comment under an article. The keywords included in the target text can refer to the words with semantics in the target text.

[0051] The target text usually contains some noises. In order to reduce the influence of these noises on the text processing results, in one implementation, the target text can be preprocessed first. For example, the spaces, symbols, etc. in the target text can be removed to obtain a target text that only contains words. After preprocessing, the target text can contain words with semantics, or it can also contain some useless or meaningless words, such as auxiliary words and modal particles.

[0052] Therefore, in one implementation, the target text can be segmented first to obtain the initial words included in the target text. Here, the initial words can include words with semantics and words without semantics.

[0053] Then, according to the preset screening rules, the keywords are screened out from each initial word. Among them, the preset screening rules, for example, can be to screen out the keywords other than the words without semantics.

[0054] Or, perform stop word removal processing on the initial words to obtain the keywords. Here, the stop words can refer to the words without semantics, and stop word removal can refer to deleting the words without semantics. After performing stop word removal processing on the initial words, the obtained words can be used as keywords.

[0055] For example, the obtained target text is: "I looked up and saw nothing but greenery all around. Only scattered patches of sunlight filtered through the green leaves, as if there was a new life trembling on every single leaf. There are many shades of green here, dark green, emerald green, light green, pale green, and some that I can't even name. One cluster of green leaves blocks another, overlapping and lush..." After removing the symbols, the target text can be: "I looked up and saw nothing but greenery all around. Only scattered patches of sunlight filtered through the green leaves, as if there was a new life trembling on every single leaf. There are many shades of green here, dark green, emerald green, light green, pale green, and some that I can't even name. One cluster of green leaves blocks another, overlapping and lush." After word segmentation, the initial words obtained can be: "I / looked up / and saw / nothing but / greenery / all around / only / scattered patches of / sunlight / filtered through / the green leaves / as if / there was / a new / life / trembling / here / the green / there are / many / shades of / dark green / emerald green / light green / pale green / and some / that I / can't even / name / one cluster of / green leaves / blocks / another / overlapping / lush". After screening, the obtained keywords can be: "I / looked up / and saw / nothing but / greenery / scattered patches of / sunlight / filtered through / the green leaves / a single / green leaf / a new / life / trembling / here / the green / many / shades of / dark green / emerald green / light green / pale green / and some / that I / can't even / name / one cluster of / green leaves / blocks / another / overlapping / lush".

[0056] By screening or removing stop words from the initial words, the text noise can be further reduced, and the impact of words irrelevant to the text's theme information on the text processing results can be minimized.

[0057] After obtaining the keywords, the word vectors corresponding to the keywords can be determined according to the corresponding relationship between the preset words and the word vectors. Here, a pre-trained model can be used to convert all the preset words into word vectors, thereby obtaining the corresponding relationship between the preset words and the word vectors. Among them, the preset words can be the keywords included in the target text or the words in the preset vocabulary library (the above keywords are included in the preset words here).

[0058] The word vectors corresponding to the keywords have the same vector dimension. For example, it can be 256-dimensional or 128-dimensional. Each vector dimension corresponds to a vector element respectively.

[0059] S102: Based on the word vectors corresponding to the keywords, construct the initial word vector matrix corresponding to the target text.

[0060] In the embodiments of the present disclosure, the word vectors corresponding to the keywords can be concatenated to obtain an initial word vector matrix. Specifically, the word vectors corresponding to the keywords can be concatenated according to the number of vector dimensions included in the word vectors and the number of keywords to obtain an initial word vector matrix.

[0061] In one implementation, the number p of vector dimensions included in the word vector can be used as the number of columns of the initial word vector matrix, and the number n of keywords can be used as the number of rows of the initial word vector matrix. The word vectors corresponding to the keywords are concatenated to obtain an initial word vector matrix with n rows and p columns.

[0062] For example, if the number of keywords is 2000 and the vector dimension included in the word vector is 256, after concatenating the word vectors corresponding to the keywords, an initial word vector matrix with 2000 rows and 256 columns can be obtained.

[0063] In another implementation, the number p of vector dimensions included in the word vector can also be used as the number of rows of the initial word vector matrix, and the number n of keywords can be used as the number of columns of the initial word vector matrix. The word vectors corresponding to the keywords are concatenated to obtain an initial word vector matrix with p rows and n columns. Here, the concatenation method of the word vectors can be not specifically limited.

[0064] In practice, the number of occurrences of a keyword in the target text is at least one. The above keywords can be after deduplication or without deduplication. In the case of deduplication, the number of the above keywords can be equal to the number of types of keywords; in the case of no deduplication, the number of the above keywords can be equal to the total number of times of the keywords.

[0065] Considering that in the target text, the more times a keyword appears, the closer the keyword is to the theme information of the target text, that is, the more important the keyword is. For example, in the case of no deduplication, the total number of keywords included in a text is 2000, and the number of the keyword "fruit" is 1000, that is, the keyword "fruit" appears 1000 times in this text. Obviously, the proportion of the number of the keyword "fruit" is relatively high, so it can be considered that the keyword "fruit" is a relatively important keyword.

[0066] Therefore, in one implementation, the keywords obtained in step S101 can be without deduplication.

[0067] In this case, an initial word vector matrix corresponding to the target text can be constructed based on the number of occurrences of each keyword in the target text respectively and the word vectors corresponding to each keyword.

[0068] That is, based on the number of times each keyword appears in the target text, the word vectors corresponding to each keyword can be concatenated to obtain an initial word vector matrix.

[0069] In one implementation, the total number of times n that a keyword appears in the target text can be used as the number of rows of the initial word vector matrix, and the number p of vector dimensions can be used as the number of columns of the initial word vector matrix. The word vectors corresponding to the keywords are concatenated to obtain an initial word vector matrix with n rows and p columns. Among them, the number of times the word vector corresponding to any keyword appears in the initial word vector matrix is the same as the number of times it appears in the target text.

[0070] For example, if the total number of times a keyword appears in the target text is 3000 times and the vector dimension of the word vector is 256 dimensions, after concatenating the word vectors corresponding to the keyword, an initial word vector matrix with 3000 rows and 256 columns can be obtained.

[0071] In another implementation, the total number of times a keyword appears in the target text can also be used as the number of columns of the initial word vector matrix, and the number of vector dimensions can be used as the number of rows of the initial word vector matrix. The word vectors corresponding to the keywords are concatenated to obtain an initial word vector matrix. Here, the concatenation method of the word vectors can be not specifically limited.

[0072] S103: Perform singular value decomposition on the initial word vector matrix to obtain a target decomposition matrix; the target decomposition matrix is used to represent the weights corresponding to the semantics of the target text under multiple vector dimensions.

[0073] Here, according to the singular value decomposition formula X = UΛV, after performing singular value decomposition on the initial word vector matrix, two orthogonal matrices U and V and a diagonal matrix Λ can be obtained. Here, U T U = I, V T V = I, Λ i,j = λ i,j if i = j, else 0, i ∈ [1, n], j ∈ [1, p]. Among them, I is the identity matrix, and λ i,j is the element on the diagonal of the diagonal matrix, n is the number of rows of the initial word vector matrix, and P is the number of columns of the initial word vector matrix.

[0074] Exemplarily, for an initial word vector matrix with n rows and p columns, after performing singular value decomposition, an orthogonal matrix with p rows and p columns, an orthogonal matrix with n rows and n columns, and a diagonal matrix with p rows and p columns can be obtained. Among them, the orthogonal matrix with p rows and p columns is obtained for the columns of the initial word vector matrix, that is, the number of rows and columns of this orthogonal matrix is the same as the number of columns of the initial word vector matrix, and this orthogonal matrix can represent the weights corresponding to the semantics of the target text in multiple vector dimensions respectively; the orthogonal matrix with n rows and n columns is a matrix obtained for the rows of the initial word vector matrix, that is, the number of rows and columns of this orthogonal matrix is the same as the number of rows of the initial word vector matrix; the diagonal matrix with p rows and p columns contains p singular values, and the singular values are the elements on the diagonal of the diagonal matrix.

[0075] Here, the target decomposition matrix can be an orthogonal matrix obtained for the columns of the initial word vector matrix, and is used to represent the weights corresponding to the semantics of the target text in multiple vector dimensions respectively. For example, the above orthogonal matrix with p rows and p columns is the target decomposition matrix obtained after performing singular value decomposition on the initial word vector matrix with n rows and p columns. Each row decomposition vector in the target decomposition matrix corresponds to one semantics. The number of decomposition vectors included in the target decomposition matrix can be the same as the vector dimension of the initial word vector matrix. The number of vector elements included in each decomposition vector can also be the same as the vector dimension of the initial word vector matrix. The values of the respective vector elements in each row decomposition vector in the target decomposition matrix can represent the weights of the semantics corresponding to this row decomposition vector in the vector dimension same as this vector element.

[0076] For example, an initial word vector matrix X including 4 dimensions can be expressed as Here, during the process of performing singular value decomposition on the initial word vector matrix X, first calculate Then, according to the formula |ΛI - X T X| = 0, the respective eigenvalues (i.e., singular values) that satisfy the formula |ΛI - X T X| = 0 can be calculated; next, calculate the square roots of the respective eigenvalues, and place the square roots of the respective eigenvalues at the diagonal positions of the matrix, then a diagonal matrix Λ with 4 rows and 4 columns can be obtained.

[0077] Then, substitute the respective eigenvalues back into the formula |ΛI - X T X| = 0, the eigenvectors corresponding to the respective eigenvalues can be obtained. Finally, transpose and splice the respective eigenvectors first, and then a 4 - row and 4 - column orthogonal matrix can be obtained.

[0078] Next, calculate And according to XX TAnd for each of the above eigenvalue values, another set of eigenvectors corresponding to each eigenvalue value is obtained. Furthermore, based on this set of eigenvectors, an orthogonal matrix with 3 rows and 3 columns is obtained.

[0079] That is, after performing singular value decomposition on the above initial word vector matrix, finally, an orthogonal matrix with 4 rows and 4 columns, an orthogonal matrix with 3 rows and 3 columns, and a diagonal matrix with 4 rows and 4 columns can be obtained. The obtained orthogonal matrix with 4 rows and 4 columns is the target decomposition matrix, which can be expressed as Each row decomposition vector of the target decomposition matrix U can correspond to a semantics. Taking the first row decomposition vector as an example, the vector elements a 11 、a 12 、a 13 、a 14 respectively represent the weights of the semantics corresponding to the first row decomposition vector in 4 dimensions.

[0080] In the embodiments of the present disclosure, the row decomposition vectors in the target decomposition matrix can be arranged according to the numerical magnitudes of the vector elements. For example, in the above example, the numerical magnitudes of the vector elements in the first row decomposition vector are greater than those in the second row decomposition vector, and the numerical magnitudes of the vector elements in the second row decomposition vector are greater than those in the third row decomposition vector, and so on. Here, the larger the numerical magnitude of the vector element in the decomposition vector, the greater the weight corresponding to the semantics of the row decomposition vector in multiple vector dimensions, that is, the closer the semantics is to the theme information of the target text.

[0081] S104: Based on the target decomposition matrix, determine the semantic keywords corresponding to the target text.

[0082] Here, the semantic keywords corresponding to the target text can be determined according to the target decomposition matrix and the alternative words. Among them, the alternative words can be the aforementioned preset words.

[0083] In one implementation manner, the target decomposition matrix can include decomposition vectors corresponding to at least one semantics. For each semantics in the at least one semantics, based on the decomposition vector of this semantics and the word vectors corresponding to multiple alternative words, determine the semantic keywords corresponding to this semantics from the alternative words.

[0084] In specific implementation, for each of at least one semantics, based on the decomposition vector of this semantics and the lexical vectors respectively corresponding to multiple alternative words, the target lexical vector matching the decomposition vector of this semantics can be determined. Then, according to the corresponding relationship between the alternative words and the lexical vectors, the target alternative word corresponding to the target lexical vector, that is, the semantic keyword corresponding to this semantics, can be determined. Among them, the corresponding relationship between the alternative words and the lexical vectors can be obtained according to the aforementioned pre-trained model. When the alternative words are the aforementioned preset words, the corresponding relationship between the alternative words and the lexical vectors can be the corresponding relationship between the aforementioned preset words and the word vectors.

[0085] Finally, the semantic keywords respectively corresponding to at least one semantics are determined as the semantic keywords corresponding to the target text.

[0086] Among them, in the process of selecting the semantic keywords corresponding to each semantics, selection can be made according to the similarity between the decomposition vector and the lexical vector. In one implementation manner, for each of at least one semantics, the similarity information between the decomposition vector corresponding to this semantics and the lexical vectors corresponding to each alternative word can be determined. Then, based on the similarity information between the lexical vectors corresponding to multiple alternative words and the decomposition vector corresponding to this semantics respectively, the semantic keyword corresponding to this semantics is determined from multiple alternative words.

[0087] The similarity information here can be, for example, cosine similarity. In specific implementation, a similarity threshold can be set. For each semantics, the alternative words with similarity information greater than the similarity threshold to this semantics can be used as the semantic keywords corresponding to this semantics. In a further implementation, the number of semantic keywords can also be set, and among the alternative words with similarity information greater than the similarity threshold to this semantics, a preset number of alternative words are used as the semantic keywords corresponding to this semantics. In a further implementation, the alternative words with similarity information greater than the similarity threshold can also be sorted according to the magnitude of the similarity information, and according to the sorted alternative words, a preset number of alternative words are selected as the semantic keywords corresponding to this semantics.

[0088] In order to determine the semantic keywords closer to the theme information of the target text, in one implementation manner, according to the arrangement order of the decomposition vectors in each row of the target decomposition matrix from top to bottom, for the semantics corresponding to each row of decomposition vectors in the first preset number of rows of decomposition vectors, based on the decomposition vector of this semantics and the lexical vectors respectively corresponding to multiple alternative words, the semantic keyword corresponding to this semantics is determined from the alternative words. Then, the semantic keywords respectively corresponding to this semantics are determined as the semantic keywords corresponding to the target text.

[0089] Since the numerical values of the vector elements in the previous preset number of rows of the decomposition vector are large, that is, the semantics corresponding to the previous preset number of rows of the decomposition vector have large weights in multiple vector dimensions, that is, the semantic keywords corresponding to each determined semantics are closer to the theme information of the target text.

[0090] After obtaining the semantic keywords corresponding to the target text, in one implementation manner, a compressed text corresponding to the target text can be generated based on the semantic keywords corresponding to the target text. Among them, the compressed text can be a text containing only the above semantic keywords, or a sentence formed based on the above semantic keywords. Among them, generating other forms of compressed text corresponding to the target text based on the semantic keywords is also within the scope of protection required by this disclosure.

[0091] The embodiments of this disclosure also provide a flowchart of another text processing method, as Figure 2 shown.

[0092] First, the original text can be obtained, such as the review text of an article; then the original text is preprocessed (here it can be word segmentation and stop word removal, etc.) to obtain keywords; next, using the corresponding relationship between the preset keywords and word vectors provided by the pre-trained model, the obtained keywords are transformed into word vectors, and then these word vectors are concatenated into an initial word vector matrix. Among them, the process of concatenating word vectors into an initial word vector matrix can refer to the previous text and will not be elaborated here.

[0093] Next, the initial word vector matrix is subjected to singular value decomposition to obtain a target decomposition matrix for characterizing the weights corresponding to the semantics of the original text in multiple vector dimensions respectively; among them, the process of performing singular value decomposition on the initial word vector matrix can refer to the previous text and will not be elaborated here.

[0094] Next, using the corresponding relationship between the preset keywords and word vectors provided by the pre-trained model, and the decomposition vectors corresponding to each semantics in the target decomposition matrix, semantic keywords whose similarity information with each semantics meets the set threshold are screened out from the preset keywords.

[0095] For example, the review text of an article is obtained as follows:

[0096] "This narrative article is written in the order of the development of things, with smooth language and clear levels. The author has a clever idea, and the plot is full of ups and downs, thought-provoking. The language, expressions, actions, etc. of the characters are described carefully and delicately, which is the main feature of this article. This article selects materials from real life, with appropriate selection, great novelty, distinct paragraphs, natural transitions, and strong readability."

[0097] After performing word segmentation and stop word removal on the above review text, the following keywords can be obtained: "narrative / article / according to / the development of events / sequence / write / language / smooth / hierarchy / clear / author's conception / ingenious / story plot / ups and downs / thought-provoking / characters / language / facial expressions / actions / meticulous / detailed description / article features / this article / draw materials from / reality / life / material selection / appropriate / new idea / paragraphs / distinct / transition / natural / readability / strong".

[0098] Here, a pre-trained model can be used to transform these keywords into word vectors. Then, the word vectors corresponding to these keywords are concatenated into an initial word vector matrix. Next, singular value decomposition is performed on the initial word vector matrix to obtain a target decomposition matrix. Finally, according to the cosine similarity between the decomposition vectors corresponding to each semantics contained in the target decomposition matrix and the word vectors corresponding to each alternative word in the vocabulary, the three semantic keywords closest in meaning to the decomposition vector in the first row of the target decomposition matrix are selected as: "story / narrative / plot", and the three semantic keywords closest in meaning to the decomposition vector in the second row of the target decomposition matrix are selected as: "wonderful / vivid / humorous". It can be seen that the above-obtained semantic keywords describe the theme information of the review text from different angles.

[0099] Those skilled in the art can understand that in the above method of the specific implementation manner, the writing order of each step does not mean a strict execution order and does not constitute any limitation to the implementation process. The specific execution order of each step should be determined according to its function and possible internal logic.

[0100] Based on the same inventive concept, a text processing device corresponding to the text processing method is also provided in the embodiments of the present disclosure. Since the principle of solving problems by the device in the embodiments of the present disclosure is similar to the above text processing method in the embodiments of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.

[0101] Refer to Figure 3 As shown, it is a schematic architecture diagram of a text processing device provided by an embodiment of the present disclosure. The device includes: an acquisition module 301, a construction module 302, a processing module 303, and a determination module 304; wherein,

[0102] The acquisition module 301 is configured to acquire keywords included in the target text and determine the word vectors corresponding to the keywords; wherein, the word vectors include: vector elements corresponding to multiple vector dimensions;

[0103] The construction module 302 is configured to construct an initial word vector matrix corresponding to the target text based on the word vectors corresponding to the keywords;

[0104] A processing module 303, configured to perform singular value decomposition processing on the initial word vector matrix to obtain a target decomposition matrix; the target decomposition matrix is used to represent the weights corresponding to the semantics of the target text in multiple vector dimensions.

[0105] A determination module 304, configured to determine semantic keywords corresponding to the target text based on the target decomposition matrix.

[0106] In an optional implementation manner, the obtaining module 301 is specifically configured to:

[0107] Perform word segmentation processing on the target text to obtain initial words included in the target text;

[0108] Screen the keywords from each of the initial words according to a preset screening rule.

[0109] In an optional implementation manner, the construction module 302 is specifically configured to:

[0110] Construct an initial word vector matrix corresponding to the target text based on the number of times each of the keywords appears in the target text and the word vectors corresponding to the keywords.

[0111] In an optional implementation manner, the construction module 302 is specifically configured to:

[0112] Use the total number of times the keyword appears in the target text as the number of rows of the initial word vector matrix, and use the number of vector dimensions as the number of columns of the initial word vector matrix, and splice the word vectors corresponding to the keywords respectively to obtain the initial word vector matrix;

[0113] Wherein, the number of times the word vector corresponding to any keyword appears in the initial word vector matrix is the same as the number of times it appears in the target text.

[0114] In an optional implementation manner, the target decomposition matrix includes decomposition vectors corresponding to at least one semantics;

[0115] The determination module 304 is specifically configured to:

[0116] For each semantics in the at least one semantics, based on the decomposition vector corresponding to the semantics and the vocabulary vectors corresponding to multiple alternative words, determine semantic keywords corresponding to the semantics from the alternative words;

[0117] Determine the semantic keywords corresponding to the at least one semantics as the semantic keywords corresponding to the target text.

[0118] In an optional implementation manner, the determination module 304 is specifically configured to:

[0119] For each of the at least one semantics, determine the similarity information between the decomposition vector corresponding to the semantics and the lexical vectors corresponding to each alternative word.

[0120] Based on the similarity information between the lexical vectors corresponding to multiple alternative words and the decomposition vector corresponding to the semantics, determine the semantic keyword corresponding to the semantics from the multiple alternative words.

[0121] In an alternative embodiment, the apparatus further includes:

[0122] A generation module, configured to generate a compressed text corresponding to the target text based on the semantic keyword corresponding to the target text.

[0123] The description of the processing flow of each module in the apparatus and the interaction flow between the modules may refer to the relevant description in the above method embodiments, which will not be elaborated here.

[0124] Based on the same inventive concept, an embodiment of the present disclosure also provides a computer device. Referring to Figure 4 As shown, it is a schematic structural diagram of a computer device 400 provided by an embodiment of the present disclosure, including a processor 401, a memory 402, and a bus 403. Among them, the memory 402 is used to store execution instructions, including an internal memory 4021 and an external memory 4022; the internal memory 4021 here is also called the main memory, which is used to temporarily store the operation data in the processor 401 and the data exchanged with the external memory 4022 such as a hard disk. The processor 401 exchanges data with the external memory 4022 through the internal memory 4021. When the computer device 400 runs, the processor 401 communicates with the memory 402 through the bus 403, so that the processor 401 executes the following instructions:

[0125] Obtain the keywords included in the target text, and determine the word vectors corresponding to the keywords; wherein, the word vectors include: vector elements corresponding to multiple vector dimensions respectively.

[0126] Based on the word vectors corresponding to the keywords, construct an initial word vector matrix corresponding to the target text.

[0127] Perform singular value decomposition processing on the initial word vector matrix to obtain a target decomposition matrix; the target decomposition matrix is used to represent the weights corresponding to the semantics of the target text in multiple vector dimensions respectively.

[0128] Based on the target decomposition matrix, determine the semantic keyword corresponding to the target text.

[0129] In an embodiment of the present disclosure, a corresponding initial word vector matrix of the target text is constructed using word vectors corresponding to keywords in the target text. The target decomposition matrix obtained after compressing the initial word vector matrix can represent the weights corresponding to the semantics of the target text in multiple vector dimensions. In this way, according to each semantics of the target text corresponding to the target decomposition matrix and the weights corresponding to the semantics of the target text in multiple vector dimensions respectively, semantic keywords corresponding to each semantics can be determined, that is, semantic keywords reflecting the semantics of the target text can be directly determined based on the compressed matrix, thereby improving the efficiency of natural language processing.

[0130] An embodiment of the present disclosure also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is run by a processor, it executes the steps of the text processing method described in the above method embodiment. Among them, the storage medium can be a volatile or non-volatile computer-readable storage medium.

[0131] An embodiment of the present disclosure also provides a computer program product. The computer product carries program codes, and the instructions included in the program codes can be used to execute the steps of the text processing method described in the above method embodiment. For details, reference can be made to the above method embodiment and will not be elaborated here.

[0132] Among them, the above computer program product can be specifically implemented in a manner of hardware, software, or a combination thereof. In an optional embodiment, the computer program product is specifically embodied as a computer storage medium. In another optional embodiment, the computer program product is specifically embodied as a software product, such as a Software Development Kit (SDK), etc.

[0133] Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the above-described device can refer to the corresponding process in the foregoing method embodiment and will not be elaborated here. In several embodiments provided by the present disclosure, it should be understood that the disclosed device and method can be implemented in other ways. The device embodiments described above are only illustrative. For example, the division of the units is only a logical function division, and there may be other division methods in actual implementation. For another 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 displayed or discussed mutual coupling or direct coupling or communication connection may be through some communication interfaces. The indirect coupling or communication connection of the device or unit may be in an electrical, mechanical, or other form.

[0134] The unit described as a separation component may or may not be physically separated. The component shown as a unit may or may not be a physical unit, that is, it may be located in one place or may be distributed over multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0135] In addition, in each embodiment of the present disclosure, each functional unit may be integrated in a processing unit, may exist separately as individual physical units, or two or more units may be integrated in one unit.

[0136] If the described function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a non-volatile computer-readable storage medium executable by a processor. Based on such an understanding, the technical solution of the present disclosure, in essence, or the part that contributes to the prior art or a part of this technical solution can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in each embodiment of the present disclosure. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROM), random access memories (RAM), magnetic disks, or optical discs that can store program codes.

[0137] Finally, it should be noted that the above-described embodiments are only specific implementation manners of the present disclosure, used to illustrate the technical solutions of the present disclosure, and are not intended to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: any person skilled in the art within the technical scope disclosed by the present disclosure can still modify the technical solutions described in the foregoing embodiments or can easily think of changes, or perform equivalent replacements for some of the technical features; and these modifications, changes, or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should all be covered within the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be subject to the protection scope of the claims.

Claims

1. A text processing method, characterized in that, including: obtaining keywords included in a target text, and determining word vectors corresponding to the keywords; wherein, the word vectors include: vector elements corresponding to multiple vector dimensions; constructing an initial word vector matrix corresponding to the target text based on the word vectors corresponding to the keywords; performing singular value decomposition processing on the initial word vector matrix to obtain a target decomposition matrix; the target decomposition matrix is used to represent weights corresponding to the semantics of the target text under multiple vector dimensions; determining semantic keywords corresponding to the target text based on the target decomposition matrix; wherein, the target decomposition matrix includes decomposition vectors corresponding to at least one semantics; the determining semantic keywords corresponding to the target text based on the target decomposition matrix includes: for each semantics in the at least one semantics, determining semantic keywords corresponding to the semantics from the alternative words based on the decomposition vector corresponding to the semantics and the word vectors corresponding to multiple alternative words; determining the semantic keywords corresponding to the at least one semantics as the semantic keywords corresponding to the target text.

2. The method according to claim 1, wherein the obtaining keywords included in the target text includes: performing word segmentation processing on the target text to obtain initial words included in the target text; screening the keywords from each of the initial words according to a preset screening rule.

3. The method according to claim 1, characterized in that, the constructing an initial word vector matrix corresponding to the target text based on the word vectors corresponding to the keywords includes: constructing an initial word vector matrix corresponding to the target text based on the number of times each keyword appears in the target text and the word vectors corresponding to the keywords.

4. The method according to claim 3, wherein the constructing an initial word vector matrix corresponding to the target text based on the number of times each keyword appears in the target text and the word vectors corresponding to the keywords includes: using the total number of times the keyword appears in the target text as the number of rows of the initial word vector matrix and using the number of vector dimensions as the number of columns of the initial word vector matrix, and performing splicing processing on the word vectors corresponding to the keywords to obtain the initial word vector matrix; wherein, the number of times the word vector corresponding to any keyword appears in the initial word vector matrix is the same as the number of times it appears in the target text.

5. The method according to claim 1, wherein the determining semantic keywords corresponding to the semantics from the alternative words based on the decomposition vector corresponding to the semantics and the word vectors corresponding to multiple alternative words includes: for each semantics in the at least one semantics, determining similarity information between the decomposition vector corresponding to the semantics and the word vectors corresponding to each alternative word; determining semantic keywords corresponding to the semantics from multiple alternative words based on the similarity information between the word vectors corresponding to multiple alternative words and the decomposition vector corresponding to the semantics.

6. The method according to any one of claims 1-5, characterized in that, the method further includes: generating a compressed text corresponding to the target text based on the semantic keywords corresponding to the target text.

7. A text processing device, characterized in that, including: An acquisition module, configured to acquire keywords included in a target text and determine word vectors corresponding to the keywords; wherein the word vectors include vector elements corresponding to multiple vector dimensions; A construction module, configured to construct an initial word vector matrix corresponding to the target text based on the word vectors corresponding to the keywords; A processing module, configured to perform singular value decomposition processing on the initial word vector matrix to obtain a target decomposition matrix; the target decomposition matrix is used to represent weights corresponding to the semantics of the target text under multiple vector dimensions; A determination module, configured to determine semantic keywords corresponding to the target text based on the target decomposition matrix; wherein the target decomposition matrix includes decomposition vectors corresponding to at least one semantics; The determination module is further configured to: for each semantics in the at least one semantics, based on the decomposition vector corresponding to the semantics and the word vectors corresponding to multiple candidate words, determine semantic keywords corresponding to the semantics from the candidate words; determine the semantic keywords corresponding to the at least one semantics as the semantic keywords corresponding to the target text.

8. A computer device, characterized in that, Comprising: A processor, a memory and a bus, the memory stores machine-readable instructions executable by the processor, when the computer device runs, the processor communicates with the memory through the bus, and when the machine-readable instructions are executed by the processor, the steps of the text processing method according to any one of claims 1 to 6 are executed.

9. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, and when the computer program is run by a processor, the steps of the text processing method according to any one of claims 1 to 6 are executed.

Citation Information

Patent Citations

  • A method and a device for carrying out sentiment classification on a text, a terminal

    CN109726391A