Method, device, electronic device and storage medium for generating word weight

The target word weight is determined by word segmentation and the weight of intermediate words in the preset corpus, which solves the problems of high manual annotation cost and low accuracy of unsupervised methods in the existing technology, and achieves efficient and accurate word weight generation.

CN113590755BActive Publication Date: 2024-10-29BEIJING XIAOMI MOBILE SOFTWARE CO LTD +1
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202110881442.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-02
Publication Date
2024-10-29
Estimated Expiration
2041-08-02

AI Technical Summary

Technical Problem

Existing word weight generation methods require a large amount of manual annotation, which is costly and inefficient. In particular, unsupervised methods have poor generation accuracy and cannot effectively improve the efficiency and accuracy of word weight generation.

Method used

By obtaining the query statement input by the user, perform word segmentation processing and segment the text according to the preset fragment division method, and use the weight of the intermediate words in the preset corpus to determine the weight of the target word, avoiding model training and manual annotation, reducing the amount of calculation, and improving the efficiency Generate efficiency and accuracy.

Benefits of technology

It effectively reduces labor costs, improves the efficiency and accuracy of word weight generation, avoids multiple iterative calculations, and improves the accuracy of generated word weights.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113590755B_ABST
    Figure CN113590755B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a method, device, electronic device and storage medium for generating word weights. The method performs word segmentation processing on a query sentence to obtain the target sentence text after word segmentation; segments the target sentence text according to one or more preset segment division methods to obtain multiple text segments; obtains at least one target text segment from a preset corpus based on the multiple text segments, and the middle word weight corresponding to each word in the at least one target text segment; determines the target word weight corresponding to each word in the target sentence text based on the middle word weight corresponding to each word in the target text segment. In this way, since there is no need for manual annotation, the problem of high labor costs can be avoided. Since there is no need for multiple iterative calculations, the amount of calculation required in the process of generating word weights can be effectively reduced, which is conducive to improving the efficiency of generating word weights, and can effectively ensure the accuracy of the generated word weights.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of natural language processing, and in particular to a method, device, electronic device and storage medium for generating word weights. Background Art

[0002] Word weight is an important parsing task in NLP (Neuro-Linguistic Programming). The size of the word weight is used to characterize the importance of the word in the article or query, which is helpful to reflect the semantic theme of the article and query. The keywords filtered out by the word weight can help browsing users quickly understand the content of the article, and establish an inverted index for the article or query based on the analyzed keywords, which can also improve the accuracy of article or query retrieval. In addition, as the content of semantic analysis, word weight also has a significant effect on other NLP tasks, such as text classification, text clustering and text summary extraction.

[0003] However, current word weight generation methods usually include supervised and unsupervised methods. Supervised word weight generation methods require a large number of labeled keywords as training data to train the model, but the annotation of these keywords is usually difficult, and domain experts are often required to annotate the keywords of the text, which requires high manual annotation costs. Unsupervised word weight generation methods usually have the problem of low efficiency in generating word weights and poor accuracy in obtaining word weights. Summary of the invention

[0004] In order to overcome the problems existing in the related art, the present disclosure provides a method, device, electronic device and storage medium for generating word weights.

[0005] According to a first aspect of an embodiment of the present disclosure, a method for generating a word weight is provided, comprising:

[0006] Obtaining a query statement input by a user, and performing word segmentation processing on the query statement to obtain a target sentence text after word segmentation;

[0007] Segmenting the target sentence text according to one or more preset segment division methods to obtain multiple text segments;

[0008] According to the plurality of text segments, obtaining at least one target text segment and an intermediate word weight corresponding to each word in at least one of the target text segments from a preset corpus, wherein the at least one target text segment is a text segment in the preset corpus used to form the target sentence text with the least number of text segments;

[0009] The target word weight corresponding to each word in the target sentence text is determined according to the intermediate word weight corresponding to each word in the target text segment.

[0010] Optionally, the preset corpus includes a plurality of search text segments and an intermediate word weight of each search word in each of the search text segments, and acquiring at least one target text segment and an intermediate word weight corresponding to each word in at least one of the target text segments from the preset corpus according to the plurality of text segments, comprises:

[0011] Acquire at least one pending text segment that matches the multiple search text segments in the preset corpus;

[0012] Determining, from at least one of the pending text segments, a target text segment for forming the target sentence text with a minimum number of text segments;

[0013] The middle word weight corresponding to each search word in the target text segment is obtained from the preset corpus to obtain the middle word weight corresponding to each word in the target text segment.

[0014] Optionally, determining the target word weight corresponding to each word in the target sentence text according to the intermediate word weight corresponding to each word in the target text segment includes:

[0015] The intermediate word weight corresponding to each word in the target text segment is normalized to obtain the target word weight corresponding to each word in the target sentence text.

[0016] Optionally, the preset corpus is generated in the following manner:

[0017] Acquire a target number of occurrences of each set of search text pairs within a preset historical time period from a user search record database, wherein the search text pairs include a search term and a target search statement text;

[0018] The search text pairs whose target number of times is greater than or equal to a preset number of times threshold are used as the text pairs to be stored, so as to obtain a plurality of the text pairs to be stored;

[0019] Determining, according to the search term, a target relevance between two different target search statement texts in the plurality of to-be-stored text pairs;

[0020] Determining the word weight of each search word in each of the target search sentence texts according to the target relevance;

[0021] Determining the middle word weight of each search word in the search text segment of a preset length according to the word weight of each search word in each target search sentence text;

[0022] The search text segment and the middle word weight of each search word in the search text segment are stored in a preset database to generate the preset corpus.

[0023] Optionally, determining the target relevance between two different target search statement texts in the plurality of to-be-stored text pairs according to the search term includes:

[0024] Obtaining the occurrence frequency of each search term in each target search statement text in the to-be-stored text pair;

[0025] Determining a first correlation between each search term and the target search statement text, and a second correlation between the target search statement text and each search term, according to the occurrence frequency of each search term in the target search statement text;

[0026] The relevance between different target search sentence texts is determined according to the first relevance and the second relevance.

