Web page text positioning method, device and computer equipment based on sequence annotation

Through a method based on sequence annotation, using regular expressions and HMM models combined with the Viterbi algorithm, the problem of noise interference and format differences in web page text positioning is solved, achieving higher accuracy and versatility, ensuring that the content can be used on different websites. Accurately extract text content when there is a large amount of information.

CN118606591BActive Publication Date: 2024-10-25NAT UNIV OF DEFENSE TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411086021.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-08
Publication Date
2024-10-25
Estimated Expiration
2044-08-08

AI Technical Summary

Technical Problem

Existing technologies have problems with noise interference, format differences, and insufficient versatility in web page text positioning, resulting in low accuracy and difficulty in effectively identifying and eliminating noise in web page source code, especially in informal websites and situations with a large amount of information. Down.

Method used

Using a method based on sequence annotation, the web page source code is matched and classified by pre-set regular expression rule tables, the HMM model is trained, and the Viterbi algorithm is used to calculate the word label probability, combined with the LSTM model of the Tensorflow library for classification, and the real the text content.

Benefits of technology

It improves the accuracy and versatility of web page text positioning, can effectively identify and eliminate noise, and ensures that the text content can be accurately extracted on different websites and under large amounts of information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118606591B_ABST
    Figure CN118606591B_ABST
Patent Text Reader

Abstract

The present application relates to a method, device and computer equipment for locating the text of a web page based on sequence annotation. First, a regular expression is constructed to extract the corresponding text fragments from the source code. Since only a small part of the extracted fragments contains the text content to be extracted, these fragments are also classified, and the fragments that truly contain the text content are screened out based on the differences between the text and non-text fragments. Secondly, all parameters to be used in the HMM model are assigned and initialized using the training set. Finally, the Viterbi algorithm is used to calculate the probability that each word in the text fragment belongs to different labels, and the largest probability is selected for sequence annotation, and all the content belonging to the text is located according to the category of the label.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the field of web page text positioning, and in particular to a web page text positioning method, device and computer equipment based on sequence annotation. Background Art

[0002] Faced with a massive amount of site information, how to accurately obtain the knowledge that users want from web pages has become an urgent problem to be solved. Usually when users want to search for knowledge in a certain aspect, they will search in the browser through keywords, and then select the appropriate web page to view from the many matching results. This method has good efficiency when the amount of information required by the user is small and the directionality is relatively obvious. However, if the amount of information required by the user is large and the content is relatively broad, for example, if you want to obtain all news reports about people introduced by a news website in recent years, then obviously searching through search engines becomes a very inefficient method. Therefore, it has become the mainstream to use intelligent methods to realize web page text positioning and automatically extract the text content from many web page source codes.

[0003] Web page body location refers to the process of locating and extracting the main content of a web page from a noisy web page source code. This process usually filters out HTML tags, navigation bars, advertising links, and other information in the web page source code, thereby retaining the most valuable main content. In this field, current research mainly starts from the text features, structural features, and visual features of the web page source code, and formulates rules for screening by mining the different features between the main content and other noisy parts. However, these studies still have the following difficulties to a greater or lesser extent: (1) Most web pages are written in HTML, and the HTML source code contains a large number of HTML tags and format information for setting fonts and typesetting. These contents are semantically irrelevant to the main content that users want to extract, which will cause certain interference. (2) In addition to the main content, most commercial web pages also include many other contents, such as navigation bars, external advertisements, and related tweets. These contents are related to the main content that users want in terms of both presentation and semantics, which will greatly affect the accuracy of text location. (3) There are great differences in the web page formats of different websites, especially some informal websites with lax censorship. There may be many places in the HTML source code of their web pages that are not written in a standardized manner. Therefore, many existing text extraction technologies can only achieve good results on a certain type of website, and their versatility needs to be improved.

[0004] Therefore, how to effectively identify various noises in web page source codes and eliminate the interference of different web page formats to achieve batch web page text extraction is an important issue faced in the field of web page text positioning. Summary of the invention

