Text similarity calculation method based on improved YAKE and neural network

By integrating improved YAKE and neural network methods, calculating keyword feature values ​​​​of Chinese texts and using the word2vec model, the shortcomings of the YAKE algorithm in Chinese texts are solved, and the efficiency and simplification of Chinese text similarity calculations are achieved.

CN115129815BActive Publication Date: 2024-09-06SHANGHAI INST OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210777915.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-28
Publication Date
2024-09-06
Estimated Expiration
2042-06-28

AI Technical Summary

Technical Problem

The existing YAKE algorithm is not suitable for Chinese text keyword extraction, and the Chinese text similarity calculation requires a large amount of input data and high complexity.

Method used

Integrating improved YAKE and neural network methods, through Chinese word segmentation and part-of-speech tagging, calculate the feature values ​​of word position, word frequency, contextual relevance, number of heterosentence words, word span and part-of-speech, build a candidate keyword list, and use the word2vec model Calculate keyword vectors and calculate cosine similarity.

Benefits of technology

It effectively solves the shortcomings of the YAKE algorithm in Chinese text keyword extraction, reduces the input data volume and complexity of Chinese text similarity calculation, and improves calculation efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115129815B
    Figure CN115129815B
Patent Text Reader

Abstract

The present invention provides a text similarity calculation method integrating improved YAKE and neural network. By improving the keyword candidate stage of the YAKE algorithm, the word feature value calculation is performed using part of speech, word position, word span, word frequency, word context relevance, and the number of different sentence words, and the keyword score of each candidate word is calculated by integrating all the feature values, and the keywords are output in ascending order of the score. Finally, all keywords are input into a trained word2vec model for vectorization, the vectors of all keywords are summed and averaged, and finally the cosine similarity is calculated to obtain the similarity of different texts. In the above manner, the present invention mainly solves the problem that the YAKE algorithm is not suitable for Chinese text keyword extraction, and at the same time reduces the problem of large input data volume and high complexity of Chinese text similarity calculation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a text similarity calculation method integrating improved YAKE and neural network. Background Art

[0002] With the rapid development of the Internet, the Internet is flooded with massive amounts of text information, and natural language processing has received great attention. YAKE (Yet Another Keyword Extractor) is an unsupervised keyword extraction algorithm that identifies and sorts keywords through statistical features. It does not rely on external corpora, the length of text documents, language or domain, and outperforms TF-IDF, TextRank and RAKE on many data sets.

[0003] The existing YAKE algorithm is not suitable for Chinese text keyword extraction. Summary of the invention

[0004] The purpose of the present invention is to provide a text similarity calculation method integrating improved YAKE and neural network.

[0005] To solve the above problems, the present invention provides a text similarity calculation method integrating improved YAKE and neural network, comprising:

[0006] S1: Input Chinese text;

[0007] S2: Preprocess the Chinese text, use the LTP Chinese word segmentation tool to perform Chinese word segmentation and part-of-speech tagging, and remove stop words by combining the Chinese stop word list, stop word library, machine learning intelligent laboratory stop word library and stop word list to obtain the preprocessed text;

[0008] S3: Calculate the position, word frequency, context relevance, number of different words, word span and part of speech of the words in the preprocessed text, and fuse the obtained feature values ​​to obtain the final score of the word;

[0009] S4: construct a list of candidate keywords through the N-gram algorithm, and score the words in the list of candidate keywords based on the final scores of the words. The smaller the score, the more important the candidate keyword is. In this way, the top K most important keywords are selected from the candidate keywords. Each candidate keyword consists of one or more words.

[0010] S5: Input the K most important keywords into the word2vec model to obtain the keyword vector, add and average the word vectors of all keywords, and calculate the cosine similarity to obtain the similarity of different texts.

[0011] Furthermore, in the above method, the word position position(w), the feature representation gives more importance to the words appearing at the beginning of the document.

[0012] position(w)=ln(ln(3+Median(Sen(w)))),

[0013] Among them, Sen(W) is the set of sentence positions where all word w appears, and the Median function calculates the median of Sen(w).

[0014] Furthermore, in the above method, the word frequency (w) of a word indicates that the higher the frequency of a word, the greater its importance.

[0015]

[0016] Where TF(w) is the frequency of word w in the text, Avg(W) is the average frequency of all non-stop word sets W in the text, and σ is the standard deviation of the frequency of non-stop words.

[0017] Furthermore, in the above method, the contextual relevance of a word (w) indicates the relevance of a word to its context. If different words appear more frequently on the left or right side of a word, the importance of the word is lower.

[0018]

[0019]