[0027] Optionally, determining a first correlation between each search term and the target search statement text, and a second correlation between the target search statement text and each search term according to the occurrence frequency of each search term in the target search statement text, comprises:

[0028] Generate a first matrix by taking the occurrence frequencies of different search terms in each of the target search sentence texts as column vectors;

[0029] Normalizing the elements in the first matrix row by row to obtain a first correlation matrix;

[0030] determining the first correlation degree according to the first correlation matrix;

[0031] The frequency of each search word appearing in different target search sentence texts is used as a column vector to generate a second matrix;

[0032] Normalizing the elements in the second matrix row by row to obtain a second correlation matrix;

[0033] The second correlation degree is determined according to the second correlation matrix.

[0034] Optionally, determining the relevance between different target search statement texts according to the first relevance and the second relevance includes:

[0035] Obtain the product of the second correlation matrix and the first correlation matrix to obtain a third correlation matrix, wherein the element a in the third correlation matrix is ij represents the correlation between the i-th target search sentence text and the j-th target search sentence text, where i and j are both positive integers;

[0036] The correlation between different target search sentence texts is obtained through the third correlation matrix.

[0037] Optionally, determining the middle word weight of each search word in a search text segment of a preset length according to the word weight of each search word in each target search statement text includes:

[0038] Acquire similar text corresponding to the search text segment and the word weight of each search word in the search text segment in the similar text from a plurality of target search statement texts corresponding to the plurality of text pairs to be stored, wherein the similar text includes one or more search words in the search text segment;

[0039] Get the target number of each similar text;

[0040] The intermediate word weight of each search word in the search text segment is determined according to the target quantity and the word weight of each search word in the search text segment in the similar text.

[0041] According to a second aspect of an embodiment of the present disclosure, there is provided a device for generating word weights, including:

[0042] A first acquisition module is configured to acquire a query sentence input by a user and perform word segmentation processing on the query sentence to obtain a target sentence text after word segmentation;

[0043] A segmentation module is configured to segment the target sentence text according to one or more preset segment division methods to obtain multiple text segments;

[0044] A second acquisition module is configured to acquire at least one target text segment and an intermediate word weight corresponding to each word in at least one target text segment from a preset corpus according to the plurality of text segments, wherein the at least one target text segment is a text segment in the preset corpus used to form the target sentence text with a minimum number of text segments;

[0045] The determination module is configured to determine the target word weight corresponding to each word in the target sentence text according to the intermediate word weight corresponding to each word in the target text segment.

[0046] Optionally, the preset corpus includes a plurality of search text segments and an intermediate word weight of each search word in each of the search text segments, and the second acquisition module is configured to:

[0047] Acquire at least one pending text segment that matches the multiple search text segments in the preset corpus;

[0048] Determining, from at least one of the pending text segments, a target text segment for forming the target sentence text with a minimum number of text segments;

[0049] The middle word weight corresponding to each search word in the target text segment is obtained from the preset corpus to obtain the middle word weight corresponding to each word in the target text segment.

[0050] Optionally, the determining module is configured to:

[0051] The intermediate word weight corresponding to each word in the target text segment is normalized to obtain the target word weight corresponding to each word in the target sentence text.

[0052] Optionally, the device further comprises a preset corpus generation module, wherein the preset corpus generation module is configured to:

[0053] Acquire a target number of occurrences of each set of search text pairs within a preset historical time period from a user search record database, wherein the search text pairs include a search term and a target search statement text;

[0054] The search text pairs whose target number of times is greater than or equal to a preset number of times threshold are used as the text pairs to be stored, so as to obtain a plurality of the text pairs to be stored;

[0055] Determining, according to the search term, a target relevance between two different target search statement texts in the plurality of to-be-stored text pairs;

[0056] Determining the word weight of each search word in each of the target search sentence texts according to the target relevance;

[0057] Determining the middle word weight of each search word in the search text segment of a preset length according to the word weight of each search word in each target search sentence text;

[0058] The search text segment and the middle word weight of each search word in the search text segment are stored in a preset database to generate the preset corpus.

[0059] Optionally, determining the target relevance between two different target search statement texts in the plurality of to-be-stored text pairs according to the search term includes:

[0060] Obtaining the occurrence frequency of each search term in each target search statement text in the to-be-stored text pair;

[0061] Determining a first correlation between each search term and the target search statement text, and a second correlation between the target search statement text and each search term, according to the occurrence frequency of each search term in the target search statement text;

[0062] The relevance between different target search sentence texts is determined according to the first relevance and the second relevance.

[0063] Optionally, the preset corpus generation module is configured to:

[0064] Generate a first matrix by taking the occurrence frequencies of different search terms in each of the target search sentence texts as column vectors;

[0065] Normalizing the elements in the first matrix row by row to obtain a first correlation matrix;

[0066] determining the first correlation degree according to the first correlation matrix;

[0067] The frequency of each search word appearing in different target search sentence texts is used as a column vector to generate a second matrix;

[0068] Normalizing the elements in the second matrix row by row to obtain a second correlation matrix;

[0069] The second correlation degree is determined according to the second correlation matrix.

[0070] Optionally, the preset corpus generation module 405 is configured to:

[0071] Obtain the product of the second correlation matrix and the first correlation matrix to obtain a third correlation matrix, wherein the element a in the third correlation matrix is ij represents the correlation between the i-th target search sentence text and the j-th target search sentence text, where i and j are both positive integers;

[0072] The correlation between different target search sentence texts is obtained through the third correlation matrix.

[0073] Optionally, the preset corpus generation module 405 is configured to:

[0074] Acquire similar text corresponding to the search text segment and the word weight of each search word in the search text segment in the similar text from a plurality of target search statement texts corresponding to the plurality of text pairs to be stored, wherein the similar text includes one or more search words in the search text segment;

[0075] Get the target number of each similar text;

[0076] The intermediate word weight of each search word in the search text segment is determined according to the target quantity and the word weight of each search word in the search text segment in the similar text.

[0077] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, comprising: a memory on which a computer program is stored; and a processor for executing the computer program in the memory to implement the steps of the method described in the first aspect above.