[0005] Based on this, it is necessary to provide a method, device and computer equipment for locating web page text based on sequence annotation to address the above technical problems.

[0006] A method for locating webpage text based on sequence annotation, the method comprising:

[0007] Using a pre-set regular expression rule table to match the webpage source code to obtain text content, and classifying and extracting the text content to obtain the text content contained in the text content;

[0008] Training the HMM model according to the text content to obtain a trained HMM model;

[0009] According to the trained HMM model, the Viterbi algorithm is used to calculate the probability of the word at each position in the text content under each label, and the label with the largest probability is selected to mark the word;

[0010] Determine the content of the main text of the web page based on the marking of all words in the main text.

[0011] In one of the embodiments, it also includes: using an LSTM model of the Tensorflow library to classify and extract the text content to obtain the main text content contained in the text content.

[0012] In one of the embodiments, it also includes: setting a state set of the HMM model according to all labels of the words in the text content; setting an observation set of the HMM model according to the word set of all words in the text content; setting an initial label probability of the HMM model according to the probability that the first word in the text content belongs to each label; setting a transition probability matrix of the HMM model according to the label changes of adjacent words in the text content; setting an emission probability matrix of the HMM model according to the probability of each word in the word set in the text content appearing in the current label; initializing the state set, observation set, initial label probability, transition probability matrix and emission probability matrix in the HMM model according to the sample data of the text content acquired in advance to obtain a trained HMM model.

[0013] In one embodiment, the method further includes: calculating the initial position The label probability of the word and the pre-label probability are:

[0014] ;

[0015] in, Indicates the initial position Words belong to tags The probability of represents the initial label probability, Represents the observation value in the observation set Belongs to the tag The emission probability matrix, Indicates the preceding label;

[0016] Calculate position The label probability of the word and the pre-label probability are:

[0017] ;

[0018] After all positions are calculated, the hidden state with the maximum probability is found as the final output:

[0019] ;

[0020] According to the maximum probability value and optimal path information recorded, the most likely hidden state sequence corresponding to the entire observation sequence is obtained by backtracking:

[0021] ;

[0022] A webpage text positioning device based on sequence annotation, the device comprising:

[0023] A text preprocessing module is used to match the webpage source code with a pre-set regular expression rule table to obtain text content, and to classify and extract the text content to obtain the text content contained in the text content;

[0024] A model training module is used to train the HMM model according to the text content to obtain a trained HMM model;

[0025] A labeling module is used to calculate the probability of each word at each position in the text content under each label according to the trained HMM model using the Viterbi algorithm, and select the label with the largest probability to label the word;

[0026] The positioning module is used to determine the content of the main text of the web page based on the annotations of all words in the main text.

[0027] In one of the embodiments, the text preprocessing module is also used to classify and extract the text content using the LSTM model of the Tensorflow library to obtain the main text content contained in the text content.

[0028] In one of the embodiments, the model training module is further used to set a state set of the HMM model according to all labels of the words in the text content;

[0029] According to the word set of all words in the text content, an observation set of the HMM model is set;

[0030] According to the probability that the first word in the text content belongs to each label, the initial label probability of the HMM model is set;

[0031] According to the label changes of adjacent words in the text content, a transition probability matrix of the HMM model is set;

[0032] According to the probability of each word in the word set in the text content appearing in the current label, setting the emission probability matrix of the HMM model;

[0033] The state set, observation set, initial label probability, transition probability matrix and emission probability matrix in the HMM model are initialized according to the sample data of the text content acquired in advance to obtain a trained HMM model.

[0034] In one embodiment, the annotation module is also used to calculate the initial position t =1, and the label probability of the preceding label is:

[0035] ;

[0036] in, Indicates the initial position Words belong to tags The probability of represents the initial label probability, Represents the observation value in the observation set Belongs to the tag The emission probability matrix, Indicates the preceding label;

[0037] Calculate position The label probability of the word and the pre-label probability are:

[0038] ;

[0039] After all positions are calculated, the hidden state with the maximum probability is found as the final output:

[0040] ;

[0041] According to the maximum probability value and optimal path information recorded, the most likely hidden state sequence corresponding to the entire observation sequence is obtained by backtracking:

[0042] ;

[0043] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of a method when executing the computer program:

[0044] Using a pre-set regular expression rule table to match the webpage source code to obtain text content, and classifying and extracting the text content to obtain the text content contained in the text content;

[0045] Training the HMM model according to the text content to obtain a trained HMM model;

[0046] According to the trained HMM model, the Viterbi algorithm is used to calculate the probability of the word at each position in the text content under each label, and the label with the largest probability is selected to mark the word;

[0047] Determine the content of the main text of the web page based on the marking of all words in the main text.

[0048] The above-mentioned web page text positioning method, device and computer equipment based on sequence annotation first construct a regular expression to extract the corresponding text fragments from the source code. Since only a small part of the extracted fragments contain the text content to be extracted, these fragments are also classified, and the fragments that truly contain the text content are screened out based on the difference between the text and non-text fragments. Secondly, all parameters used in the HMM model are assigned and initialized using the training set. Finally, the Viterbi algorithm is used to calculate the probability that each word in the text fragment belongs to different labels, and the largest probability is selected for sequence annotation, and all the content belonging to the text is located according to the category of the label. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] Figure 1 is a schematic flow chart of a method for locating web page text based on sequence annotation in one embodiment;

[0050] Figure 2 It is an overall flow chart of a method for locating webpage text based on sequence annotation in one embodiment;

[0051] Figure 3 A diagram of a web page source code preprocessing framework in one embodiment;

[0052] Figure 4 A schematic diagram of a source code text fragment with nested tags in one embodiment;

[0053] Figure 5 It is a structural block diagram of a web page text positioning device based on sequence annotation in one embodiment;

[0054] Figure 6 The figure is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0055] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0056] In one embodiment, if Figure 1 As shown, a web page text positioning method based on sequence annotation is provided, comprising:

[0057] Step 102, using a preset regular expression rule table to match the web page source code to obtain text content, and classifying and extracting the text content to obtain the text content contained in the text content.

[0058] Step 104, training the HMM model according to the text content to obtain a trained HMM model.

[0059] Step 106, based on the trained HMM model, the Viterbi algorithm is used to sequentially calculate the probability of the word at each position in the text content under each label, and the label with the largest probability is selected to mark the word.

[0060] Step 108, determining the content of the web page body according to the annotations of all words in the body content.

[0061] The above-mentioned web page text location method based on sequence annotation first constructs a regular expression to extract the corresponding text fragments from the source code. Since only a small part of the extracted fragments contain the text content to be extracted, these fragments are also classified, and the fragments that truly contain the text content are screened out based on the difference between the text and non-text fragments. Secondly, all parameters used in the HMM model are assigned and initialized using the training set. Finally, the Viterbi algorithm is used to calculate the probability that each word in the text fragment belongs to different labels, and the largest probability is selected for sequence annotation, and all the content belonging to the text is located according to the label category.

[0062] The main work of the present invention is to annotate the web page source code word by word to locate the text content. The specific process can be divided into three parts: web page source code preprocessing, HMM model pretraining and sequence annotation. Figure 2 shown.

[0063] Web page source code preprocessing:

[0064] Perform some preprocessing on the long webpage source text crawled from the website to shorten the length of the text that needs to be annotated, such as Figure 3 As shown, this step can be divided into two parts: regular extraction and classification reduction.

[0065] (1) Regular extraction

[0066] The main purpose of regular extraction is to find out the fragments in the web page source code that may contain the main text content, so as to shorten the length of the text for sequence annotation. By analyzing the source code of web pages with different structural layouts, the main text content in the web page is generally concentrated in 、 、 、 <article>Among these four tags, corresponding regular expression rules for regular matching expressions can be formulated:

[0067]

[0068] It should be noted that there may be some formatting information inside the tag, so In Indicates that the match is except Any character except 0 or more times, The modifier is used to make the period match all characters including line breaks, ensuring that multi-line text content can be correctly matched.

