A method for discovering and parsing new words on web pages based on word vector representation
Through the method based on word vector representation, the problem of insufficient accuracy in web page text information collection and extraction is solved, the accurate discovery and analysis of new words is achieved, the accuracy and autonomy of information extraction are improved, and operation and maintenance costs are reduced.
Patent Information
- Application Number
- CN202111444046.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-30
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2041-11-30
AI Technical Summary
Existing technologies are not accurate enough in web page text information collection and extraction. In particular, there are difficulties in discovering and parsing new words, and traditional methods lack real-time adaptability and versatility, resulting in high operation and maintenance costs.
Using a method based on word vector representation, the prefix dictionary tree is constructed through web page raw data preprocessing, rough word segmentation, and N-gram models, mutual information measurement is used to screen candidate binary pairs, left and right information entropy is used to determine new word boundaries, and CBOW model word vector mapping and Cosine similarity expands the new word dictionary and enables independent learning and identification of key information in web pages.
It achieves the accurate discovery and analysis of new words in web pages, improves the accuracy and autonomy of information extraction, reduces the dependence on word segmentation tools, and enhances the accuracy and real-time adaptability of information extraction.
Smart Images

Figure CN114169325B
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of artificial intelligence data processing methods, and relates to a method for discovering and parsing new words on a web page based on word vector representation. Background Art
[0002] With the development of the Internet, the Internet has become an essential part of people's lives. More and more people are posting their comments and opinions on different online platforms. Most of these comments appear in text form, making text classification a key technology for processing and organizing large amounts of document data. Using computers to classify text has become a very meaningful research topic in the field of natural language processing and artificial intelligence. At the same time, people are facing the challenge of "information explosion", that is, information is extremely abundant, information spreads at a very fast speed, and knowledge is too poor. With the country's strong call for "Internet +" in the past two years, the web has gradually grown into a platform for content production and consumption. Countless information sources in the form of HTML web pages have been formed on the Internet. It is an impossible task to manually process these massive data. To filter out useful information from massive data, we must rely on computers with powerful computing power.
[0003] As the types of network electronic data resources continue to increase, the amount of data is growing rapidly, especially the unstructured data such as short videos, entertainment applications, and online shopping that have grown rapidly in recent years. Extracting available text information from massive unstructured information can make full use of resources. In addition, the amount of network information is exploding, and text analysis applications based on these network information are also emerging in an endless stream, and various new words are constantly emerging with the trend of the Internet; in the present invention, unregistered words are equated with new words, that is, words that are not separated by word segmentation tools. New word discovery is an inevitable problem in the field of Chinese information processing. New word discovery technology is directly related to the effect of Chinese word segmentation, which in turn affects subsequent information processing problems at all levels. Therefore, how to quickly and accurately identify new words from corpus is the focus of research in natural language processing.
[0004] With the development of Web technology and the increasingly serious commercial operation of websites, a large amount of valuable information is distributed on various web pages, while the noise information in web pages is unprecedentedly increased, and the web page text information is mostly complex and has no structured information characteristics. Generally, it can only be searched by full-text search, making many methods no longer applicable to the extraction of current web page text information, which brings great difficulties to the next large-scale text analysis task. The present invention constructs a process for locating and identifying and extracting key information in web pages based on word vector representation. The main steps of the model are keyword recognition and extraction. The model recognizes and locates the combined new words in the web page text through autonomous learning, further improving the shortcomings of the web page information analysis technology based on the web page template adaptation method of regular matching that does not have universality and real-time adaptability, because when the website developer makes a slight change, the template cannot be invalidated, resulting in a large operation and maintenance cost. Summary of the invention
[0005] The purpose of the present invention is to provide a method for discovering and parsing new words on a web page based on word vector representation, which solves the problem of insufficient accuracy in collecting and extracting web page text information in the prior art.
[0006] The technical solution adopted by the present invention is:
[0007] The method for discovering and parsing new words on a web page based on word vector representation includes the following steps:
[0008] Step 1: preprocessing the original data of the web page, that is, removing useless code symbols and codes in the original data to obtain pre-trained text;
[0009] Step 2: Perform a rough word segmentation preprocessing on the pre-trained text in step 1, construct nodes using the N-gram method for the pre-processed scattered strings, and construct a prefix dictionary tree to count the scattered string words and word frequencies;
[0010] Step 3, using the scattered string words and word frequency information stored in the prefix dictionary tree in step 2, using the mutual information metric to measure the possibility of two scattered strings forming a word, and screening out candidate bigrams;
[0011] Step 4: for the candidate bigrams that pass step 3, use the left and right information entropies to determine the left and right boundaries of the combined words, set the threshold of the left and right adjacency entropies, and then select candidate word strings greater than the threshold to form a preliminary new word set;
[0012] Step 5, perform preliminary rule screening on the preliminary new word set generated in step 4, select effective new word database, perform word vector mapping of CBOW model in 2-gram and 3-gram word strings formed by word segmentation software, and then find similar words of candidate new words based on cosine similarity principle to expand the new word dictionary of the field.
[0013] Step 6, parsing the data in the web page to be processed, and transferring the information data in the web page to a pre-set structured array list according to the web page structured information format according to the information carried by the web page tag;
[0014] Step 7, locate the data in the two-dimensional list in step 6 through the keyword dictionary in step 5, and then extract and integrate the information according to the characteristics of the feature information carried by the web page tags to complete the parsing process.
[0015] The present invention is also characterized in that:
[0016] The specific steps in step 1 are: segment the web page preprocessing corpus according to punctuation marks, special symbols and English letters, segment the sentences into multiple short sentences, and remove the punctuation marks, special symbols and English letters used for segmentation, that is, remove useless punctuation marks and stop words such as conjunctions in the original data to obtain pre-trained text.
[0017] The specific steps of step 2 are:
[0018] Step 2.1, construct a stop word library and use the jieba word segmentation tool to perform rough word segmentation on the pre-trained text in step 1;
[0019] Step 2.2, read the text line by line from the word segmentation text result obtained by the word segmentation preprocessing in step 2.1, and perform a combination construction of the N-gram model;
[0020] Step 2.3, traverse the entries formed by N-gram, construct a prefix dictionary, use the entry as the key, the word frequency as the corresponding key value, traverse the prefix dictionary, if the key corresponding to the prefix does not exist, set the prefix as the new key of the dictionary, and set the corresponding key value to 0; finally, get the scattered string words and word frequency information.
[0021] The specific steps of step 3 are:
[0022] Step 3.1, using the scattered strings and word frequency information after word segmentation stored in the N_gram prefix dictionary tree constructed in step 2, perform iterative statistics by expanding to the adjacent elements of the candidate words;
[0023] Step 3.2, using the adjacent combination word string constructed in step 3.1, calculate the multi-word mutual information value between the candidate new word and the right adjacent element to expand the binary scattered string set. Each combined new word is taken as a new unit. If it is less than the threshold, stop expanding to the right. If it is greater than the threshold, continue to expand to the right. The expansion stops if and only if the mutual information values with the right adjacent element are all less than the threshold.
[0024] Step 4 is specifically implemented according to the following steps: filter the candidate combination word set that passes step 3 according to the adjacency entropy formula, set the threshold of left and right adjacency entropy to 0.7, and calculate the formula score = PMI + min (left entropy, right entropy). The smaller the left and right adjacency entropy, the fewer the left and right adjacent characters of the candidate new word, indicating that the word is easier to use in a sentence, or even appear alone, and is very likely to become a new word. Finally, filter out new word strings containing numbers and letters.
[0025] Step 5 is implemented according to the following steps:
[0026] Step 5.1: First, the pre-trained text generated in step 1 is used to represent the combined new words into dense vectors using word embedding technology as the text input for model training. The distributed vector is mapped into a continuous fixed-length dense vector that can reflect the relationship between words.
[0027] Step 5.2, after obtaining the text after corpus segmentation, convert it into the training text format of word2vec. The neural network type used in training the model is the CBOW model. This algorithm uses a large amount of text to create high-dimensional word representations and capture the relationship between words without external annotations.
[0028] Step 5.3, using the three-layer model structure of CBOW, first pass through the input layer, take (context(w), w) as an example, where context(W) is composed of C words before and after w. Input layer: contains the word vectors v(context(w)1), v(context(w)2),..., v(context(w)2c) of the 2c words in context(w); projection layer: sum and accumulate the 2c vectors of the input layer, output layer: corresponds to a binary tree, with the words that have appeared in the corpus as leaf nodes, and the Huffman number constructed with the number of times each word appears in the corpus as the weight. There are N=D leaf nodes in total, corresponding to each word in the dictionary D, and N-1 non-leaf nodes;
[0029] Step 5.4, after the training is completed, the word vector corresponding to each word is obtained from the vocabulary to obtain the word vector model; in a text, the context of any word is composed of its first N words and the last N words. Use the cosine similarity principle to find similar words in the preliminary new word set. The more similar the contexts of two words are, the more similar and related the two words are. Therefore, the problem of finding the similarity of two words is converted into the problem of finding the similarity of the contexts of the two words, and finally the similar words of the selected new words are obtained.
[0030] Step 7 is as follows:
[0031] Step 7.1, extract and identify information using the format of the tag. If the tag format is a text tag, extract directly. If the tag format is identified as a structured table tag, use the table tag in the web page to locate the corresponding position, and locate and extract based on the right and bottom of the extracted information content in the preliminary new word set;
[0032] Step 7.2: If you encounter multiple-bid table information extraction, determine the specific number of multiple bids based on the positions of the two keywords, and then extract the multiple bids based on the method in step 6.
[0033] The beneficial effects of the present invention are:
[0034] The invention discloses a method for discovering and parsing new words on a web page based on word vector representation, which is mainly divided into three parts: data acquisition, data processing and data extraction. It can realize accurate extraction of data required by users. When extracting structured key information from some web page data, it can autonomously discover key new words and their similar words, so as to identify and extract them. Since the new words are autonomously discovered based on the original data of the web page, they are not subject to the limitations of the word segmentation tool; since the autonomous discovery process of similar words is carried out, the accuracy of information extraction is further increased. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 It is a new word discovery flow chart of a new word discovery and analysis method for a web page based on word vector representation of the present invention;
[0036] Figure 2 It is a specific network structure diagram in the CBOW model in the method for discovering and parsing new words on a web page based on word vector representation of the present invention;
[0037] Figure 3 It is a system architecture diagram of structured information processing in a method for discovering and parsing new words on a web page based on word vector representation in the present invention. DETAILED DESCRIPTION
[0038] The present invention is described in detail below with reference to the accompanying drawings and specific embodiments.
[0039] The present invention provides a method for discovering and parsing new words on a web page based on word vector representation, such as Figure 1 As shown, the following steps are included:
[0040] Step 1: preprocessing the original data of the web page, that is, removing useless code symbols and codes in the original data to obtain pre-trained text: segment the pre-processed web page corpus according to punctuation marks, special symbols and English letters, break the sentences into multiple short sentences, and remove the punctuation marks, special symbols and English letters used for segmentation, that is, remove useless punctuation marks and stop words such as conjunctions in the original data to obtain pre-trained text.
[0041] Step 2: Perform a rough word segmentation preprocessing on the pre-trained text in step 1, construct nodes using the N-gram method for the pre-processed scattered strings, and construct a prefix dictionary tree to count the scattered string words and word frequencies; specifically:
[0042] Step 2.1, construct a stop word library and use the jieba word segmentation tool to perform rough word segmentation on the pre-trained text in step 1;
[0043] Step 2.2, read the text line by line from the word segmentation text result obtained by the word segmentation preprocessing in step 2.1, and perform a combination construction of the N-gram model;
[0044] Step 2.3, traverse the entries formed by N-gram, construct a prefix dictionary, use the entry as the key and the word frequency as the corresponding key value, traverse the prefix dictionary, if the key corresponding to the prefix does not exist, set the prefix as the new key of the dictionary, and set the corresponding key value to 0.
[0045] Step 3, using the scattered strings and word frequency information stored in the prefix dictionary tree in step 2, using the mutual information metric to measure the possibility of two scattered strings forming a word, and screening out candidate bigrams;
[0046] Step 3.1, using the scattered strings and word frequency information after word segmentation stored in the N_gram prefix dictionary tree constructed in step 2, perform iterative statistics by expanding to the adjacent elements of the candidate words;
[0047] Step 3.2, using the adjacent combination word string constructed in step 3.1, calculate the multi-word mutual information value between the candidate new word and the right adjacent element to expand the binary scattered string set. Each combined new word is used as a new unit. If it is less than the threshold, it stops expanding to the right. If it is greater than the threshold, it continues to expand to the right. If and only if the mutual information value with the right adjacent element is less than the threshold, the expansion stops. The multi-word mutual information is shown in formula (1):
[0048]
[0049] Among them, w1...w n Represents a string with multiple characters, p(w1...w n ) is w1...w n The probability of appearing in the corpus, avg(w1...w n ) represents the average probability of different combinations of multi-word strings.
[0050] Step 4: For the candidate bigrams that pass step 3, use the left and right information entropies to determine the left and right boundaries of the combined words, set the threshold of the left and right adjacency entropies, and then select candidate word strings greater than the threshold to form a preliminary new word set. The calculation formula of the left and right information entropies is shown in the following formulas (2) and (3):
[0051]
[0052]
[0053] Where: S l is the set of left adjacent words of candidate word w; Sr is the set of right adjacent words of candidate word w; p(wl|w) represents w l is the conditional probability of the left adjacent word of candidate word w; p(wr|w) represents the conditional probability that wr is the right adjacent word of candidate word w.
[0054] Step 4.1, filter the candidate combination word set that passes step 3 according to the adjacency entropy formula, set the threshold of the left and right adjacency entropies, and calculate the formula score = PMI + min (left entropy, right entropy). The smaller the entropy, the fewer the left and right adjacent characters of the candidate new word, which means that the word is easier to use in a sentence, or even appear alone, and it is very likely to become a new word.
[0055] The adjacency entropy threshold is set to 0.7. When the entropy value of the right adjacent element of the candidate word string is greater than the set threshold, the right word boundary is determined. When the entropy value of the left adjacent element is greater than the set threshold, the left word boundary is determined. Finally, new word strings containing numbers and letters are filtered out.
[0056] Step 5, perform preliminary rule screening on the preliminary new word set generated in step 4, select effective new word database, perform word vector mapping of CBOW model in 2-gram and 3-gram word strings formed by word segmentation software, and then find similar words of candidate new words based on cosine similarity principle to expand the new word dictionary of the field.
[0057] Step 5.1: First, use the word vector technology to represent the pre-trained text generated in step 1 into a dense vector, which is used as the text input for model training. The distributed vector is mapped into a continuous fixed-length dense vector, which can reflect the relationship between words.
[0058] Step 5.2, after obtaining the text after corpus segmentation, convert it into the training text format of word2vec. The neural network type used in training the model is the CBOW model. This algorithm uses a large amount of text to create a high-dimensional word representation and capture the relationship between words without external annotations. The model structure is as follows Figure 2 shown.
[0059] Step 5.3, using the three-layer model structure of CBOW, first pass through the input layer, taking (context(w), w) as an example, where context(W) consists of C words before and after w. Input layer:
[0060] Contains the word vectors of 2c words in context(w); Projection layer: sums up the 2c vectors of the input layer, Output layer: corresponds to a binary tree, with words that have appeared in the corpus as leaf nodes, and the number of times each word appears in the corpus as the weight to construct the Huffman number. There are N=D leaf nodes in total, corresponding to each word in the dictionary D, and N-1 non-leaf nodes.
[0061] Step 5.4, after the three-layer model structure training of CBOW is completed, the word vector corresponding to each word is obtained from the vocabulary to obtain the word vector model; in a text, the context of any word is composed of its first N words and the last N words. Use the cosine similarity principle to find similar words in the initial new word set. The more similar the contexts of two words are, the more similar and related the two words are. Therefore, the problem of finding the similarity of two words is converted into the problem of finding the similarity of the contexts of the two words, and then the initial dictionary combination for extracting keywords is obtained.
[0062] Step 6, such as Figure 3 As shown, the data in the web page to be processed is parsed, and based on the information carried by the web page tag, the information data in the web page is transferred to a pre-set two-dimensional array list in accordance with the web page structured information format.
[0063] Step 7, locate the data in the two-dimensional list in step 6 through the keyword dictionary in step 5, and then extract and integrate the information according to the characteristics of the feature information carried by the web page tags to complete the parsing process.
[0064] Step 7.1, extract and identify information using the format of the tag. If the tag format is a text tag, extract it directly. If the tag format is identified as a table tag, use the table tag in the web page to locate the corresponding position, and locate and extract it based on the right and bottom of the extracted information content in the preliminary new word set;
[0065] Step 7.2, if you encounter multiple bid table information extraction, determine the specific number of multiple bids based on the positions of the two keywords, and then extract the multiple bids according to the method of step 6.2.
[0066] Example 1
[0067] Objective: Use the method of the present invention to extract entity information corresponding to the supplier with the keyword winning bid in web page data.
[0068] The method of the present invention is used to discover entity information corresponding to the supplier with the unique new word keyword in the web page text data using an unsupervised learning method.
[0069] The specific application process is as follows:
[0070] First, extract the web page text data from the json data, and use the stop word dictionary to make a preprocessed data set; then use the jieba word segmentation tool to roughly segment the preprocessed text. For example, after the new word "successful supplier" is mistakenly divided into two terms "successful bid" and "supplier" by the word segmentation tool, it is combined into candidate scattered strings such as "successful bid", "supplier", and "successful supplier" under the N-gram algorithm; then, considering the internal word probability and external word probability of the word, the new word "successful supplier" is identified. Finally, the CBOW model in word2vec is used to co-occur with the similar word dictionary combination of the successful supplier, and then this dictionary is used as the keyword positioning standard to locate and match keywords in the two-dimensional list that stores web page data. Finally, according to the characteristics of unstructured information storage on web pages, the structural information carried by web page tags is used to obtain the entity information corresponding to the successful supplier.
Claims
1. A method for discovering and parsing new words on a web page based on word vector representation, characterized in that: The following steps are involved: Step 1: preprocessing the original data of the web page, that is, removing useless code symbols and codes in the original data to obtain pre-trained text; Step 2: Perform a rough word segmentation preprocessing on the pre-trained text in step 1, construct nodes using the N-gram method for the pre-processed scattered strings, and construct a prefix dictionary tree to count the scattered string words and word frequencies; Step 3, using the scattered string words and word frequency information stored in the prefix dictionary tree in step 2, using the mutual information metric to measure the possibility of two scattered strings forming a word, and screening out candidate bigrams; Step 4: for the candidate bigrams that pass step 3, use the left and right information entropies to determine the left and right boundaries of the combined words, set the threshold of the left and right adjacency entropies, and then select candidate word strings greater than the threshold to form a preliminary new word set; Step 5: Perform preliminary rule screening on the preliminary new word set generated in step 4, select effective new word lexicon, perform word vector mapping of CBOW model in 2-gram and 3-gram word strings formed by word segmentation software, and then find similar words of candidate new words according to the cosine similarity principle to expand the new word dictionary of the field; Step 6, parsing the data in the web page to be processed, and transferring the information data in the web page to a pre-set structured array list according to the web page structured information format according to the information carried by the web page tag; Step 7, locate the data in the two-dimensional list in step 6 through the keyword dictionary in step 5, and then extract and integrate the information according to the characteristics of the characteristic information carried by the web page tags to complete the parsing process; The specific steps of step 2 are: Step 2.1, construct a stop word library and use the jieba word segmentation tool to perform rough word segmentation on the pre-trained text in step 1; Step 2.2, read the text line by line from the word segmentation text result obtained by the word segmentation preprocessing in step 2.1, and perform a combination construction of a 3-gram model; Step 2.3, traverse the entries formed by N-gram, construct a prefix dictionary, use the entry as the key, the word frequency as the corresponding key value, traverse the prefix dictionary, if the key corresponding to the prefix does not exist, set the prefix as the new key of the dictionary, and set the corresponding key value to 0; finally, get the scattered string word and word frequency information; The specific steps of step 3 are: Step 3.1, using the scattered strings and word frequency information after word segmentation stored in the N_gram prefix dictionary tree constructed in step 2, perform iterative statistics by expanding to the adjacent elements of the candidate words; Step 3.2, using the adjacent combination word string constructed in step 3.1, calculate the multi-word mutual information value between the candidate new word and the right adjacent element to expand the binary scattered string set, each combined new word is used as a new unit, if it is less than the threshold, then stop expanding to the right, if it is greater than the threshold, then continue to expand to the right, if and only if the mutual information value with the right adjacent element is less than the threshold, the expansion stops; The specific steps of step 4 are as follows: filter the candidate combination word set that passes step 3 according to the adjacency entropy formula, set the threshold of the left and right adjacency entropies to 0.7, calculate the formula score = PMI + min (left entropy, right entropy), when the entropy value of the right adjacent element of the candidate word string is greater than the set threshold, the right word boundary is determined, when the entropy value of the left adjacent element is greater than the set threshold, the left word boundary is determined, and finally filter out new word strings containing numbers and letters; The specific steps of step 5 are: Step 5.1: First, the pre-trained text generated in step 1 is used to represent the combined new words into dense vectors using word embedding technology as the text input for model training. The distributed vector is mapped into a continuous fixed-length dense vector that can reflect the relationship between words. Step 5.2, after obtaining the text after corpus segmentation, convert it into the training text format of word2vec. The neural network type used in training the model is the CBOW model. The CBOW model uses a large amount of text to create a high-dimensional word representation and capture the relationship between words without external annotations. Step 5.3, using the three-layer model structure of CBOW, first pass through the input layer, taking (context(w), w) as an example, where context(W) consists of C words before and after w; Input layer: contains the word vectors v(context(w)1), v(context(w)2), ..., v(context(w)2c) of the 2c words in context(w); projection layer: sums and accumulates the 2c vectors of the input layer; output layer: corresponds to a binary tree, with the words that have appeared in the corpus as leaf nodes, and the Huffman number constructed with the number of times each word appears in the corpus as the weight. There are N = D leaf nodes in total, corresponding to each word in the dictionary D, and N-1 non-leaf nodes; Step 5.4, after the training is completed, the word vector corresponding to each word is obtained from the vocabulary to obtain the word vector model; in a text, the context of any word is composed of its first N words and the last N words. The cosine similarity principle is used to find similar words in the preliminary new word set. The more similar the contexts of two words are, the more similar and related the two words are. Therefore, the problem of finding the similarity of two words is converted into the problem of finding the similarity of the contexts of the two words, and finally the similar words of the selected new word are obtained; The step 7 is specifically as follows: Step 7.1, extract and identify information using the format of the tag: if the tag format is a text tag, directly extract it; if the tag format is identified as a structured table tag, use the table tag in the web page to locate the corresponding position, and locate and extract it based on the right and bottom of the extracted information content in the preliminary new word set; Step 7.2: If you encounter multiple-bid table information extraction, determine the specific number of multiple bids based on the positions of the two keywords, and then extract the multiple bids based on the method in step 6.
2. The method for discovering and parsing new words on a web page based on word vector representation as claimed in claim 1, characterized in that: The specific steps in step 1 are: segmenting the web page preprocessing corpus according to punctuation marks, special symbols and English letters, segmenting the sentences into multiple short sentences, and removing the punctuation marks, special symbols and English letters used for segmentation, that is, removing useless punctuation marks and connecting words in the original data to obtain pre-trained text.