[0078] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, on which computer program instructions are stored, and when the program instructions are executed by a processor, the steps of the method described in the first aspect above are implemented.

[0079] The technical solution provided by the embodiments of the present disclosure may have the following beneficial effects:

[0080] The target sentence text is segmented according to one or more preset segment division methods to obtain multiple text segments; at least one target text segment and the intermediate word weight corresponding to each word in at least one target text segment are obtained from a preset corpus according to the multiple text segments, and the target word weight corresponding to each word in the target sentence text is determined according to the intermediate word weight corresponding to each word in the target text segment. In this way, since there is no need to train the model, the problem of high labor costs caused by the need for data annotation can be avoided, and the amount of calculation required in the process of generating word weights can be effectively reduced, which is conducive to improving the efficiency of generating word weights and can effectively ensure the accuracy of the generated word weights.

[0081] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0082] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0083] Figure 1 is a flow chart of a method for generating word weights shown in an exemplary embodiment of the present disclosure;

[0084] Figure 2 is based on Figure 1 The illustrated embodiment shows a flow chart of a method for generating a preset corpus;

[0085] Figure 3 is based on Figure 2 The illustrated embodiment shows a flow chart of another method for generating a preset corpus;

[0086] Figure 4 is a block diagram of a device for generating word weights shown in an exemplary embodiment of the present disclosure;

[0087] Figure 5 The invention is a block diagram of a device for generating word weights according to an exemplary embodiment. DETAILED DESCRIPTION

[0088] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0089] Before introducing the specific implementation of the present disclosure in detail, the application scenario of the present disclosure is first described as follows. Generally, the size of the word weight is used to characterize the importance of the word in the article or query. The present disclosure can be applied to any scenario where the word weight needs to be obtained, for example, the process of obtaining the word weight of each word in the query before performing topic identification on the query input by the user according to the word weight. When obtaining the keywords of the article or query, it is usually necessary to first obtain the word weight, and then determine the keywords according to the word weight. The method for generating word weights in the related art is generally divided into two categories: supervised and unsupervised. For the supervised word weight generation method, the general processing idea is: regard each word in the text as an object that needs to be processed by binary classification, extract the features of each word in the text, such as part of speech, word frequency, word position and other information, use a machine learning algorithm (such as GBDT (Gradient Boosting Decision Tree, gradient boosting decision tree), linear regression or deep learning, etc.) to train the model, and estimate the probability of each word belonging to the keyword through the trained model, and use the probability value as the word weight of the word. Usually, it is difficult to label keywords in the supervised word weight generation method, and domain experts are often required to label the keywords of the text, which requires high manual labeling costs. In addition, the unsupervised word weight generation methods are mainly divided into statistical-based methods and word graph model-based methods. Among them, the statistical-based methods are represented by Tf-Idf (bag of words model). The bag of words model mainly focuses on the global statistical information of words. It works well in long texts, but in short texts, due to the lack of text topic information, the effect is poor, and the accuracy of the obtained word weights is low. The methods based on the word graph model are represented by TextRank and ExpandRank. ExpandRank is an extension of TextRank. It is mainly aimed at the situation where the co-occurring words contained in the short text are insufficient, and more similar short texts are provided to establish the word graph. Among them, when establishing a word graph, each text will be converted into a vector, each dimension in the vector corresponds to a word, and the value of each dimension corresponds to the Tf-Idf value of the word. By calculating the cosine value between the text vectors, they are arranged from large to small according to the size of the cosine value, so as to determine the candidate similar text of the current text according to the arrangement order, and then the edges are built between the words appearing in the same text in pairs to form a graph, which is an undirected graph. Then, the word weight of each word is calculated in an iterative manner based on the undirected graph. The number of iterations is large and the time is long, so it is not suitable for the scene of real-time word weight. In other words, the method of determining word weights in related technologies usually has problems such as high labor costs, low accuracy of the word weights obtained, and low efficiency in generating word weights.

[0090] To solve the above technical problems, the present disclosure provides a method, an apparatus, an electronic device, and a storage medium for generating word weights. The method includes obtaining a query statement input by a user, performing word segmentation on the query statement to obtain a segmented target statement text; segmenting the target statement text according to one or more preset segment division methods to obtain a plurality of text segments; obtaining at least one target text segment from a preset corpus according to the plurality of text segments, and intermediate word weights corresponding to each word in at least one of the target text segments, and determining target word weights corresponding to each word in the target statement text according to the intermediate word weights corresponding to each word in the target text segment. In this way, since there is no need for manual annotation, the problem of high labor costs can be avoided. Since there is no need for multiple iterative calculations, the amount of calculation required in the process of generating word weights can be effectively reduced, which is beneficial to improving the efficiency of generating word weights and can effectively ensure the accuracy of the generated word weights.

[0091] Figure 1 is a flowchart of a method for generating word weights shown in an exemplary embodiment of the present disclosure; see Figure 1 , the method may include:

[0092] Step 101, obtain a query statement input by a user, and perform word segmentation on the query statement to obtain a segmented target statement text.

[0093] In this step, the query statement may be a statement text corresponding to a piece of query data. When performing word segmentation on the query statement, an existing word segmentation method in the prior art may be used to perform word segmentation on the query statement. There are many word segmentation methods in the prior art, and the present disclosure does not limit this.

[0094] It should be noted that after performing word segmentation on the query statement, the segmented word statement text after word segmentation may be filtered, for example, stop words such as "de" (的), "zai" (在), etc., and modal particles such as "a" (啊), "ne" (呢), "ma" (吗), etc. may be filtered to obtain the target statement text.

[0095] Step 102, segment the target statement text according to one or more preset segment division methods to obtain a plurality of text segments.

[0096] Among them, the preset segment division method may be a segment division method based on n-gram. For example, the preset segment division method may be any one of the segment division methods of 3-gram, 2-gram, and 1-gram, or a method of segmenting the target statement text according to a preset number of divided segments. For example, the target statement text may be divided into 3 text segments, 2 text segments, etc.