[0020] Among them, Max(W) represents the maximum word frequency of all words, DW(w, t) represents the number of different words within a distance of t words from word w, and AW(w, t) represents the number of all words within a distance of t words from word w.

[0021] Furthermore, in the above method, the number of different sentences of a word, different(w), indicates the frequency of a word appearing in different sentences. The higher the frequency, the more important it is.

[0022]

[0023] Among them, F(w) is the number of sentences containing word w, Sentence all Represents the total number of all sentences.

[0024] Furthermore, in the above method, the word span (w) of a word represents the distance between the first and last occurrence of a word in the text. The larger the word span, the more important the word is to the text.

[0025]

[0026] Among them, first(w) is the position where word w first appears in the text, last(w) is the position where word w first appears in the text for the last time, Word all is the total number of all words.

[0027] Furthermore, in the above method, the feature scores calculated above are integrated into the following formula to calculate the final score Score(w) of the word:

[0028]

[0029] Among them, POSw is the score of the part of speech of word w. Since some useless words may appear multiple times or in many sentences, frequency(w), different(w) and span(w) are offset with relatedness(w) to deal with this situation. Similarly, multiplying relatedness(w) with position(w) is also to suppress the situation where useless words appear in the top sentences of the text. Score(w) represents the final score of the word. The smaller the value, the greater the importance.

[0030] Finally, the score of each candidate keyword is calculated using the following formula:

[0031]

[0032] Among them, kw represents candidate keywords composed of one or more words, Score(kw) represents the final score, the smaller the value, the greater the importance; TF(kw) is the word frequency of the candidate keywords, the more frequently appearing candidate words should be more important, and the product of Score(w) scores divided by the sum of Score(w) scores is to weaken the impact of word length.

[0033] Furthermore, in the above method, it is characterized in that the K most important keywords are input into the word2vec model to obtain keyword vectors, the word vectors of all keywords are summed and averaged, and the cosine similarity is calculated to obtain the similarity of different texts, including:

[0034] Input the K most important keywords into the trained word2vec model to obtain the vectors of each individual keyword, add and average all the keyword vectors, and get the keyword set vector to represent a paragraph or a text. Finally, calculate the similarity between different texts through the cosine similarity algorithm.

[0035]

[0036] Among them, A i , B i Represent the components of vectors A and B respectively.

[0037] Compared with the prior art, the present invention improves the keyword candidate stage of the YAKE algorithm, uses part of speech, word position, word span, word frequency, word context relevance, and the number of different words to calculate the characteristic value of the word, and then calculates the keyword score of each candidate word based on all the characteristic values, and outputs the keywords in ascending order of the score. Finally, all keywords are input into the trained word2vec model for vectorization, the vectors of all keywords are summed and averaged, and finally the cosine similarity is calculated to obtain the similarity of different texts. In the above manner, the present invention mainly solves the problem that the YAKE algorithm is not suitable for Chinese text keyword extraction, and reduces the problem of large input data volume and high complexity of Chinese text similarity calculation. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] Figure 1 It is a flow chart of a text similarity calculation method integrating improved YAKE and neural network according to an embodiment of the present invention;

[0039] Figure 2 It is a flow chart of an improved YAKE algorithm according to an embodiment of the present invention. DETAILED DESCRIPTION

[0040] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.

[0041] like Figure 1 and 2 As shown, the present invention provides a text similarity calculation method integrating improved YAKE and neural network, comprising:

[0042] S1: Input Chinese text;

[0043] S2: Preprocess the Chinese text, use the LTP Chinese word segmentation tool to perform Chinese word segmentation and part-of-speech tagging, and remove stop words by combining the Chinese stop word list, stop word library, machine learning intelligent laboratory stop word library and stop word list to obtain the preprocessed text;

[0044] S3: Calculate the position, word frequency, context relevance, number of different words, word span and part of speech of the words in the preprocessed text, and fuse the obtained feature values ​​to obtain the final score of the word;

[0045] S4: construct a list of candidate keywords through the N-gram algorithm, and score the words in the list of candidate keywords based on the final scores of the words. The smaller the score, the more important the candidate keyword is. In this way, the top K most important keywords are selected from the candidate keywords. Each candidate keyword consists of one or more words.

[0046] S5: Input the K most important keywords into the word2vec model to obtain the keyword vector, add and average the word vectors of all keywords, and calculate the cosine similarity to obtain the similarity of different texts.

[0047] Here, the Word2vec model is a shallow two-layer neural network that can be efficiently trained on a dictionary of millions of words and a dataset of hundreds of millions, quickly and effectively representing a word in vector form.