[0069] (2) Classification reduction

[0070] The main purpose of classification reduction is to filter out the fragments extracted from regular extraction that do not contain the main text content. Among the text fragments obtained by regular extraction, the fragments containing the main text account for less than 1% of all the extracted fragments, so filtering is required. Due to the significant difference in features between the main text and non-main text fragments, this stage uses the LSTM model of the widely used Tensorflow library in Python for classification. From the classification results, the accuracy of text fragment classification can reach 97.8%, which can effectively filter out non-text fragments to ensure the subsequent sequence labeling. After obtaining the classified text fragments, it is also necessary to consider a nested special case such as Figure 4 As shown, in this case, multiple body fragments may contain the same body content.

[0071] It can be seen that when a tag contains another tag extracted by regular expression, the text content contained in the two text segments extracted by regular expression is actually repeated. This can be avoided by looping through any two segments, and if one segment contains the content of another segment, the longer one is retained to avoid repeated interference.

[0072] HMM model pre-training:

[0073] To perform sequence labeling on the preprocessed text fragments, you first need to assign values ​​to the key parameters required in the HMM model. The following parameters can be initialized and assigned values ​​through the training set data:

[0074] (1) State set: HMM contains a state set consisting of states, which are abstract representations of visible states or observed states in the model. In sequence labeling, the set of hidden states is all possible label types.

[0075] ;

[0076] (2) Observation set: Each state generates an observation, which can be a discrete symbol or a continuous value. In sequence labeling, the observation set is all the words that the label may correspond to, that is, the dictionary.

[0077]

[0078] (3) Label probability corresponding to the first word: refers to the probability that the first word in the text to be annotated belongs to each label.

[0079] ;

[0080] Where count is the counting function, The superscript indicates That is, the first word, the subscript represents the i-th label, so the above formula calculates the i-th label in all training texts. hour The number of times a label appears is proportional to the total number of training samples.

[0081] (4) Transition probability matrix A: describes the probability distribution of transition from one state to another. In sequence labeling, the transition of a state represents the change in the label between two adjacent words, that is, when a word has a certain label, the probability that the next word following it will also have a certain label.

[0082] ;

[0083] Transfer Matrix Middle Line Probability of the column Represents the labels in all training data The label is right behind The number of times is higher than the label Number of occurrences.

[0084] (5) Emission probability matrix B: describes the probability distribution of generating observations in each state. In sequence labeling, the emission probability refers to the probability that a word under a certain label is a word in the dictionary.

[0085] ;

[0086] Transmitting Matrix Middle Line Probability of the column Represents all words in the training data Tag The number of times is higher than the label Number of occurrences.

[0087] At this point, the pre-training of all parameters required for sequence prediction of the HMM model has been completed.

[0088] Text sequence annotation:

[0089] After completing the pre-training of the HMM model, you only need to use the Viterbi algorithm to calculate the probability of each word at each position under each label and the preceding label of this probability, then label the word at the last position with the label with the highest probability and then backtrack to obtain other labels on this result path to obtain the final label sequence. The specific steps for predicting labels using the Viterbi algorithm are as follows:

[0090] (1) Initialization: Assume that Indicates the word position subscript of the current tag to be estimated. For the initial position , calculate the initial probability of each hidden state. When , the probability of each label is The initial probability is multiplied by the probability of the first word in the emission matrix being labeled with this label, the preceding label Then it is 0.

[0091] ;

[0092] in Indicates that at position t The maximum probability among all local paths ending with a label, express The predecessor state of the optimal path at the position, that is, the label of the previous word.

[0093] (2) Recursion: From First, for each position , calculate the maximum probability path to each hidden state, and record the maximum probability value on the path. When , the probability of each label can be iterated according to the algorithm. Represents the maximum probability among all possible paths from the previous label to this label, That is the preceding label corresponding to the maximum probability.

[0094] ;