[0097] It should be noted that the n-gram refers to a continuous n-word fragment in the target sentence text. For example, when the target sentence text is A / B / C / D, the 3-gram ending with D is B / C / D, the 2-gram ending with D is C / D, and the 1-gram ending with D is D. When the preset segment division method is a segment division method based on n-gram, the target sentence text can be divided into multiple text segments with a segment length less than or equal to n. For example, when the target sentence text after division is A / B / C / D, if the preset segment division method is to perform segment division according to the 3-gram segment division method, it is necessary to obtain 3-gram, 2-gram and 1-gram text segments ending with each word from the target sentence text, so that the 1-gram ending with A is ^ / A, where ^ represents the start mark, the 2-gram ending with A does not exist, the 3-gram ending with C does not exist, the 1-gram ending with B is B, and the 1-gram ending with B is ^ / A. The 2-gram ending with B is A / B, the 3-gram ending with B is ^ / A / B, the 1-gram ending with C is C, the 2-gram ending with C is B / C, the 3-gram ending with C is A / B / C, the 1-gram ending with D is D, the 2-gram ending with D is C / D, and the 3-gram ending with D is B / C / D. The obtained multiple text fragments include: A, ^ / A, B, A / B, ^ / A / B, C, B / C, A / B / C, D, C / D, and B / C / D.

[0098] Step 103: acquiring at least one target text segment and an intermediate word weight corresponding to each word in at least one target text segment from a preset corpus according to the plurality of text segments.

[0099] Among them, the at least one target text segment is a text segment in the preset corpus used to form the target sentence text with the least number of text segments, the preset corpus includes multiple search text segments and the intermediate word weight of each search word in each of the search text segments, and the search text segment is composed of at least one search word.

[0100] In this step, a possible implementation method is: obtain at least one pending text segment that matches multiple search text segments in a preset corpus; determine a target text segment used to form the target sentence text with the least number of text segments from at least one of the pending text segments; obtain the intermediate word weight corresponding to each search word in the target text segment from the preset corpus to obtain the intermediate word weight corresponding to each word in the target text segment.

[0101] For example, still taking the example shown in step 102 as an example, if a plurality of search text fragments matching the text fragment ": A, ^ / A, B, A / B, ^ / A / B, C, B / C, A / B / C, D, C / D, and B / C / D" are obtained in the preset corpus, that is, "^ / A, B / C / D, B, C / D" can be used as the pending text fragment, because the pending text fragment ^ / A and the pending text fragment B / C / D form the text fragment corresponding to the target sentence text "A / B / C / D". The number of segments is 2, and the number of text segments corresponding to the target sentence text "A / B / C / D" formed by the pending text segment ^ / A, the pending text segment B and the pending text segment C / D is 3. Therefore, the pending text segment ^ / A and the pending text segment B / C / D are used as the target text segments, and the middle word weights corresponding to each search term in ^ / A and B / C / D (i.e., the middle word weight of A in ^ / A, the middle word weight of B, the middle word weight of C and the middle word weight of D in B / C / D) are obtained from the preset corpus, so as to obtain the middle word weight of each word in the target text segment.

[0102] Step 104 , determining the target word weight corresponding to each word in the target sentence text according to the intermediate word weight corresponding to each word in the target text segment.

[0103] In this step, the intermediate word weight corresponding to each word in the target text segment may be normalized to obtain the target word weight corresponding to each word in the target sentence text.

[0104] For example, if the intermediate word weight of A in ^ / A is a, the intermediate word weight of B in B / C / D is b, the intermediate word weight of C in B / C / D is c, and the intermediate word weight of D in B / C / D is d, after normalizing the intermediate word weight of A, the intermediate word weight of B, the intermediate word weight of C, and the intermediate word weight of D, we obtain the intermediate word weight of A a / (a+b+c+d), the intermediate word weight of B b / (a+b+c+d), the intermediate word weight of C c / (a+b+c+d), and the intermediate word weight of D d / (a+b+c+d).

[0105] The above technical solution divides the target sentence text into one or more preset segment division methods to obtain multiple text segments; based on the multiple text segments, at least one target text segment and the intermediate word weight corresponding to each word in at least one target text segment are obtained from the preset corpus, and the target word weight corresponding to each word in the target text segment is determined according to the intermediate word weight corresponding to each word in the target text segment. Since there is no need to train the model, the problem of high labor costs caused by the need for data annotation can be avoided, and the amount of calculation required in the process of generating word weights can be effectively reduced, which is conducive to improving the efficiency of generating word weights, and can effectively ensure the accuracy of the generated word weights.

[0106] Figure 2 is based on Figure 1 The embodiment shown is a flowchart of a method for generating a preset corpus; see Figure 2 , Figure 1 The preset corpus shown in can be generated by following the steps below:

[0107] Step 201: Obtain a target number of occurrences of each search text pair within a preset historical time period from a user search record database.

[0108] The search text pair includes a search term and a target search sentence text.

[0109] It should be noted that the user search record database may be a user feedback log that records user search operations. The preset historical time period may be within one month, five days, one hour, or a few seconds before the current time, the search term may be a search keyword entered by the user into the search engine, the target search statement text may be the title text of the searched web page link, and the target number is the number of times the web page link corresponding to the title text is searched by the search keyword in the user search record database within the preset time period.

[0110] For example, after the user enters the search keyword "neural network", the URL link "neural network algorithm" (the title text is displayed on the web page), the URL link "introduction to neural network algorithm", the URL link "machine learning neural network video", etc. appear on the page. If user A clicks on the "neural network algorithm" once, the search text pair formed by the search keyword "neural network" and the target search statement text "neural network algorithm" appears once. If there are users B and C who also select the "neural network algorithm" through the search keyword "neural network", and user B clicks 5 times within the historical time period, and user C clicks 2 times within the historical time period, then the target number of times is 8 times.

[0111] Step 202: The search text pairs whose target number of times is greater than or equal to a preset number of times threshold are taken as the text pairs to be stored, so as to obtain a plurality of the text pairs to be stored.

[0112] For example, if the preset number threshold is N, only when the target number of times of the search text pair is greater than or equal to N, can the search text pair be used as the text pair to be stored.

[0113] Step 203: determining the target relevance between two different target search statement texts in the plurality of to-be-stored text pairs according to the search term.