[0048] The YAKE algorithm proposes a characteristic factor of uppercase and lowercase letters, which is derived from the writing rules of English, but is obviously not suitable for keyword extraction in Chinese text. Therefore, the uppercase and lowercase letters of words will not be used as a characteristic factor for the improved algorithm, but will be combined with Chinese part of speech and word span as a new characteristic factor.

[0049] The present invention improves the keyword candidate stage of the YAKE algorithm, uses part of speech, word position, word span, word frequency, word context relevance, and the number of different words to calculate the characteristic value of the word, and then calculates the keyword score of each candidate word based on all the characteristic values, and outputs the keywords in ascending order of the score. Finally, all the keywords are input into the trained word2vec model for vectorization, the vectors of all the keywords are summed and averaged, and finally the cosine similarity is calculated to obtain the similarity of different texts. In the above manner, the present invention mainly solves the problem that the YAKE algorithm is not suitable for Chinese text keyword extraction, and reduces the problem of large input data volume and high complexity of Chinese text similarity calculation.

[0050] Furthermore, in the above method, the word position position(w), the feature representation gives more importance to the words appearing at the beginning of the document.

[0051] position(w)=ln(ln(3+Median(Sen(w)))),

[0052] Among them, Sen(w) is the set of sentence positions where word w appears, and the Median function is to calculate the median of Sen(w). The double logarithm function is applied to smooth the differences between items with large median differences. At the same time, since the result of this formula is an increasing function, the more times word w appears at the beginning of the document, the lower its position value; on the contrary, word w closer to the end of the document will be assigned a higher position value.

[0053] Furthermore, in the above method, the word frequency (w) of a word indicates that the higher the frequency of a word, the greater its importance.

[0054]

[0055] Among them, TF(w) is the frequency of word w in the text, Avg(W) is the average frequency of all non-stop word sets W in the text, and σ is the standard deviation of the frequency of non-stop words. The purpose is to prevent excessive bias towards high-frequency words in long texts.

[0056] Furthermore, in the above method, the contextual relevance of a word (w) indicates the relevance of a word to its context. If different words appear more frequently on the left or right side of a word, the importance of the word is lower.

[0057]

[0058]

[0059] Among them, MaxTF(W) represents the maximum word frequency of all words, DW(w, t) represents the number of different words within a distance of t words from word w, and AW(w, t) represents the number of all words within a distance of t words from word w.

[0060] Furthermore, in the above method, the number of different sentences of a word, different(w), indicates the frequency of a word appearing in different sentences. The higher the frequency, the more important it is.

[0061]

[0062] Among them, F(w) is the number of sentences containing word w, Sentence all Represents the total number of all sentences.

[0063] Furthermore, in the above method, the word span (w) of a word represents the distance between the first and last occurrence of a word in the text. The larger the word span, the more important the word is to the text.

[0064]

[0065] Among them, first(w) is the position where word w first appears in the text, last(w) is the position where word w first appears in the text for the last time, Word all is the total number of all words.

[0066] Furthermore, in the above method, the feature scores calculated above are integrated into the following formula to calculate the final score Score(w) of the word:

[0067]

[0068] Among them, POSw is the score of the part of speech of word w. Since some useless words may appear multiple times or in many sentences, frequency(w), different(w) and span(w) are offset with relatedness(w) to deal with this situation. Similarly, multiplying relatedness(w) with position(w) is also to suppress the situation where useless words appear in the top sentences of the text. Score(w) represents the final score of the word. The smaller the value, the greater the importance.

[0069] Words of different parts of speech have different importance. For example, nouns and verbs have higher scores than prepositions and adverbs.

[0070] Finally, the score of each candidate keyword is calculated using the following formula:

[0071]

[0072] Among them, kw represents candidate keywords consisting of one or more words, such as "machine", "learning", and "machine learning". Score(kw) represents the final score. The smaller the value, the greater the importance. TF(kw) is the frequency of the candidate keywords. The more frequently appearing candidate words are, the more important they should be. At the same time, the product of Score(w) scores divided by the sum of Score(w) scores is to weaken the impact of word length.

[0073] Furthermore, in the above method, it is characterized in that the K most important keywords are input into the word2vec model to obtain keyword vectors, the word vectors of all keywords are summed and averaged, and the cosine similarity is calculated to obtain the similarity of different texts, including:

[0074] Input the K most important keywords into the trained word2vec model to obtain the vectors of each individual keyword, add and average all the keyword vectors, and get the keyword set vector to represent a paragraph or a text. Finally, calculate the similarity between different texts through the cosine similarity algorithm.

[0075]

[0076] Among them, A i , B i Represent the components of vectors A and B respectively.

