Method and device for determining keywords of text
By segmenting Chinese online texts and filtering features, the problem of keyword extraction in Chinese texts relying on corpora and single granularity is solved, achieving high-accuracy keyword and phrase extraction, which is suitable for multi-domain texts and reduces operation and maintenance. cost.
Patent Information
- Application Number
- CN202310138465.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-14
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2043-02-14
AI Technical Summary
Existing keyword extraction methods in Chinese online texts have problems such as relying on pre-constructed corpora, single granularity of output results, failure to utilize Chinese characteristics, and lack of post-processing processes, resulting in low accuracy and efficiency.
By segmenting the text to be processed, identifying candidates, and filtering based on filtering features such as stop words, redundancy, and semantic similarity, keywords are determined to avoid relying on pre-built corpora and support the extraction of keywords and phrases.
It realizes keyword extraction without pre-building a corpus, improves the semantic accuracy and efficiency of the results, is suitable for Chinese texts in multiple fields, and reduces operation and maintenance costs.
Smart Images

Figure CN116306616B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of text processing, and in particular to a method and device for determining keywords of a text. Background Art
[0002] Keyword extraction is a basic technology in the field of text processing. In today's era of information explosion, tens of thousands of text messages are generated on the Internet every day. Accurately extracting keywords from these online texts plays a vital role in the management and application of these online texts.
[0003] Existing keyword extraction methods can be roughly divided into supervised methods and unsupervised methods. Supervised methods can usually achieve good results in texts in the corresponding fields of their data sets, but they require a lot of manpower to annotate the data sets, and the effect will be significantly worse when applied to texts in fields that do not correspond to existing data sets. The corresponding information field in online texts is extensive and changes rapidly, so supervised methods are not suitable for keyword extraction from online texts. Typical unsupervised methods include TF-IDF and YAKE, both of which extract keywords by constructing statistical features of words in the text and have achieved good results. However, most of the current unsupervised keyword extraction methods still have the following limitations when applied to Chinese online texts.
[0004] Relying on pre-built corpus text libraries. Most unsupervised methods use statistical features similar to IDF, and the generation of such statistical features requires the pre-construction of a text corpus, which needs to be updated and maintained in a timely manner to maintain its accuracy. In the online text scenario, massive amounts of data are generated every day, and the collection, screening, storage, and update of these data require high maintenance costs.
[0005] The output result is a single word, not a phrase consisting of several words. Single words are often semantically broad, resulting in lower semantic accuracy than phrases, and cannot accurately describe the key information of the target text. For example, "loan" refers to various types of banking services, while "housing provident fund loan" clearly indicates the banking business of using housing provident funds for loans.
[0006] Keyword features were not designed based on the characteristics of Chinese text. Many keyword features in English cannot be applied to Chinese, such as judging keywords by whether they are capitalized or not, or whether they are word roots. Some effective text features in Chinese were not utilized, such as the number of characters in a keyword (a single character is almost impossible to be a keyword, and proper nouns with three or more characters are likely to be keywords), and the position of the keyword in the article (the keyword that appears at the beginning of the article may not be a keyword, but the keyword that echoes the beginning and the end is likely to be a keyword).
[0007] There is a lack of post-processing of the output results. The first is redundancy in the output format. It is possible that a certain keyword is included in another key phrase, or the two phrases are mostly overlapping, for example, "loan" and "provident fund loan" are output at the same time. The second is semantic redundancy. It is possible that two results with very similar meanings are output at the same time, for example, "agency" and "agency" are output at the same time. Finally, there is no confirmation whether the output keywords and the semantics of the article are consistent. For example, the article titled "How to make a will to leave the house to the children?" outputs the keyword "Xiao Ming". It is obvious that "Xiao Ming" is just a pseudonym that appears many times in the article and is mistaken for a keyword. It has nothing to do with the semantics of the entire article and cannot be used as a keyword. Summary of the invention
[0008] An object of the embodiments of the present invention is to provide a method and apparatus for determining keywords of a text, which can solve or at least partially solve the above problems.
[0009] In order to achieve the above-mentioned purpose, one aspect of an embodiment of the present invention provides a method for determining keywords of a text, the method comprising: splitting the text to be processed into at least one element by performing word segmentation on the text to be processed to obtain a word segmentation result list; determining candidate objects based on the elements in the word segmentation result list, wherein any of the candidate objects includes at least one element with a continuous position in the word segmentation result list; screening the candidate objects based on screening features, wherein the screening features include at least one of the following: whether they belong to a preset disabled element set, a score, output form redundancy between the candidate objects, semantic redundancy between the candidate objects, and semantic similarity between the candidate objects and the text to be processed, the score of any of the candidate objects reflecting the possibility of the candidate object becoming the keyword of the text to be processed; and determining the keyword of the text to be processed based on the screened candidate objects.
[0010] Correspondingly, another aspect of an embodiment of the present invention provides a device for determining keywords of a text, the device comprising: a word segmentation module, for splitting the text to be processed into at least one element by performing word segmentation on the text to be processed, so as to obtain a word segmentation result list; a candidate object determination module, for determining candidate objects based on the elements in the word segmentation result list, wherein any of the candidate objects includes at least one element with a continuous position in the word segmentation result list; a screening module, for screening the candidate objects based on screening features, wherein the screening features include at least one of the following: whether they belong to a preset disabled element set, a score, output form redundancy between the candidate objects, semantic redundancy between the candidate objects, and semantic similarity between the candidate objects and the text to be processed, the score of any of the candidate objects reflecting the possibility of the candidate object becoming the keyword of the text to be processed; and a keyword determination module, for determining the keyword of the text to be processed based on the screened candidate objects.
[0011] In addition, another aspect of an embodiment of the present invention further provides a machine-readable storage medium, on which instructions are stored, and the instructions are used to enable a machine to execute the above method.
[0012] In addition, another aspect of an embodiment of the present invention further provides a processor for running a program, wherein the program is used to execute the above method when being run.
[0013] In addition, another aspect of an embodiment of the present invention further provides a computer program product, including a computer program / instruction, which implements the above method when executed by a processor.
[0014] Through the above technical scheme, a segmentation result list is obtained by segmenting the text to be processed, candidate objects are determined based on the segmentation result list, the candidate objects are screened, and then the keywords of the text to be processed are determined. In this way, keywords can be determined based on the text to be processed without relying on a pre-built corpus text library; the candidate object includes at least one element, so when a certain keyword determined includes multiple elements, the determined keyword is no longer just a single word, which improves the accuracy of the determined keyword to more accurately describe the key information of the target text; when the candidate objects are screened based on the output form redundancy between the candidate objects and / or the semantic redundancy between the candidate objects and / or the semantic similarity between the candidate objects and the text to be processed, the output form redundancy between the candidate objects and / or the semantic redundancy between the candidate objects and / or the semantic similarity between the candidate objects and the text to be processed are considered when determining the keywords.
[0015] Other features and advantages of the embodiments of the present invention will be described in detail in the subsequent detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The accompanying drawings are used to provide a further understanding of the embodiments of the present invention and constitute a part of the specification. Together with the following specific implementations, they are used to explain the embodiments of the present invention, but do not constitute a limitation on the embodiments of the present invention. In the accompanying drawings:
[0017] Figure 1 is a flow chart of a method for determining keywords of a text provided by an embodiment of the present invention;
[0018] Figure 2 is a logic diagram of a method for determining keywords of a text provided by another embodiment of the present invention;
[0019] Figure 3 is a logical schematic diagram of screening candidate objects based on output form redundancy between candidate objects provided by another embodiment of the present invention;
[0020] Figure 4 is a logical schematic diagram for screening candidate objects based on semantic redundancy between candidate objects provided by another embodiment of the present invention; and
[0021] Figure 5 It is a structural block diagram of an apparatus for determining keywords of a text provided by another embodiment of the present invention.
[0022] Description of Reference Numerals
[0023] 1 Word segmentation module 2 Candidate object determination module
[0024] 3 Screening module 4 Keyword determination module DETAILED DESCRIPTION
[0025] The specific implementation of the embodiment of the present invention is described in detail below in conjunction with the accompanying drawings. It should be understood that the specific implementation described here is only used to illustrate and explain the embodiment of the present invention, and is not used to limit the embodiment of the present invention.
[0026] One aspect of an embodiment of the present invention provides a method for determining keywords of a text.
[0027] Figure 1 FIG. 1 is a flow chart of a method for determining keywords of a text provided by an embodiment of the present invention. Figure 1 As shown, the method includes the following contents.
[0028] In step S10, by performing word segmentation on the text to be processed, the text to be processed is split into at least one element to obtain a word segmentation result list. Wherein, the text to be processed is the text whose keywords need to be determined. Optionally, the text to be processed can be a Chinese text, an English text, or a network text. In addition, word segmentation refers to the reasonable segmentation of continuous text into language forms of smaller granularity such as single words, punctuation marks, words and idioms with practical significance, wherein these language forms of smaller granularity are the elements described in the embodiment of the present invention. Optionally, in the embodiment of the present invention, the word segmentation method can be an open source word segmentation tool, such as Hanlp, jieba. After word segmentation, a word segmentation result list will be obtained, in which the position of each element in the word segmentation result list is consistent with the position in the text to be processed, and the original text to be processed can be fully restored according to the word segmentation result list.
[0029] In step S11, based on the elements of the word segmentation result list, determine the candidate objects, wherein any candidate object includes at least one element whose position is continuous in the word segmentation result list. Optionally, the number of elements included in the candidate object may be preset, and then starting from the first element of the word segmentation result list, the elements in the word segmentation result list are divided, and the division is performed every preset number, so that each candidate object obtained by division includes a preset number of elements and the position of the elements is continuous. For example, the preset number is 2, and starting from the first element of the word segmentation result list, a candidate object is obtained by dividing every two elements. Optionally, the range of the number of elements included in the candidate object may also be preset, and for each value in the range, the elements in the word segmentation result list are divided starting from the first element in the word segmentation result list to obtain the candidate object. For example, the value range of the number is greater than or equal to 1 and less than or equal to 3, then for the numbers of 1, 2 and 3 respectively, the elements in the word segmentation result list are divided starting from the first element in the word segmentation result list. Specifically, when the number is 1, each element is divided once to obtain a candidate object; when the number is 2, every two elements are divided once to obtain a candidate object; when the number is 3, every three elements are divided once to obtain a candidate object. In the case of a preset number range, all candidate objects obtained by dividing all values within the range are determined candidate objects and participate in subsequent operations.
[0030] In step S12, the candidate objects are screened based on screening features, wherein the screening features include at least one of the following: whether they belong to a preset set of disabled elements, scores, output form redundancy between candidate objects, semantic redundancy between candidate objects, and semantic similarity between candidate objects and the text to be processed. The score of any candidate object reflects the possibility of the candidate object becoming a keyword of the text to be processed.
[0031] Among them, the preset stop elements are elements that are not desired to appear in the keywords, and can be set according to the specific situation. For example, the preset stop elements can be "basically", "how much", "generally", etc. The preset stop element set includes all pre-set preset stop elements. For example, a candidate object includes at least one element. For any candidate object, if the candidate object includes one or more preset stop elements, the candidate object belongs to the preset stop element set, and the candidate object is removed, and it cannot become a keyword of the text to be processed; only when all elements included in the candidate object are not preset stop elements, it is determined that the candidate object does not belong to the preset stop element set.
[0032] In addition, the output form redundancy between the candidate objects can be inclusion redundancy or overlapping redundancy. Among them, the existence of inclusion redundancy between two candidate objects means that the two candidate objects are in an inclusion relationship, that is, one candidate object includes all the elements of the other candidate object. For example, one candidate object is "Provident Fund Loan" and the other candidate object is "Loan". "Provident Fund Loan" contains "Loan". Therefore, "Provident Fund Loan" and "Loan" are in an inclusion relationship and there is inclusion redundancy. Specifically, it can be judged whether there is inclusion redundancy based on the string relationship. Specifically, it can be judged whether there is inclusion redundancy based on whether the candidate object with a short length is a substring of the candidate object with a long length, where the length refers to the number of characters included in the candidate object. In addition, the overlapping redundancy between the two candidate objects means that the two candidate objects are in an overlapping relationship, that is, the prefix element of one candidate object is the same as the suffix element of the other candidate object. For example, one candidate object is "Real Estate Project" and the other candidate object is "Project Surroundings". The suffix element of "Real Estate Project" and the prefix element of "Project Surroundings" are both "Project". Therefore, "Real Estate Project" and "Project Surroundings" are in an overlapping relationship and there is overlapping redundancy. For two candidate objects with overlapping redundancy, new words can be obtained by splicing them. For example, "real estate project" and "project surrounding" are spliced to obtain a new word "real estate project surrounding". For any two candidate objects, by judging whether there is a containment relationship or an overlapping relationship between the two candidate objects, it is judged whether there is containment redundancy or overlapping redundancy between the two candidate objects, thereby judging whether there is output form redundancy between the two candidate objects. Among them, for the coincidence relationship, the following content can be used for judgment. For candidate A and candidate B, the lengths are SA and SB respectively, the length of the spliced word is S, and the length ratio before and after splicing is: ratio = S / (SA+SB). When the ratio is greater than 0.35, there is an overlap relationship between candidate A and candidate B; otherwise, there is no overlap relationship. Among them, the length refers to the number of characters included. For example, if there is containment redundancy between the two candidate objects, the candidate with a shorter length is eliminated; if there is overlapping redundancy between the two candidate objects, the two candidate objects are eliminated and replaced with the content obtained by splicing the two candidate objects.
[0033] In addition, the semantic redundancy between candidate objects refers to the semantic similarity or identity between two candidate objects. Optionally, the following content can be used to determine whether there is semantic redundancy between any two candidate objects. The two candidate objects are represented as semantic vectors, for example, the candidate objects are represented as semantic vectors using an Embedding model. The semantic similarity between the two candidate objects is calculated based on the semantic vector, for example, the cosine distance or Euclidean distance is used to represent the semantic similarity between the two candidate objects. The calculated semantic similarity is compared with a preset candidate object semantic similarity threshold. If the calculated semantic similarity does not reach the candidate object semantic similarity threshold, it means that there is no similarity or identity between the two candidate objects, and there is no semantic redundancy; if the calculated semantic similarity reaches the candidate object semantic similarity threshold, it means that there is similarity or identity between the two candidate objects, and there is semantic redundancy. For example, if there is semantic redundancy between the two candidate objects, the candidate object with a larger semantic similarity to the text to be processed is retained, wherein the calculation of the semantic similarity between the candidate object and the text to be processed can refer to the semantic similarity between the candidate object and the candidate object.
[0034] In addition, the semantic similarity between the candidate object and the text to be processed reflects the degree of semantic similarity between the candidate object and the text to be processed. The higher the semantic similarity, the higher the accuracy of the candidate object. Optionally, the semantic similarity between a candidate object and the text to be processed can be determined by the following content. The semantic vectors corresponding to the candidate object and the text to be processed are calculated respectively, for example, the semantic vectors corresponding to the candidate object and the text to be processed are calculated using the Embedding model. The semantic similarity between the candidate object and the text to be processed is calculated, for example, the cosine distance or the Euclidean distance is used to represent the semantic similarity between the candidate object and the text to be processed. For example, a preset semantic similarity threshold is set in advance, and the candidate objects whose semantic similarity with the text to be processed does not reach the preset semantic similarity threshold are eliminated.
[0035] For screening candidate objects by using scores, the objects to be screened may be sorted by using the scores, and candidate objects ranked at the front of a preset value may be selected; in addition, a threshold of the score may be set, and candidate objects whose scores reach the threshold may be selected.
[0036] Optionally, in an embodiment of the present invention, when the screening feature includes multiple contents, the screening of candidate objects between the multiple contents can be performed sequentially. For example, the screening features include the output form redundancy of the candidate object quality inspection form, the semantic redundancy between the candidate objects, and the semantic similarity between the candidate objects and the text to be processed. The candidate objects can be screened according to the following order: first, screening is performed according to the output form redundancy of the candidate object quality inspection form, then screening is performed according to the semantic redundancy between the candidate objects, and then screening is performed according to the semantic similarity between the candidate objects and the text to be processed.
[0037] In step S13, based on the candidate objects obtained through screening, the keywords of the text to be processed are determined. Optionally, the candidate objects obtained through screening are the keywords of the text to be processed. Optionally, a preset number of required keywords may be pre-set, and a preset number of candidate objects may be randomly selected from the keywords obtained through screening as the keywords of the text to be processed; or the candidate objects obtained through screening may be sorted based on the scores, and the candidate objects in the first preset number of positions may be selected as the keywords of the text to be processed.
[0038] Through the above technical scheme, a segmentation result list is obtained by segmenting the text to be processed, candidate objects are determined based on the segmentation result list, the candidate objects are screened, and then the keywords of the text to be processed are determined. In this way, keywords can be determined based on the text to be processed without relying on a pre-built corpus text library; the candidate object includes at least one element, so when a certain keyword determined includes multiple elements, the determined keyword is no longer just a single word, which improves the accuracy of the determined keyword to more accurately describe the key information of the target text; when the candidate objects are screened based on the output form redundancy between the candidate objects and / or the semantic redundancy between the candidate objects and / or the semantic similarity between the candidate objects and the text to be processed, the output form redundancy between the candidate objects and / or the semantic redundancy between the candidate objects and / or the semantic similarity between the candidate objects and the text to be processed are considered when determining the keywords.
[0039] Optionally, in an embodiment of the present invention, screening candidate objects based on output form redundancy between candidate objects may include the following contents. Step 1: Establish a first candidate object set for candidate objects that will be screened based on output form redundancy between candidate objects. The candidate objects that will be screened based on output form redundancy between candidate objects may be candidate objects that have been screened based on part of the content included in the screening feature, or may be all candidate objects that have not been screened and are determined based on the elements in the word segmentation result list. Step 2: Determine formal redundancy comparison candidate objects and delete the formal redundancy comparison candidate objects from the first candidate object set, wherein the formal redundancy comparison candidate objects are the candidate objects with the largest length in the first candidate object set. The length of the candidate object is the number of characters included in the candidate object. Step 3: for each candidate object remaining in the first candidate object set, perform the following operations: determine whether there is output form redundancy between the candidate object being targeted and the candidate object for formal redundancy comparison, wherein how to determine whether there is output form redundancy can refer to the contents described in the above embodiments; in the case of output form redundancy, determine the screening candidate object according to the first preset rule, update the formal redundancy comparison candidate object based on the screening candidate object, and delete the candidate object being targeted from the first candidate object set; in the case of no output form redundancy, delete the candidate object being targeted from the first candidate object set and save it to the third candidate object set. Wherein, updating the formal redundancy comparison candidate object based on the screening candidate object is to replace the formal redundancy comparison candidate object with the screening candidate object, thereby updating the formal redundancy comparison candidate object. It should be noted that in step 3, when there is output form redundancy, the formal redundancy comparison candidate object will be updated, but the formal redundancy comparison candidate object will still be used for description in the following description, but the use of the formal redundancy comparison candidate object for description does not mean that it has not been updated, and it is necessary to understand whether the formal redundancy comparison candidate object used has been updated based on whether there is output form redundancy. Step 4: Save the formal redundancy comparison candidate objects to the second candidate object set. In step 3, compare the formal redundancy comparison candidate objects determined in step 2 with each remaining candidate object in the first candidate object set to screen the candidate objects in the first candidate object set. Finally, save the formal redundancy comparison candidate objects obtained after step 3 to the second candidate object set. The formal redundancy comparison candidate objects obtained after step 3 are updates of the formal redundancy comparison candidate objects determined in step 2, or they may not be updated, depending on whether there is output formal redundancy when screening each remaining candidate object in the first candidate object set. Step 5: Copy the candidate objects in the third candidate object set to the first candidate object set and clear the third candidate object set.Step 6: Determine whether the first candidate object set is empty. Step 7: When the first candidate object set is not empty, repeat steps 2 to 6 until the first candidate object set is empty, wherein the formal redundancy comparison candidate objects in the second candidate object set are candidate objects screened based on the output formal redundancy between the candidate objects. Optionally, in an embodiment of the present invention, the first preset rule may include the following contents. When the output formal redundancy is included redundancy, the screened candidate objects are redundant comparison candidate objects; and / or when the output formal redundancy is overlapping redundancy, the screened candidate objects are objects obtained by splicing the redundant comparison candidate objects with the targeted candidate objects.
[0040] Optionally, in an embodiment of the present invention, screening candidate objects based on semantic redundancy between candidate objects may include the following contents. Step 8: Establish a fourth candidate object set for the candidate objects to be screened based on semantic redundancy between candidate objects. The candidate objects to be screened based on semantic redundancy between candidate objects may be candidate objects that have been screened based on part of the content included in the screening feature, or may be all candidate objects that have not been screened and are determined based on the elements in the word segmentation result list. Step 9: Determine semantic redundancy comparison candidate objects and delete the semantic redundancy comparison candidate objects from the fourth candidate object set, wherein the semantic redundancy comparison candidate objects are the candidate objects in the fourth candidate object set with the greatest semantic similarity with the text to be processed. Specifically, the semantic similarity between the candidate object and the text to be processed may be calculated with reference to the contents described in the above embodiments. Step 10: For each candidate object remaining in the fourth candidate object set, perform the following operations: determine whether there is semantic redundancy between the candidate object being targeted and the semantic redundancy comparison candidate object. Specifically, the method described in the above embodiment can be referred to to determine whether there is semantic redundancy; if there is semantic redundancy, delete the candidate object being targeted from the fourth candidate object set; if there is no semantic redundancy, delete the candidate object being targeted from the fourth candidate object set and save it in the sixth candidate object set. Step 11: Save the semantic redundancy comparison candidate object in the fifth candidate object set. In step 10, the semantic redundancy comparison candidate object determined in step 9 is compared with each candidate object remaining in the fourth candidate object set to screen the candidate objects in the fourth candidate object set, and finally the semantic redundancy comparison candidate object determined in step 9 is saved in the fifth candidate object set. Step 12: Copy the candidate objects in the sixth candidate object set to the fourth candidate object set and clear the sixth candidate object set. Step 13: Determine whether the fourth candidate object set is empty. Step 14: When the fourth candidate object set is not empty, repeat steps 9 to 13 until the fourth candidate object set is empty, wherein the semantic redundancy comparison candidate objects in the fifth candidate object set are the candidate objects screened based on the semantic redundancy between the candidate objects.
[0041] Optionally, in an embodiment of the present invention, screening candidate objects based on the semantic similarity between candidate objects and the text to be processed may include the following. For any candidate object to be screened based on the semantic similarity between candidate objects and the text to be processed, the semantic similarity between the candidate object to be screened and the text to be processed is calculated, and specifically, the semantic similarity between the candidate object to be screened and the text to be processed can be calculated with reference to the method described in the above embodiment. Wherein, the candidate object to be screened based on the semantic similarity between the candidate object and the text to be processed can be a candidate object that has been screened based on the partial content included in the screening feature, or can be all candidate objects that have not been screened and determined based on the elements in the word segmentation result list. Based on the calculated semantic similarity, the candidate objects to be screened are screened, and the candidate objects to be screened whose semantic similarity does not reach the preset semantic similarity threshold are eliminated, and the candidate objects to be screened whose semantic similarity reaches the preset semantic similarity threshold are retained, and the candidate objects to be screened whose semantic similarity reaches the preset semantic similarity threshold are the candidate objects screened based on the semantic similarity between the candidate object and the text to be processed.
[0042] Optionally, in an embodiment of the present invention, for any candidate object, determining the score may include the following. Determine the title score and / or text score corresponding to the candidate object based on the score determination feature of the candidate object, wherein, for any candidate object, the score determination feature includes at least one of the following: the first number, the second number, the position weight of the candidate object, the length of the candidate object, and the number of elements included in the candidate object, wherein the first number represents the number of times the candidate object appears in the title of the text to be processed, and the second number represents the number of times the candidate object appears in the text of the text to be processed. In addition, the position weight of the candidate object represents the weight corresponding to the position of the candidate object in the text compared with the entire text. For example, the position weight may include a first position weight corresponding to the proportion of the position of the candidate object in the text for the first time to the full text length of the text and a second position weight corresponding to the proportion of the position span of the candidate object in the text to the full text length. The length of the candidate object refers to the number of characters included in the candidate object, and the full text length of the text refers to the total number of characters included in the text. In addition, the title score refers to the score determined for the candidate object to appear in the title, and the text score refers to the score determined for the candidate object to appear in the text. The score is determined based on the title score and / or text score corresponding to the candidate object. For example, in the case of only the title score, the title score is the determined score; in the case of only the text score, the text score is the determined score; in the case of both the title score and the text score, the score can be determined by summing the title score and the text score or weighted summing them. In this way, by determining the score based on the position weight and length and other features of the candidate object, and then filtering the candidate objects based on the score, the features of the final keywords are optimized, and the accuracy of the obtained keywords is improved.
[0043] Optionally, in the embodiment of the present invention, for any candidate object, determining the title score includes determining based on the following formula: Score title =1.5*TF1*log2(M+1)*log2(P / 2*M+0.5), where Score title Indicates the title score, TF1 indicates the first number, M indicates the number, and P indicates the length. In addition, in this calculation formula, 1.5 indicates the score coefficient of the title candidate, because the content in the title is more likely to become a keyword than the content in the text.
[0044] Optionally, in an embodiment of the present invention, the position weight of the candidate object includes a first position weight corresponding to a ratio of the position of the first appearance of the candidate object in the text to the full text length and a second position weight corresponding to a ratio of the position span of the candidate object in the text to the full text length. For any candidate object, determining the text score includes determining based on the following formula: Score content=TF2*log2(M+1)*log2(OP / 2*M+0.5)*(W front +W range ), where Score content represents the text score, TF2 represents the second number, M represents the number, P represents the length, W front represents the first position weight, W range Represents the second position weight.
[0045] Optionally, in the embodiment of the present invention, for any candidate object, the calculation formula of the first position weight is: Among them, L first The position index of the first occurrence of the candidate object in the text, L total Indicates the full length of the text. The position index of the first occurrence of the candidate object in the text refers to the number of characters before the first occurrence of the candidate object; the full length of the text refers to the total number of characters in the text.
[0046] Optionally, in the embodiment of the present invention, for any candidate object, the calculation formula of the second position weight is: range =2*L range / L total , where L range represents the position span of the candidate object in the text, that is, the position index of the last occurrence minus the position index of the first occurrence to get the result. Obviously, when a candidate object only appears once in the text, W range =0.
[0047] Optionally, in an embodiment of the present invention, before the candidate object is screened based on the screening feature, the method may further include the following contents. The elements in the word segmentation result list are marked with parts of speech, wherein the screening feature also includes at least one of the following: whether it belongs to a preset basic part of speech set and whether it belongs to a preset boundary part of speech set. Among them, the preset basic part of speech is pre-set and can be flexibly adjusted according to different application scenarios, and is for elements; the preset basic part of speech set includes all pre-set preset basic parts of speech. For example, the preset basic part of speech can be punctuation, auxiliary words, numerals, interjections, pronouns, etc. The candidate object includes at least one element. For any candidate object, only when all elements included in the candidate object do not belong to the preset basic part of speech set, the candidate object is determined not to belong to the preset basic part of speech set. Candidate objects that are determined not to belong to the preset basic part of speech set can be retained after screening and may become keywords of the text to be processed. The preset boundary part of speech is also pre-set and can be flexibly adjusted according to different application scenarios. It is also for elements, but the preset boundary part of speech is specifically used for elements on the boundary when judging. For example, the preset boundary part of speech can be an adverb, a conjunction, a preposition, etc. The preset boundary part of speech set includes all preset boundary parts of speech. For example, a candidate object is composed of element 1, element 2 and element 3, and the composition order is also element 1, element 2 and element 3, then element 1 is the left boundary of the candidate object, and element 3 is the right boundary of the candidate object. For any candidate object, only when the part of speech of the left boundary element and the part of speech of the right boundary element of the candidate object do not belong to the preset boundary part of speech set, the candidate object is determined to be not belonging to the preset boundary part of speech set. Candidate objects that are determined not to belong to the preset boundary part of speech set can be retained after screening and may become keywords of the text to be processed. Optionally, in an embodiment of the present invention, the left boundary part of speech can be distinguished from the right boundary part of speech, and the preset boundary part of speech set includes a preset left boundary part of speech set and a preset right boundary part of speech set. The preset left boundary part of speech set includes the part of speech set for the left boundary of the candidate object, and the preset right boundary part of speech set includes the part of speech set for the right boundary of the candidate object. When judging whether a candidate object belongs to the preset boundary part-of-speech set, the part-of-speech of the left boundary of the candidate object is compared with the preset left boundary part-of-speech in the preset left boundary part-of-speech set, and the part-of-speech of the right boundary of the candidate object is compared with the preset right boundary part-of-speech in the preset right boundary part-of-speech set. Only when the part-of-speech of the left boundary element of the candidate object does not belong to the preset left boundary part-of-speech set and the part-of-speech of the right boundary element does not belong to the preset right boundary part-of-speech set, the candidate object is determined not to belong to the preset boundary part-of-speech set. By dividing the preset boundary part-of-speech set into the preset left boundary part-of-speech set and the preset right boundary part-of-speech set, the candidate objects obtained by screening can be made more accurate, and the accuracy of the obtained keywords can be improved.
[0048] Figure 2 FIG. 1 is a logic diagram of a method for determining keywords of a text provided by another embodiment of the present invention. Figure 2 An exemplary introduction is given to the method for determining keywords of a text provided in an embodiment of the present invention. In this embodiment, an exemplary introduction is given by taking Chinese network text as an example. In brief, the method mainly includes the following contents. First, obtain the Chinese network text to be processed and the number N of target keywords. Then, the Chinese network text to be processed is processed by word segmentation and part-of-speech tagging; candidate objects are screened out based on the results of word segmentation and part-of-speech tagging to generate a first candidate object set. For each candidate object in the first candidate object set, its word frequency and word position features are extracted, and scored based on word frequency and word position; after sorting according to the scoring results, the Top 2N candidate objects are obtained to generate a second candidate object set. Post-processing is performed on the candidate objects in the second candidate object set, which mainly includes three steps: reducing output form redundancy, reducing semantic redundancy, and improving semantic accuracy. The Top N is obtained from the candidate objects after the post-processing results as the final keyword output result. The following is combined with Figure 2 Give a detailed introduction.
[0049] First, obtain the Chinese network text to be processed and the number of target keywords N to be extracted. The Chinese network text to be processed includes two parts: the title and the body, and the character encoding format is "UTF-8". The number of target keywords N represents the number of keywords that need to be extracted from the current Chinese network text, generally 3≤N≤10. The size of N can be set according to the specific situation, and there is no limit on this.
[0050] Secondly, the Chinese network text to be processed is subjected to word segmentation and part-of-speech tagging operations. Word segmentation refers to the reasonable segmentation of continuous text into smaller-granularity language forms such as individual characters, punctuation marks, words and idioms with practical significance, wherein these smaller-granularity language forms are the elements described in the embodiments of the present invention; the word segmentation method generally adopts an open source word segmentation tool, such as: Hanlp, jieba; after word segmentation, a word list (equivalent to the word segmentation result list described in the embodiments of the present invention) will be obtained, and the original text can be completely restored according to the word list. Part-of-speech tagging refers to adding a part-of-speech tag to each element in the word list after the word segmentation result, such as using the Hanlp tool for tagging, wherein the tag symbol is "w". After part-of-speech tagging, a part-of-speech list will be obtained. The length of the word list and the part-of-speech list are equal, and the elements and parts of speech in the two lists correspond one-to-one through the position index in the list.
[0051] Again, based on the results of word segmentation and part-of-speech tagging, candidate objects are generated. Among them, candidate objects include candidate keywords and candidate key phrases. The generation processes of candidate keywords and candidate key phrases are independent of each other and only rely on the results of word segmentation and part-of-speech tagging; keywords only include one element, and key phrases include multiple elements. M elements with consecutive positions are extracted from the word list obtained after word segmentation as a candidate object: when M=1, the candidate object is called a candidate keyword; when M≥2, the candidate object is called a candidate key phrase. The value of M is pre-set, and for each M value in the range, the operation of extracting candidate objects is performed to obtain candidate objects.
[0052] Fourth, the candidate objects are screened according to whether they belong to the preset stop element set, whether they belong to the preset basic part-of-speech set, and whether they belong to the preset boundary part-of-speech set, and a first candidate object set is generated. Specifically, the candidate objects can be screened in the following order: whether they belong to the preset stop element set, whether they belong to the preset basic part-of-speech set, and whether they belong to the preset boundary part-of-speech set. The preset stop word set is obtained by manual summary, and the elements included may include "basically", "how much", "generally", etc. The preset basic part-of-speech set can be flexibly adjusted according to different application scenarios, and can usually include punctuation marks, auxiliary words, numerals, interjections, pronouns, etc. The preset boundary part-of-speech set is further divided into a preset left boundary part-of-speech set and a preset right boundary part-of-speech set. The preset left and right boundary part-of-speech sets are usually different, and can also be flexibly adjusted according to different application scenarios. Usually, the preset boundary part-of-speech set can include adverbs, conjunctions, prepositions, etc. Judging whether any candidate object belongs to the preset stop element set refers to judging whether the elements included in the candidate object can completely match any preset stop element in the preset stop element set, that is, judging whether there is at least one element in the M elements included in the candidate object that belongs to the preset stop element set; when there is at least one element in the candidate object that belongs to the preset stop element set, the candidate object belongs to the preset stop element set and is screened out; only when all elements included in the candidate object do not belong to the preset stop element set, can the candidate object be included and subsequent operations be performed. Whether the candidate object belongs to the preset basic part-of-speech set refers to when any element of the candidate object does not belong to the preset basic part-of-speech set, the current candidate object does not belong to the preset basic part-of-speech set, otherwise the current candidate object belongs to the basic part-of-speech set. Whether it belongs to the preset boundary part-of-speech set includes two parts: whether it belongs to the preset left boundary part-of-speech set and whether it belongs to the preset right boundary part-of-speech set. Only when it does not belong to the preset left and right boundary part-of-speech sets, it is considered not to belong to the preset boundary part-of-speech set, otherwise it belongs to the boundary part-of-speech set. When M=1, the left and right boundaries of the candidate object are both the candidate object itself; when M≥2, the left boundary of the candidate object represents the first element of the candidate object, and the right boundary of the candidate object represents the last element of the candidate object. In particular, the purpose of distinguishing between the preset basic part-of-speech set and the preset boundary part-of-speech set in the above method is that when M=3, the middle elements of the candidate object only need to be judged by the preset stop word set and the preset basic part-of-speech set, that is, when M>2, elements belonging to the preset boundary part-of-speech set are allowed to appear in the candidate results. Optionally, comparison is used to determine whether the candidate object belongs to the preset stop element set, the preset basic part-of-speech set, and the preset boundary part-of-speech set.
[0053] Fifth, for candidate objects that neither belong to the preset stop element set, nor to the preset basic part-of-speech set, nor to the preset boundary part-of-speech set, candidate operations are performed. Features such as word frequency and word position of the candidate keywords are extracted and scored, that is, the determination score described in the above embodiment. Specifically, the word frequency includes the first number and the second number described in the above embodiment. The word position feature includes the first position weight and the second position weight described in the above embodiment. In addition, when scoring, it is also based on the following contents: the length of the candidate object, the number of elements included in the candidate object (M value). Among them, in this step, for any candidate object, the title score and the text score are determined respectively. Specifically, the title score and the text score can be determined with reference to the calculation formula described in the above embodiment. Then, for any candidate object, the final score is obtained by adding the title score and the text score.
[0054] Sixth, the candidate objects and their scores are sorted from largest to smallest, and the first 2N candidate objects are selected to generate a second candidate object set.
[0055] Seventh, post-processing measures are performed on the second candidate object set to remove output form redundancy and semantic redundancy, and improve semantic accuracy, that is, to reduce the output form redundancy and semantic redundancy of the result, and improve semantic accuracy. Among them, reducing output form redundancy means screening according to the output form redundancy between candidate objects, reducing semantic redundancy means screening according to the semantic redundancy between candidate objects, and improving semantic accuracy means screening according to the semantic similarity between candidate objects and the text to be processed. Specifically, for the candidate objects in the second candidate object set, post-processing is performed according to the following screening order: reducing output redundancy, reducing semantic redundancy and improving semantic accuracy. Finally, the set of candidate objects after post-processing is output. In an embodiment of the present invention, it is more reasonable to perform post-processing in the order of reducing output form redundancy, reducing semantic redundancy and improving semantic accuracy, and the candidate objects are screened from the literal meaning to the semantic meaning to the similarity with the whole article, from the shallow to the deep, so that the accuracy of the screened candidate objects will be better, and the accuracy of the keywords finally obtained will be improved.
[0056] Among them, the output form redundancy between candidate objects is mainly divided into two types. One is that there is an inclusion relationship between candidate objects, that is, there is inclusion redundancy; the other is that there is an overlapping relationship between candidate objects, that is, there is overlapping redundancy. Figure 3This is a logical diagram of screening candidate objects based on output form redundancy between candidate objects provided by another embodiment of the present invention. The overall greedy idea is adopted, and a candidate object W1 with the largest string length is selected each time, and then the remaining candidate objects in the candidate set are traversed to determine whether there is output form redundancy with W1: if there is redundancy, the score value (score value) of W1 is updated (the maximum value between the score of W1 and the score of the candidate object is taken), and this candidate object is deleted from the candidate object set; if there is no redundancy, it is retained and enters the next round of processing flow.
[0057] Specifically, combined Figure 3 An exemplary introduction is given to how to screen candidate objects based on the output form redundancy between candidate objects. A first candidate object set C1(n) is given, wherein the first candidate object set is established for candidate objects to be screened based on the output form redundancy between candidate objects. When reducing the output form redundancy for the first time, the candidate objects in the set C1(n) are the candidate objects in the above-mentioned second candidate object set. Create a second candidate object set R1(n). Determine whether the set C1(n) is empty. If so, the candidate objects in the set R1(n) are post-processed candidate objects, that is, candidate objects obtained by screening by reducing the output form redundancy. If not, create a third candidate object set T1(n). Sort the candidate objects in the set C1(n) according to the length index, and select the first candidate object ranked first as W1, and delete W1 from the set C1(n), wherein the length index is the number of characters included in the candidate object. Traverse the remaining candidate objects in the C1(n) set, that is, for the remaining candidate objects in the set C1(n) except W1, perform the following, wherein for any traversed candidate object: determine whether there is output form redundancy between the candidate object and W1, specifically, refer to the method described in the above embodiment; if there is inclusion redundancy, delete the currently traversed candidate object; if there is overlapping redundancy, splice the two candidate objects and replace W1 with the spliced candidate object; regardless of inclusion redundancy or overlapping redundancy, update the weight of W1, the weight described here is the score value, and update the weight of W1 to the maximum between the score value of W1 and the score value of the currently traversed candidate object; if there is no output form redundancy, save the currently traversed candidate object and its weight to the set T1(n). Save W1 and its weight to the set R1(n), copy the content in the set T1(n) to the set C1(n), and the set T1(n) becomes empty. Then return to determine whether the set C1(n) is empty, and repeat the candidate operations for the set C1(n) that is determined not to be empty, until the set C1(n) is empty. The candidate objects in the set R1(n) are the candidate objects obtained by reducing the redundancy of the output form.
[0058] In addition, the semantic redundancy of candidate objects refers to the high semantic similarity between candidate objects, that is, there is semantic redundancy. Figure 4 The figure shows a logical diagram for screening candidate objects based on semantic redundancy between candidate objects. The greedy idea is adopted as a whole. First, a pre-trained Embedding model is used to represent the candidate objects and the Chinese network text to be processed as semantic vectors, and the semantic similarity between the candidate objects and the Chinese network text is calculated using the cosine distance. Then, a candidate object W2 that is closest to the semantics of the Chinese network text is selected each time, and then the remaining candidate objects in the candidate set and W2 are traversed to see if there is semantic redundancy: if there is semantic redundancy, the weight value of W2 is updated (the sum of the score value of W and the score value of the candidate object is taken), and this candidate object is deleted from the candidate object set; if there is no semantic redundancy, it is retained and enters the next round of processing.
[0059] Specifically, refer to Figure 4, an exemplary introduction is given to how to screen candidate objects based on semantic redundancy between candidate objects. Given a fourth candidate object set C2(n), wherein the fourth candidate object set is established for candidate objects that will be screened based on semantic redundancy between candidate objects. In this embodiment, when semantic redundancy is reduced for the first time, the candidate objects in the set C2(n) are the candidate objects in the set R1(n) obtained after reducing the redundancy of the output form. Create a fifth candidate object set R2(n). Obtain the semantic vector of the text to be processed and the semantic vector of each candidate object through a pre-trained Embedding model. Determine whether the set C2(n) is empty. If so, the candidate objects in the set R2(n) are post-processed candidate objects, that is, candidate objects obtained by screening by reducing semantic redundancy. If not, create a sixth candidate object set T2(n). The candidate objects in the set C2(n) are sorted according to the semantic similarity index between the candidate objects and the text to be processed (specifically, how to calculate the semantic similarity between the candidate objects and the text to be processed can refer to the method described in the above embodiment), and the first candidate object ranked first is selected as W2, and W2 is deleted from the set C2(n). The remaining candidate objects in the set C2(n) are traversed, that is, the following contents are executed for the remaining candidate objects in the set C2(n) except W2, wherein for any traversed candidate object: determine whether there is semantic redundancy between the candidate object and W2, specifically, refer to the method described in the above embodiment; if there is semantic redundancy, delete the currently traversed candidate object, and update the weight of W2, the weight described here is also the score value, and update the weight of W2 to the sum of the score value of W2 and the score value of the currently traversed candidate object; if there is no semantic redundancy, save the currently traversed candidate object and its weight to the set T2(n). Save W2 and its weight to set R2(n), copy the content of set T2(n) to set C2(n), and set T2(n) becomes empty. Then return to determine whether set C2(n) is empty, and repeat the candidate operation of set C2(n) that is determined not to be empty until set C2(n) is empty. The candidate objects in set R2(n) are the candidate objects obtained by reducing semantic redundancy.
[0060] In addition, the semantic accuracy of the candidate object refers to the degree of semantic similarity between the candidate object and the Chinese network text to be processed. The higher the similarity, the more accurate the candidate object is. First, the semantic vectors of the candidate object and the Chinese network text to be processed are calculated through a pre-trained Embedding model, and then the cosine distance value between the semantic vectors of the candidate object and the Chinese network text to be processed is calculated to measure the semantic similarity between the candidate object and the Chinese network text to be processed. When the semantic similarity does not reach the preset semantic similarity threshold, it is directly deleted from the candidate object set. Among them, in this embodiment, the candidate object set described here is a set of candidate objects obtained after reducing semantic redundancy.
[0061] Eighth, for the candidate objects in the candidate object set obtained after post-processing, sort them from large to small according to the score, and select the first N as the final keyword extraction results.
[0062] From the above content, it can be seen that the technical solution provided by the embodiments of the present invention solves the following problems: 1) dependence on a pre-constructed corpus text library and its update and maintenance; 2) the granularity of the output results only supports a single word, rather than a phrase composed of several words; 3) keyword features are not designed based on the characteristics of Chinese text; 4) there is a lack of post-processing process for the algorithm output results.
[0063] In the technical solution provided by the embodiment of the present invention, a method for extracting keywords from Chinese network text is provided, which specifically has the following beneficial effects: 1) In order to eliminate the dependence of the method on the corpus text library, the use of keyword features represented by IDF that rely on a pre-built expected text library is abandoned, and the keyword extraction task can be completed only based on the current text, which can be flexibly applied to texts in various fields; 2) In order to support the simultaneous output of keywords and key phrases, a keyword filtering method and a key phrase generation method based on word parts of speech are proposed, and the extraction of keywords and the extraction of key phrases are completely independent of each other, and the output key phrases can greatly improve the semantic accuracy of the results; 3) In order to optimize the keyword features of Chinese text, a series of keyword features for Chinese are proposed. On the basis of TF features, the weights of candidate objects are adjusted by combining features such as candidate object length and candidate object position to improve the accuracy of keywords, where TF features refer to the number of times a candidate object appears in the text; 4) In order to optimize the output results, a series of candidate object post-processing methods are proposed, including three measures: reducing output form redundancy, reducing semantic redundancy, and improving semantic consistency between keywords and articles.
[0064] Accordingly, another aspect of an embodiment of the present invention provides an apparatus for determining keywords of a text.
[0065] Figure 5FIG. 1 is a structural block diagram of an apparatus for determining keywords of a text provided by another embodiment of the present invention. Figure 5 As shown, the device includes a word segmentation module 1, a candidate object determination module 2, a screening module 4 and a keyword determination module 4. The word segmentation module 1 is used to segment the text to be processed into at least one element to obtain a word segmentation result list; the candidate object determination module 2 is used to determine the candidate objects based on the elements in the word segmentation result list, wherein any candidate object includes at least one element in a continuous position in the word segmentation result list; the screening module 3 is used to screen the candidate objects based on the screening features, wherein the screening features include at least one of the following: whether they belong to a preset disabled element set, a score, output form redundancy between candidate objects, semantic redundancy between candidate objects, and semantic similarity between candidate objects and the text to be processed, and the score of any candidate object reflects the possibility that the candidate object becomes a keyword of the text to be processed; the keyword determination module 4 is used to determine the keywords of the text to be processed based on the candidate objects obtained by screening.
[0066] Optionally, in an embodiment of the present invention, the screening module screens candidate objects based on output form redundancy between candidate objects, including: step 1: establishing a first candidate object set for candidate objects to be screened based on output form redundancy between candidate objects; step 2: determining form redundancy comparison candidate objects and deleting the form redundancy comparison candidate objects from the first candidate object set, wherein the form redundancy comparison candidate objects are the candidate objects with the largest length in the first candidate object set; step 3: for each candidate object remaining in the first candidate object set, performing the following operations: determining whether there is output form redundancy between the candidate object being targeted and the form redundancy comparison candidate objects; in the case of output form redundancy, determining the screening candidate objects according to the first preset rule, and updating the screening candidate objects based on the screening candidate objects. Formal redundancy comparison candidate objects, delete the targeted candidate objects from the first candidate object set; in the case where there is no output formal redundancy, delete the targeted candidate objects from the first candidate object set and save them in the third candidate object set; step 4: save the formal redundancy comparison candidate objects to the second candidate object set; step 5: copy the candidate objects in the third candidate object set to the first candidate object set and clear the third candidate object set; step 6: determine whether the first candidate object set is empty; and step 7: if the first candidate object set is not empty, repeat steps 2 to 6 until the first candidate object set is empty, wherein the formal redundancy comparison candidate objects in the second candidate object set are the candidate objects screened based on the output formal redundancy between the candidate objects.
[0067] Optionally, in an embodiment of the present invention, the first preset rule includes: when the output form redundancy is including redundancy, the screening candidate object is the redundant comparison candidate object; and / or when the output form redundancy is overlapping redundancy, the screening candidate object is the object obtained by splicing the redundant comparison candidate object and the targeted candidate object.
[0068] Optionally, in an embodiment of the present invention, the screening module screens the candidate objects based on the semantic redundancy between the candidate objects, including: step 8: establishing a fourth candidate object set for the candidate objects to be screened based on the semantic redundancy between the candidate objects; step 9: determining the semantic redundancy comparison candidate objects and deleting the semantic redundancy comparison candidate objects from the fourth candidate object set, wherein the semantic redundancy comparison candidate objects are the candidate objects in the fourth candidate object set with the greatest semantic similarity to the text to be processed; step 10: for each candidate object remaining in the fourth candidate object set, performing the following operations: determining whether there is semantic redundancy between the candidate object being targeted and the semantic redundancy comparison candidate objects; and removing the candidate object being targeted from the fourth candidate object set if there is semantic redundancy. The selected object is deleted from the fourth candidate object set; in the absence of semantic redundancy, the targeted candidate object is deleted from the fourth candidate object set and saved in the sixth candidate object set; step 11: the semantic redundancy comparison candidate object is saved in the fifth candidate object set; step 12: the candidate objects in the sixth candidate object set are copied to the fourth candidate object set and the sixth candidate object set is cleared; step 13: whether the fourth candidate object set is empty; and step 14: when the fourth candidate object set is not empty, repeat steps 9 to 13 until the fourth candidate object set is empty, wherein the semantic redundancy comparison candidate object in the fifth candidate object set is the candidate object screened based on the semantic redundancy between the candidate objects.
[0069] Optionally, in an embodiment of the present invention, the screening module screens candidate objects based on the semantic similarity between the candidate objects and the text to be processed, including: for any candidate object to be screened based on the semantic similarity between the candidate object and the text to be processed, calculating the semantic similarity between the candidate object to be screened and the text to be processed; and screening the candidate objects to be screened based on the calculated semantic similarity, wherein the object to be screened whose semantic similarity reaches a preset semantic similarity threshold is the candidate object screened based on the semantic similarity between the candidate object and the text to be processed.
[0070] Optionally, in an embodiment of the present invention, the device further includes: a score determination module, for determining a score for any candidate object; wherein the score determination module determines the score for any candidate object including: determining a title score and / or a text score corresponding to the candidate object based on a score determination feature of the candidate object, wherein, for any candidate object, the score determination feature includes at least one of the following: a first number, a second number, a position weight of the candidate object, a length of the candidate object, and a number of elements included in the candidate object, wherein the first number represents the number of times the candidate object appears in the title of the text to be processed, and the second number represents the number of times the candidate object appears in the text of the text to be processed; and determining the score based on the title score and / or text score corresponding to the candidate object.
[0071] Optionally, in the embodiment of the present invention, the score determination module determines the title score for any candidate object based on the following formula: Score title =1.5*TF1*log2(M+1)log2(P / 2*M+0.5), where Score title It represents the title score, TF1 represents the first time count, M represents the number, and P represents the length.
[0072] Optionally, in an embodiment of the present invention, the position weight of the candidate object includes a first position weight corresponding to a ratio of the position of the candidate object first appearing in the text to the full text length and a second position weight corresponding to a ratio of the position span of the candidate object in the text to the full text length. The score determination module determines the text score for any candidate object based on the following formula: Score content =TF2*log2(M+1)*log2(P / 2*M+0.5)*(W front +W range ), where Score content represents the text score, TF2 represents the second number, M represents the number, P represents the length, and W represents the front represents the first position weight, W range Represents the second position weight.
[0073] Optionally, in an embodiment of the present invention, the device also includes: a part-of-speech tagging module, used to tag the parts of speech of the elements in the word segmentation result list before screening the candidate objects based on the screening features, wherein the screening features also include at least one of the following: whether it belongs to a preset basic part-of-speech set and whether it belongs to a preset boundary part-of-speech set.
[0074] The specific working principle and benefits of the device for determining keywords of a text provided by an embodiment of the present invention are similar to the working principle and benefits of the method for determining keywords of a text provided by an embodiment of the present invention, and will not be repeated here.
[0075] The device for determining keywords of a text includes a processor and a memory. The above-mentioned word segmentation module, candidate object determination module, screening module and keyword determination module are all stored in the memory as program units, and the processor executes the above-mentioned program units stored in the memory to realize corresponding functions.
[0076] The processor includes a kernel, which retrieves the corresponding program unit from the memory. One or more kernels can be set, and by adjusting kernel parameters, keywords can be determined based on the text to be processed without relying on a pre-built corpus text library.
[0077] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0078] In addition, another aspect of the embodiments of the present invention further provides a machine-readable storage medium, on which instructions are stored, and the instructions are used to enable a machine to execute the method described in the above embodiments.
[0079] In addition, another aspect of the embodiments of the present invention further provides a processor for running a program, wherein the program is used to execute the method described in the above embodiments when it is run.
[0080] In addition, another aspect of the embodiments of the present invention further provides a device, the device includes a processor, a memory, and a program stored in the memory and executable on the processor, and the processor implements the method described in the above embodiments when executing the program. The device in this article can be a server, a PC, a PAD, a mobile phone, etc.
[0081] In addition, another aspect of the embodiments of the present invention further provides a computer program product, including a computer program / instruction, which implements the method described in the above embodiment when the computer program / instruction is executed by a processor.
[0082] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0083] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0084] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0085] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0086] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0087] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0088] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0089] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0090] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.
Claims
1. A method for determining keywords of a text, characterized in that: The method includes: By performing word segmentation on the text to be processed, the text to be processed is split into at least one element to obtain a word segmentation result list; Determine candidate objects based on the elements in the word segmentation result list, wherein any of the candidate objects includes at least one element in a continuous position in the word segmentation result list; The candidate objects are screened based on screening features, wherein the screening features include at least one of the following: whether they belong to a preset disabled element set, a score, output form redundancy between the candidate objects, semantic redundancy between the candidate objects, and semantic similarity between the candidate objects and the text to be processed, and the score of any candidate object reflects the possibility that the candidate object becomes the keyword of the text to be processed; and Determining the keywords of the text to be processed based on the candidate objects obtained by screening; For any of the candidate objects, determining the score includes: Determine the title score corresponding to the candidate object based on the score determination feature of the candidate object and / or text score, wherein, for any of the candidate objects, the score determination feature includes at least one of the following: a first number, a second number, a position weight of the candidate object, a length of the candidate object, and the number of elements included in the candidate object, wherein the first number indicates the number of times the candidate object appears in the title of the text to be processed, and the second number indicates the number of times the candidate object appears in the text to be processed; and Determine the score based on the title score and / or the text score corresponding to the candidate object; The output form redundancy includes: inclusion redundancy and overlapping redundancy; the output form redundancy screening of any two candidate objects is implemented by the following method: When there is inclusion redundancy between the two candidate objects, the candidate object with a shorter length is eliminated; when there is overlapping redundancy between the two candidate objects, the two candidate objects are eliminated and replaced with the content obtained by splicing the two candidate objects.
2. The method according to claim 1, characterized in that Screening the candidate objects based on the output form redundancy between the candidate objects includes: Step 1: establishing a first candidate object set for the candidate objects to be screened based on output form redundancy between the candidate objects; Step 2: determining a formal redundant comparison candidate object and deleting the formal redundant comparison candidate object from the first candidate object set, wherein the formal redundant comparison candidate object is the candidate object with the largest length in the first candidate object set; Step 3: For each remaining candidate object in the first candidate object set, perform the following operations: Determine whether there is output form redundancy between the candidate object and the form redundancy comparison candidate object; In the case of output form redundancy, determining a screening candidate object according to a first preset rule, updating the form redundancy comparison candidate object based on the screening candidate object, and deleting the targeted candidate object from the first candidate object set; In the case where there is no output form redundancy, the targeted candidate object is deleted from the first candidate object set and saved in the third candidate object set; Step 4: Save the formal redundancy comparison candidate object into the second candidate object set; Step 5: copy the candidate objects in the third candidate object set to the first candidate object set and clear the third candidate object set; Step 6: Determine whether the first candidate object set is empty; and Step 7: When the first candidate object set is not empty, repeat steps 2 to 6 until the first candidate object set is empty, wherein the formal redundancy comparison candidate objects in the second candidate object set are candidate objects screened based on output formal redundancy between the candidate objects.
3. The method according to claim 1, characterized in that Screening the candidate objects based on semantic redundancy between the candidate objects includes: Step 8: establishing a fourth candidate object set for the candidate objects to be screened based on the semantic redundancy between the candidate objects; Step 9: determining a semantic redundancy comparison candidate object and deleting the semantic redundancy comparison candidate object from the fourth candidate object set, wherein the semantic redundancy comparison candidate object is the candidate object in the fourth candidate object set with the greatest semantic similarity to the text to be processed; Step 10: For each of the remaining candidate objects in the fourth candidate object set, perform the following operations: Determine whether there is semantic redundancy between the candidate object and the semantic redundancy comparison candidate object; In the case of semantic redundancy, deleting the targeted candidate object from the fourth candidate object set; In the absence of semantic redundancy, deleting the targeted candidate object from the fourth candidate object set and saving it to the sixth candidate object set; Step 11: saving the semantic redundancy comparison candidate object into a fifth candidate object set; Step 12: copy the candidate objects in the sixth candidate object set to the fourth candidate object set and clear the sixth candidate object set; Step 13: Determine whether the fourth candidate object set is empty; and Step 14: When the fourth candidate object set is not empty, repeat steps 9 to 13 until the fourth candidate object set is empty, wherein the semantic redundancy comparison candidate objects in the fifth candidate object set are candidate objects screened based on the semantic redundancy between the candidate objects.
4. The method according to claim 1, characterized in that: Screening the candidate objects based on the semantic similarity between the candidate objects and the text to be processed includes: For any candidate object to be screened that is to be screened based on the semantic similarity between the candidate object and the text to be processed, calculating the semantic similarity between the candidate object to be screened and the text to be processed; and Based on the calculated semantic similarity, the candidate objects to be screened are screened, wherein the candidate objects to be screened whose semantic similarity reaches a preset semantic similarity threshold are the candidate objects screened based on the semantic similarity between the candidate objects and the text to be processed.
5. The method according to claim 1, characterized in that For any of the candidate objects, determining the title score includes determining based on the following formula: in, represents the title score, represents the first number of times, M represents the number, and P represents the length.
6. The method according to claim 1, characterized in that The position weight of the candidate object includes a first position weight corresponding to a ratio of the position of the candidate object appearing for the first time in the text to the full text length of the text and a second position weight corresponding to a ratio of the position span of the candidate object in the text to the full text length. For any of the candidate objects, determining the text score includes determining based on the following formula: in, represents the text score, represents the second number of times, M represents the number, and P represents the length. represents the first position weight, represents the second position weight.
7. The method according to claim 1, characterized in that Before screening the candidate objects based on the screening features, the method further comprises: The elements in the word segmentation result list are marked with parts of speech, wherein the screening feature further includes at least one of the following: whether they belong to a preset basic part of speech set and whether they belong to a preset boundary part of speech set.
8. A machine-readable storage medium, characterized in that: The machine-readable storage medium stores instructions, which are used to enable a machine to execute the method according to any one of claims 1 to 7.
9. A processor, characterized in that: Used to run a program, wherein the program is used to execute the method according to any one of claims 1 to 7 when being run.
10. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Method and device for determining keywords of compositions
CN103942189A
Keyword extracting method and device
CN105426360A
Keyword extraction method and device, computer equipment and storage medium
CN110147425A
Keyword extraction method and electronic device
US20170139899A1
Keyword extraction method, keyword extraction device and computer-readable storage medium
US20200250376A1