[0114] For example, take three text pairs to be stored as an example, namely keyword 1 and query 1, keyword 2 and query 2, and keyword 3 and query 3, wherein keyword 1, keyword 2, keyword 3 are all search terms, query 1, query 2 and query 3 are target search statement texts, query 1 includes 3 keyword 1s, 6 keyword 2s, and 0 keyword 3s, query 2 includes 0 keyword 1s, 5 keyword 2s, and 3 keyword 3s, and query 3 includes 5 keyword 1s, 5 keyword 2s, and 7 keyword 3s. The table can be expressed as shown in the following Table 1:

[0115] query1 query2 query3 keyword 1 3 0 5 keyword 2 6 5 5 keyword 3 0 3 7

[0116] Table 1

[0117] In Table 1, the correlation between keyword 1 and query 1 is 3 / (3+5), the correlation between query 1 and keyword 1 is 3 / (3+6), the correlation between keyword 2 and query 1 is 6 / (6+5+5), the correlation between query 1 and keyword 2 is 6 / (3+6), the correlation between keyword 3 and query 1 is 0, and the correlation between query 1 and keyword 3 is 5 / (5+5+7). Similarly, the correlation between each keyword and query 2 and query 3 can be calculated, and the correlation between each query and keyword 1, keyword 2 and keyword 3 can be calculated. After obtaining the correlation between the above keywords and query 1, query 2 and query 3, and the correlation between each query and keyword 1, keyword 2 and keyword 3, we can get the correlation between the above keywords and query 1, query 2 and query 3, and the correlation between each query and keyword 1, keyword 2 and keyword 3. After finding the correlation between query1 and keyword2 and keyword3, we can transfer the keywords to find the target correlation between query1 and query3, query2 and query3, and query1 and query3. Here we take the correlation between query1 and query3 as an example.

[0118] The target correlation between query1 and query3 = (correlation between query1 and keyword1×correlation between keyword1 and query3)+(correlation between query1 and keyword2×correlation between keyword2 and query3)+(correlation between query1 and keyword3×correlation between keyword3 and query3)=(3 / 9)×(5 / 8)+×(5 / 16)+0×(7 / 10)=0.417. Similarly, we can get the target relevance of query1 and query2 = (relevance of query1 and keyword1 × relevance of keyword1 and query2) + (relevance of query1 and keyword2 × relevance of keyword2 and query2) + (relevance of query1 and keyword3 × relevance of keyword3 and query2) = (3 / 9) × 0 + (6 / 9) × (5 / 16) + 0 × (3 / 10) = 0.208, and the target relevance of query2 and query3 = (relevance of query2 and keyword1 × relevance of keyword1 and query3) + (relevance of query2 and keyword2 × relevance of keyword2 and query3) + (relevance of query2 and keyword3 × relevance of keyword3 and query2) 3 and query3) = 0×(3 / 9)+(5 / 8)×(5 / 16)+(3 / 8)×(7 / 10)=0.360.

[0119] Step 204: determine the word weight of each search word in each target search sentence text according to the target relevance.

[0120] For example, still taking the example shown in step 203 as an example, after obtaining the target relevances of query1 and query3, query2 and query3, and query1 and query3, the target relevance can be used to determine the word weight of each search term in each query. If A represents keyword 1, B represents keyword 2, and C represents keyword 3, query1 is represented by A / B, query2 is represented by B / C, and query3 is represented by A / B / C. The target relevance of query1 and query3 is 0.417, and only A and B are in query 3. 1, the target relevance between query1 and query2 is 0.208, among which A appears in query3 except query1, so the word weight of A is 0.417, since B appears in query2 and query3 except query1, the word weight of B is 0.417+0.208. Similarly, since the target relevance between query2 and query3 is 0.360, when calculating the word weights of B and C in query2, since B appears in query1 and query3 except query2, and C appears in query3 except query2, therefore, the word weight of B in query2 is 0.208+0.360, and the word weight of C in query2 is 0.360. Similarly, the word weights of A, B and C in query3 can also be obtained, which will not be repeated here.

[0121] Step 205: determine the middle word weight of each search word in the search text segment of a preset length according to the word weight of each search word in each target search sentence text.

[0122] In this step, similar texts corresponding to the search text fragment and the word weight of each search term in the search text fragment in the similar text can be obtained from multiple target search statement texts corresponding to the multiple text pairs to be stored, and the similar text includes one or more search terms in the search text fragment; the target number of each similar text is obtained; and the intermediate word weight of each search term in the search text fragment is determined according to the target number and the word weight of each search term in the search text fragment in the similar text.

[0123] The search text segment of the preset length may be a 3-gram search text segment, a 2-gram search text segment, or a 1-gram search text segment.

[0124] For example, if a query is A / B / C / D / E, then the 3-gram ending with D is B / C / D, the 2-gram ending with D is C / D, and the 1-gram ending with D is D. If the search text fragment of the preset length is a 3-gram, the search text fragment can be B / C / D for the 3-gram ending with D, A / B / C for the 3-gram ending with C, and C / D / E for the 3-gram ending with E. Here, the word weights of each search word in B / C / D are taken as an example. Since B / C / D may come from multiple different queries, assuming that they are from query4, query5, query6 (that is, query4, query5, query6 are similar texts corresponding to B / C / D), when calculating the intermediate word weight of B, the following formula can be used: (tw1*freq1+tw2*freq2+tw3*freq3) / (freq1+freq2+freq3), in the above formula, tw1, tw2, tw3 represent the word weights of B in query 4, query 5 and query 6 respectively, freq1, freq2 and freq3 represent query 4, query 6 respectively. The frequency of occurrence of query 5 and query 6 in the user search record database (i.e., the target number) can be calculated. Similarly, the intermediate word weights of C and D in the search text segment B / C / D can be obtained. Similarly, the above method can be used to calculate the intermediate word weight corresponding to each search word in each search text segment, which will not be repeated in this disclosure.

[0125] Step 206: store the search text segment and the middle word weight of each search word in the search text segment in a preset database to generate the preset corpus.