[0077] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0078] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0079] Obviously, those skilled in the art can make various changes and modifications to the invention without departing from the spirit and scope of the invention. Thus, if these modifications and variations of the invention fall within the scope of the claims of the invention and their equivalents, the invention is also intended to include these modifications and variations.

Claims

1. A text similarity calculation method integrating improved YAKE and neural network, characterized in that: include: S1: Input Chinese text; S2: Preprocess the Chinese text, use the LTP Chinese word segmentation tool to perform Chinese word segmentation and part-of-speech tagging, and remove stop words by combining the Chinese stop word list, stop word library, machine learning intelligent laboratory stop word library and stop word list to obtain the preprocessed text; S3: Calculate the position, word frequency, context relevance, number of different words, word span and part of speech of the words in the preprocessed text, and fuse the obtained feature values ​​to obtain the final score of the word; S4: construct a list of candidate keywords through the N-gram algorithm, and score the words in the list of candidate keywords based on the final scores of the words. The smaller the score, the more important the candidate keyword is. In this way, the top K most important keywords are selected from the candidate keywords. Each candidate keyword consists of one or more words. S5: Input the K most important keywords into the word2vec model to obtain the keyword vector, add and average the word vectors of all keywords, and calculate the cosine similarity to obtain the similarity of different texts.

2. The text similarity calculation method of the fusion improved YAKE and neural network according to claim 1 is characterized in that: The position of the word (w), the feature indicates that more importance is given to the words that appear at the beginning of the document. position(w)=ln(ln(3+Median(Sen(w)))), Among them, Sen(w) is the set of sentence positions where all word w appears, and the Median function calculates the median of Sen(w).

3. The text similarity calculation method of the fusion improved YAKE and neural network according to claim 2 is characterized in that: The frequency (w) of a word means that the more frequently a word appears, the greater its importance. Where TF(w) is the frequency of word w in the text, Avg(W) is the average frequency of all non-stop word sets W in the text, and σ is the standard deviation of the frequency of non-stop words.

4. The text similarity calculation method of the fusion improved YAKE and neural network according to claim 3 is characterized in that: The word's contextual relevance (w) indicates the relevance of a word to its context. The more frequently different words appear on the left or right side of a word, the less important the word is. Among them, MaxTF(W) represents the maximum word frequency of all words, DW(w, t) represents the number of different words within a distance of t words from word w, and AW(w, t) represents the number of all words within a distance of t words from word w.

5. The text similarity calculation method of the fusion improved YAKE and neural network according to claim 4 is characterized in that: The number of different sentences of a word, different(w), indicates the frequency of a word appearing in different sentences. The higher the frequency, the more important it is. Among them, F(w) is the number of sentences containing word w, Sentence all Represents the total number of all sentences.

6. The text similarity calculation method of the fusion improved YAKE and neural network according to claim 5 is characterized in that: The word span (w) of a word indicates the distance between the first and last occurrence of a word in the text. The larger the word span, the more important the word is to the text. Among them, first(w) is the position where word w first appears in the text, last(w) is the position where word w first appears in the text for the last time, Word all is the total number of all words.

7. The text similarity calculation method of the fusion improved YAKE and neural network according to claim 6 is characterized in that: Integrate the feature scores calculated above into the following formula to calculate the final score Score(w) of the word: Among them, POSw is the score of the part of speech of word w. Since some useless words may appear multiple times or in many sentences, frequency(w), different(w) and span(w) are offset with relatedness(w) to deal with this situation. Similarly, multiplying relatedness(w) with position(w) is also to suppress the situation where useless words appear in the top sentences of the text. Score(w) represents the final score of the word. The smaller the value, the greater the importance. Finally, the score of each candidate keyword is calculated using the following formula: Among them, kw represents candidate keywords composed of one or more words, Score(kw) represents the final score, the smaller the value, the greater the importance; TF(kw) is the word frequency of the candidate keywords, the more frequently appearing candidate words should be more important, and the product of Score(w) scores divided by the sum of Score(w) scores is to weaken the impact of word length.

8. The text similarity calculation method of the fusion improved YAKE and neural network according to claim 7 is characterized in that: Input the K most important keywords into the word2vec model to obtain the keyword vector, add and average the word vectors of all keywords, and calculate the cosine similarity to obtain the similarity of different texts, including: Input the K most important keywords into the trained word2vec model to obtain the vectors of each individual keyword, add and average all the keyword vectors, and get the keyword set vector to represent a paragraph or a text. Finally, calculate the similarity between different texts through the cosine similarity algorithm. Among them, A i , B i Represent the components of vectors A and B respectively.