[0095] One point that needs to be noted here is that in actual sequence tagging, the text to be annotated may contain words that are not in the dictionary. For this case, the unified assumption is , Therefore, the tags and formats of general HTML codes have relatively fixed syntax. If the amount of data is sufficient, no new situations will appear. Therefore, if new words appear, they generally belong to the main text. The above probability is finally set based on the ratio of the beginning and the middle part of a paragraph of text.

[0096] (3) Termination: After all time steps are calculated, the hidden state with the maximum probability at the last position t = T is found as the final output.

[0097] ;

[0098] in Indicates the final The maximum probability of all labels at the position, It represents the label with the maximum probability.

[0099] (4) Backtracking: Based on the recorded maximum probability value and optimal path information, backtrack to obtain the most likely hidden state sequence corresponding to the entire observation sequence.

[0100] ;

[0101] in That is the final predicted label at position t.

[0102] Through the above steps, you can label each word in the text segment, and then you only need to select the content under the TEXT tag to get the required text.

[0103] It should be understood that although Figure 1 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0104] In one embodiment, Figure 5 As shown, a web page text positioning device based on sequence annotation is provided, comprising: a text preprocessing module 502, a model training module 504, a labeling module 506 and a positioning module 508, wherein:

[0105] The text preprocessing module 502 is used to match the webpage source code with a preset regular expression rule table to obtain text content, and to classify and extract the text content to obtain the text content contained in the text content;

[0106] A model training module 504 is used to train the HMM model according to the text content to obtain a trained HMM model;

[0107] The tagging module 506 is used to calculate the probability of each word at each position in the text content under each label according to the trained HMM model by using the Viterbi algorithm, and select the label with the largest probability to tag the word;

[0108] The positioning module 508 is used to determine the content of the web page body according to the annotations of all words in the body content.

[0109] In one embodiment, the text preprocessing module 502 is further used to classify and extract the text content using the LSTM model of the Tensorflow library to obtain the main text content contained in the text content.

[0110] In one embodiment, the model training module 504 is further used to set a state set of the HMM model according to all labels of the words in the text content;

[0111] According to the word set of all words in the text content, an observation set of the HMM model is set;

[0112] According to the probability that the first word in the text content belongs to each label, the initial label probability of the HMM model is set;

[0113] According to the label changes of adjacent words in the text content, a transition probability matrix of the HMM model is set;

[0114] According to the probability of each word in the word set in the text content appearing in the current label, setting the emission probability matrix of the HMM model;

[0115] The state set, observation set, initial label probability, transition probability matrix and emission probability matrix in the HMM model are initialized according to the sample data of the text content acquired in advance to obtain a trained HMM model.

[0116] In one embodiment, the annotation module 506 is also used to calculate the initial position t =1, and the label probability of the preceding label is:

[0117] ;

[0118] in, Indicates the initial position Words belong to tags The probability of represents the initial label probability, Represents the observation value in the observation set Belongs to the tag The emission probability matrix, Indicates the preceding label;

[0119] Calculate position The label probability of the word and the pre-label probability are:

[0120] ;

[0121] After all positions are calculated, the hidden state with the maximum probability is found as the final output:

[0122] ;

[0123] According to the maximum probability value and optimal path information recorded, the most likely hidden state sequence corresponding to the entire observation sequence is obtained by backtracking:

[0124] ;

[0125] For the specific definition of the web page text locating device based on sequence annotation, please refer to the definition of the web page text locating method based on sequence annotation in the above text, which will not be repeated here. Each module in the above-mentioned web page text locating device based on sequence annotation can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0126] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 6 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for locating the body of a web page based on sequence annotation is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covered on the display screen, or a key, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse, etc.

[0127] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0128] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method in the above embodiment when executing the computer program.

[0129] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0130] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0131] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.< / article>

Claims