[0126] The above technical scheme can determine the target relevance between two different target search statement texts in multiple pairs of texts to be stored by using the search term as the transmission, and determine the word weight of each search term in each target search statement text according to the target relevance, thereby determining the intermediate word weight of each search term in a search text segment of a preset length according to the word weight of each search term in each target search statement text, which can effectively improve the accuracy of the intermediate word weight, and since there is no need for manual labeling, the problem of high labor costs can be avoided. Since there is no need for multiple iterative calculations, the amount of calculation required in the process of generating word weights can be effectively reduced, which is beneficial to improving the efficiency of generating word weights.

[0127] Figure 3 is based on Figure 2 The embodiment shown is a flowchart of another method for generating a preset corpus; see Figure 3 ,above Figure 2The step 203 shown in the figure, in which the target relevance between two different target search statement texts in the plurality of to-be-stored text pairs is determined according to the search term, may include the following steps:

[0128] Step 2031, obtaining the occurrence frequency of each search term in each target search statement text in the to-be-stored text pair.

[0129] For example, taking Table 1 as an example, in Table 1, the frequency of occurrence of keyword 1 in query 1 is 3, the frequency of occurrence of keyword 2 in query 1 is 6, the frequency of occurrence of keyword 3 in query 1 is 0, the frequency of occurrence of keyword 1 in query 2 is 0, the frequency of occurrence of keyword 2 in query 2 is 5, the frequency of occurrence of keyword 3 in query 2 is 3, the frequency of occurrence of keyword 1 in query 3 is 5, the frequency of occurrence of keyword 2 in query 3 is 5, and the frequency of occurrence of keyword 3 in query 3 is 7.

[0130] Step 2032: Determine a first correlation between the search term and the target search statement text, and a second correlation between the target search statement text and each search term, according to the occurrence frequency of each search term in the target search statement text.

[0131] In this step, a possible implementation may include: generating a first matrix using the frequency of occurrence of different search terms in each target search sentence text as a column vector; normalizing the elements in the first matrix by row to obtain a first relevance matrix; determining the first relevance based on the first relevance matrix; generating a second matrix using the frequency of occurrence of each search term in different target search sentence texts as a column vector; normalizing the elements in the second matrix by row to obtain a second relevance matrix; and determining the second relevance based on the second relevance matrix.

[0132] For example, still taking Table 1 as an example, the frequency of occurrence of different search terms (keyword 1, keyword 2, keyword 3) in each target search statement text (query1, query2 and query3) is taken as a column vector, that is, the number of times keyword 1, keyword 2, keyword 3 appear in query1 is taken as the first column vector of the first matrix, the number of times keyword 1, keyword 2, keyword 3 appear in query2 is taken as the second column vector of the first matrix, and the number of times keyword 1, keyword 2, keyword 3 appear in query3 is taken as the third column vector of the first matrix, so that the first matrix is ​​obtained as follows: Normalizing the elements in the first matrix row by row may be to divide the elements of each row by the sum of the elements in the current row, thereby obtaining the first correlation matrix The first correlation between the search term keyword 1 and the target search sentence text query1 is The first correlation between keyword 1 and the target search sentence text query2 is 0, and the first correlation between keyword 1 and the target search sentence text query3 is Similarly, we can get the first correlation between keyword2 and the target search statement text query1, query2, and query3 as The first correlation between keyword3 and the target search statement text query1, query2, and query3 is 0.

[0133] In addition, the frequency of each search word (keyword 1, keyword 2, keyword 3) appearing in different target search sentence texts (query 1, query 2 and query 3) is used as a column vector, that is, the frequency of the search word keyword 1 appearing in query 1, query 2 and query 3 is used as the first column vector in the second matrix, the frequency of the search word keyword 2 appearing in query 1, query 2 and query 3 is used as the second column vector in the second matrix, and the frequency of the search word keyword 3 appearing in query 1, query 2 and query 3 is used as the third column vector in the second matrix, so that the second matrix is ​​formed as follows: It should be noted that That is, the second matrix is ​​the transpose of the first matrix. Normalizing the elements in the second matrix row by row can be done by dividing the elements of each row by the sum of the elements in the current row, thereby obtaining the second correlation matrix According to the second correlation matrix, the second correlation between query1 and the search terms keyword 1, keyword 2, and keyword 3 can be obtained as follows: 0, the second relevance between query2 and the search terms keyword 1, keyword 2, and keyword 3 is 0, The second relevance between keyword3 and the target search statement text query1, query2, and query3 is obtained as

[0134] Step 2033: Determine the relevance between different target search statement texts according to the first relevance and the second relevance.

[0135] In this step, the product of the second correlation matrix and the first correlation matrix can be obtained to obtain a third correlation matrix. The element a in the third correlation matrix is ij represents the correlation between the i-th target search statement text and the j-th target search statement text, where i and j are both positive integers; the correlation between different target search statement texts is obtained through the third correlation matrix.

[0136] For example, if the product of the second correlation matrix and the first correlation matrix is ​​obtained as Then the a 11 Represents the relevance between the first target search sentence text and the first target search sentence text. 12 Represents the relevance between the first target search sentence text and the second target search sentence text, that is, a ij represents the correlation between the i-th target search sentence text and the j-th target search sentence text, where i and j are both positive integers less than or equal to 3.

[0137] The above technical scheme can effectively determine the correlation between different target search statement texts according to the first correlation and the second correlation, and can provide a reliable data basis for generating the intermediate word weights in the preset expectation library, which is conducive to improving the accuracy of the intermediate word weights.

[0138] Figure 4 is a block diagram of a device for generating word weights as shown in an exemplary embodiment of the present disclosure; Figure 4 As shown, the word weight generating device may include:

[0139] The first acquisition module 401 is configured to acquire a query sentence input by a user and perform word segmentation on the query sentence to obtain a target sentence text after word segmentation;

[0140] The segmentation module 402 is configured to segment the target sentence text according to one or more preset segmentation methods to obtain multiple text segments;