1. A web page text positioning method based on sequence annotation, characterized in that: The method comprises: Using a pre-set regular expression rule table to match the webpage source code to obtain text content, and classifying and extracting the text content to obtain the text content contained in the text content; Training the HMM model according to the text content to obtain a trained HMM model; Training an HMM model according to the text content to obtain a trained HMM model includes: setting a state set of the HMM model according to all labels of words in the text content; setting an observation set of the HMM model according to a word set of all words in the text content; setting an initial label probability of the HMM model according to the probability that the first word in the text content belongs to each label; setting a transition probability matrix of the HMM model according to label changes of adjacent words in the text content; setting an emission probability matrix of the HMM model according to the probability that each word in the word set in the text content appears in the current label; initializing the state set, observation set, initial label probability, transition probability matrix and emission probability matrix in the HMM model according to sample data of the text content acquired in advance to obtain a trained HMM model; According to the trained HMM model, the Viterbi algorithm is used to calculate the probability of the word at each position in the text content under each label, and the label with the largest probability is selected to mark the word; Determine the content of the main text of the web page based on the marking of all words in the main text.

2. The method according to claim 1, characterized in that Classify and extract the text content to obtain the text content contained in the text content, including: The LSTM model of the Tensorflow library is used to classify and extract the text content to obtain the main text content contained in the text content.

3. The method according to claim 1, characterized in that: The Viterbi algorithm is used to sequentially calculate the probability of a word at each position in the text content under each label, including: Calculate the initial position t =1, and the label probability of the preceding label is: in, Indicates the initial position t =1 word belongs to tag i The probability of represents the initial label probability, Represents the observation value in the observation set Belongs to the tag i The emission probability matrix, represents the probability of the previous label; Calculate position The label probability of the word and the pre-label probability are: in, Represents the labels in all training data The label is right behind The number of times is greater than the number of times label j appears; After all positions are calculated, the hidden state with the maximum probability is found as the final output: represents the maximum probability of all labels at the final T position, It represents the label with the maximum probability; According to the maximum probability value and optimal path information recorded, the most likely hidden state sequence corresponding to the entire observation sequence is obtained by backtracking: in, is the final predicted label at position t.

4. A web page text positioning device based on sequence annotation, characterized in that: The device comprises: A text preprocessing module is used to match the webpage source code with a pre-set regular expression rule table to obtain text content, and to classify and extract the text content to obtain the text content contained in the text content; A model training module is used to train the HMM model according to the text content to obtain a trained HMM model; the model training module is specifically used to set the state set of the HMM model according to all labels of the words in the text content; set the observation set of the HMM model according to the word set of all words in the text content; set the initial label probability of the HMM model according to the probability that the first word in the text content belongs to each label; set the transition probability matrix of the HMM model according to the label changes of adjacent words in the text content; set the emission probability matrix of the HMM model according to the probability that each word in the word set in the text content appears in the current label; initialize the state set, observation set, initial label probability, transition probability matrix and emission probability matrix in the HMM model according to the sample data of the text content obtained in advance to obtain a trained HMM model; A labeling module is used to calculate the probability of each word at each position in the text content under each label according to the trained HMM model using the Viterbi algorithm, and select the label with the largest probability to label the word; The positioning module is used to determine the content of the main text of the web page based on the annotations of all words in the main text.

5. The device according to claim 4, characterized in that The text preprocessing module is also used to classify and extract the text content using the LSTM model of the Tensorflow library to obtain the main text content contained in the text content.

6. The device according to claim 4, characterized in that The annotation module is also used to calculate the initial position t =1, and the label probability of the preceding label is: in, Indicates the initial position t =1 word belongs to tag i The probability of represents the initial label probability, Represents the observation value in the observation set Belongs to the tag i The emission probability matrix, represents the probability of the previous label; Calculate position The label probability of the word and the pre-label probability are: in, Represents the labels in all training data The label is right behind The number of times is greater than the number of times label j appears; After all positions are calculated, the hidden state with the maximum probability is found as the final output: represents the maximum probability of all labels at the final T position, It represents the label with the maximum probability; According to the maximum probability value and optimal path information recorded, the most likely hidden state sequence corresponding to the entire observation sequence is obtained by backtracking: in, is the final predicted label at position t.

7. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 3 are implemented.