[0141] The second acquisition module 403 is configured to acquire at least one target text segment and an intermediate word weight corresponding to each word in at least one of the target text segments from a preset corpus according to the plurality of the text segments, wherein the at least one target text segment is a text segment in the preset corpus used to form the target sentence text with the least number of text segments;

[0142] The determination module 404 is configured to determine the target word weight corresponding to each word in the target sentence text according to the intermediate word weight corresponding to each word in the target text segment.

[0143] The above technical solution, through the segmentation module 402, the target sentence text is segmented according to one or more preset segment division methods to obtain multiple text segments; through the second acquisition module 403, at least one target text segment is acquired from the preset corpus according to the multiple text segments, and the intermediate word weight corresponding to each word in at least one of the target text segments is determined by the determination module 404 according to the intermediate word weight corresponding to each word in the target text segment. In this way, since there is no need to train the model, the problem of high labor costs caused by the need for data annotation can be avoided, and the amount of calculation required in the process of generating word weights can be effectively reduced, which is conducive to improving the efficiency of generating word weights, and can effectively ensure the accuracy of the generated word weights.

[0144] Optionally, the second acquisition module 403 is configured to:

[0145] Acquire at least one pending text segment that matches the plurality of text segments from a preset corpus;

[0146] Determining, from at least one of the pending text segments, a target text segment for forming the target sentence text with a minimum number of text segments;

[0147] The intermediate word weight corresponding to each word in the target text segment is obtained from the preset corpus.

[0148] Optionally, the determination module 404 is configured to:

[0149] The intermediate word weight corresponding to each word in the target text segment is normalized to obtain the target word weight corresponding to each word in the target sentence text.

[0150] Optionally, the device further includes a preset corpus generation module 405, and the preset corpus generation module 405 is configured to:

[0151] Obtaining a target number of occurrences of each set of search text pairs within a preset historical time period from a user search record database, the search text pairs including a search term and a target search sentence text;

[0152] The search text pairs whose target number of times is greater than or equal to a preset number of times threshold are used as the text pairs to be stored, so as to obtain a plurality of the text pairs to be stored;

[0153] Determine, according to the search term, a target relevance between two different target search statement texts in the plurality of to-be-stored text pairs;

[0154] Determine the word weight of each search word in each target search sentence text according to the target relevance;

[0155] Determine the middle word weight of each search word in the search text segment of a preset length according to the word weight of each search word in each target search sentence text;

[0156] The search text segment and the middle word weight of each search word in the search text segment are stored in a preset database to generate the preset corpus.

[0157] Optionally, determining the target relevance between two different target search statement texts in the plurality of to-be-stored text pairs according to the search term includes:

[0158] Obtaining the occurrence frequency of each search term in each target search statement text in the to-be-stored text pair;

[0159] Determining a first correlation between the search term and the target search statement text, and a second correlation between the target search statement text and each search term, according to the occurrence frequency of each search term in the target search statement text;

[0160] The relevance between different target search sentence texts is determined according to the first relevance and the second relevance.

[0161] Optionally, the preset corpus generation module 405 is configured to:

[0162] Generate a first matrix by taking the occurrence frequencies of different search terms in each target search sentence text as column vectors;

[0163] Normalizing the elements in the first matrix row by row to obtain a first correlation matrix;

[0164] Determining the first correlation degree according to the first correlation matrix;

[0165] The frequency of each search word appearing in different target search sentence texts is used as a column vector to generate a second matrix;

[0166] Normalizing the elements in the second matrix row by row to obtain a second correlation matrix;

[0167] The second correlation degree is determined according to the second correlation matrix.

[0168] Optionally, the preset corpus generation module 405 is configured to:

[0169] Obtain the product of the second correlation matrix and the first correlation matrix to obtain a third correlation matrix, in which element a ij represents the correlation between the i-th target search sentence text and the j-th target search sentence text, where i and j are both positive integers;

[0170] The correlations between different target search sentence texts are obtained through the third correlation matrix.

[0171] Optionally, the preset corpus generation module 405 is configured to:

[0172] Acquire similar text corresponding to the search text segment and the word weight of each search word in the search text segment in the similar text from multiple target search statement texts corresponding to the multiple text pairs to be stored, wherein the similar text includes one or more search words in the search text segment;

[0173] Get the target number of each similar text;

[0174] The middle word weight of each search word in the search text segment is determined according to the target quantity and the word weight of each search word in the search text segment in the similar text.

[0175] The above technical scheme can determine the target relevance between two different target search statement texts in multiple pairs of texts to be stored by using the search term as the transmission, and determine the word weight of each search term in each target search statement text according to the target relevance, thereby determining the intermediate word weight of each search term in a search text segment of a preset length according to the word weight of each search term in each target search statement text, which can effectively improve the accuracy of the intermediate word weight, and since there is no need for manual labeling, the problem of high labor costs can be avoided. Since there is no need for multiple iterative calculations, the amount of calculation required in the process of generating word weights can be effectively reduced, which is beneficial to improving the efficiency of generating word weights.

[0176] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0177] The present disclosure also provides a computer-readable storage medium having computer program instructions stored thereon, and when the program instructions are executed by a processor, the steps of the method for generating word weights provided by the present disclosure are implemented.

[0178] Figure 5 5 is a block diagram of a device for generating word weights according to an exemplary embodiment. For example, the device 500 may be provided as a server. Figure 5 , the apparatus 500 includes a processing component 522, which further includes one or more processors, and a memory resource represented by a memory 532 for storing instructions executable by the processing component 522, such as an application. The application stored in the memory 532 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 522 is configured to execute instructions to perform the above-mentioned method for generating word weights.

[0179] The device 500 may also include a power supply component 526 configured to perform power management of the device 500, a wired or wireless network interface 550 configured to connect the device 500 to a network, and an input / output (I / O) interface 558. The device 500 may operate based on an operating system stored in the memory 532, such as Windows Server 2008. TM , Mac OS X TM , Unix TM ,Linux TM , FreeBSD TM or similar.

[0180] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the present disclosure. This application is intended to cover any variations, uses or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure. The specification and examples are to be considered as exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.

[0181] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims

1. A method for generating word weights, characterized in that: include: Obtaining a query statement input by a user, and performing word segmentation processing on the query statement to obtain a target statement text after word segmentation; Segmenting the target sentence text according to one or more preset segment division methods to obtain multiple text segments; According to the plurality of text segments, obtaining at least one target text segment and an intermediate word weight corresponding to each word in at least one of the target text segments from a preset corpus, wherein the at least one target text segment is a text segment in the preset corpus used to form the target sentence text with the least number of text segments; Determine the target word weight corresponding to each word in the target sentence text according to the intermediate word weight corresponding to each word in the target text segment; The preset corpus is generated in the following way: Acquire a target number of occurrences of each set of search text pairs within a preset historical time period from a user search record database, wherein the search text pairs include a search term and a target search statement text; The search text pairs whose target number of times is greater than or equal to a preset number of times threshold are used as the text pairs to be stored, so as to obtain a plurality of the text pairs to be stored; Determining, according to the search term, a target relevance between two different target search statement texts in the plurality of to-be-stored text pairs; Determining the word weight of each search word in each of the target search sentence texts according to the target relevance; Determining the middle word weight of each search word in the search text segment of a preset length according to the word weight of each search word in each target search sentence text; The search text segment and the middle word weight of each search word in the search text segment are stored in a preset database to generate the preset corpus.

2. The method according to claim 1, characterized in that The preset corpus includes a plurality of search text segments and an intermediate word weight of each search word in each of the search text segments. The step of acquiring at least one target text segment and an intermediate word weight corresponding to each word in at least one of the target text segments from the preset corpus according to the plurality of text segments includes: Acquire at least one pending text segment that matches the multiple search text segments in the preset corpus; Determining, from at least one of the pending text segments, a target text segment for forming the target sentence text with a minimum number of text segments; The middle word weight corresponding to each search word in the target text segment is obtained from the preset corpus to obtain the middle word weight corresponding to each word in the target text segment.

3. The method according to claim 1, characterized in that The step of determining the target word weight corresponding to each word in the target sentence text according to the intermediate word weight corresponding to each word in the target text segment includes: The intermediate word weight corresponding to each word in the target text segment is normalized to obtain the target word weight corresponding to each word in the target sentence text.

4. The method according to claim 1, characterized in that The step of determining the target relevance between two different target search statement texts in the plurality of to-be-stored text pairs according to the search term comprises: Obtaining the occurrence frequency of each search term in each target search statement text in the to-be-stored text pair; Determining a first correlation between each search term and the target search statement text, and a second correlation between the target search statement text and each search term, according to the occurrence frequency of each search term in the target search statement text; The relevance between different target search sentence texts is determined according to the first relevance and the second relevance.

5. The method according to claim 4, characterized in that The step of determining a first correlation between the search term and the target search statement text, and a second correlation between the target search statement text and each search term according to the occurrence frequency of each search term in the target search statement text, comprises: Generate a first matrix by taking the occurrence frequencies of different search terms in each of the target search sentence texts as column vectors; Normalizing the elements in the first matrix row by row to obtain a first correlation matrix; determining the first correlation according to the first correlation matrix; The frequency of each search word appearing in different target search sentence texts is used as a column vector to generate a second matrix; Normalizing the elements in the second matrix row by row to obtain a second correlation matrix; The second correlation is determined according to the second correlation matrix.

6. The method according to claim 5, characterized in that The determining the relevance between different target search sentence texts according to the first relevance and the second relevance includes: Obtain the product of the second correlation matrix and the first correlation matrix to obtain a third correlation matrix, wherein the element a in the third correlation matrix is ij Indicates i The target search sentence text and the j The relevance between target search sentence texts, where i , j are all positive integers; The correlation between different target search sentence texts is obtained through the third correlation matrix.

7. The method according to claim 1, characterized in that The step of determining the middle word weight of each search word in a search text segment of a preset length according to the word weight of each search word in each target search sentence text includes: Acquire similar text corresponding to the search text segment and the word weight of each search word in the search text segment in the similar text from a plurality of target search statement texts corresponding to the plurality of text pairs to be stored, wherein the similar text includes one or more search words in the search text segment; Get the target number of each similar text; The intermediate word weight of each search word in the search text segment is determined according to the target quantity and the word weight of each search word in the search text segment in the similar text.

8. A device for generating word weights, characterized in that: include: A first acquisition module is configured to acquire a query statement input by a user and perform word segmentation processing on the query statement to obtain a target statement text after word segmentation; A segmentation module is configured to segment the target sentence text according to one or more preset segment division methods to obtain multiple text segments; A second acquisition module is configured to acquire at least one target text segment and an intermediate word weight corresponding to each word in at least one target text segment from a preset corpus according to the plurality of text segments, wherein the at least one target text segment is a text segment in the preset corpus used to form the target sentence text with a minimum number of text segments; A determination module, configured to determine a target word weight corresponding to each word in the target sentence text according to an intermediate word weight corresponding to each word in the target text segment; The device further includes a preset corpus generation module, wherein the preset corpus generation module is configured to: Acquire a target number of occurrences of each set of search text pairs within a preset historical time period from a user search record database, wherein the search text pairs include a search term and a target search statement text; The search text pairs whose target number of times is greater than or equal to a preset number of times threshold are used as the text pairs to be stored, so as to obtain a plurality of the text pairs to be stored; Determining, according to the search term, a target relevance between two different target search statement texts in the plurality of to-be-stored text pairs; Determining the word weight of each search word in each of the target search sentence texts according to the target relevance; Determining the middle word weight of each search word in the search text segment of a preset length according to the word weight of each search word in each target search sentence text; The search text segment and the middle word weight of each search word in the search text segment are stored in a preset database to generate the preset corpus.

9. An electronic device, characterized in that: include: a memory having a computer program stored thereon; A processor, configured to execute the computer program in the memory to implement the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the program instructions are executed by a processor, the steps of the method described in any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Method and apparatus for determining search term weight values, and method and apparatus for generating search results.

    CN102289436A

  • Term weight generation method and device

    CN105653553A

  • A search term weight determination method and device

    CN109815396A

  • Text word segmentation method and device, equipment and medium

    CN111274353A