A processing method, device, equipment and medium for character recognition in web pages
By converting web page documents into document object model tree and analyzing subtree collections, the problem of extracting character information from corporate web pages is solved, and the function of accurately extracting character-related information in web pages is realized.
Patent Information
- Application Number
- CN202411111528.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-14
- Publication Date
- 2024-12-20
- Estimated Expiration
- 2044-08-14
AI Technical Summary
It is difficult to extract relevant information from each person in the core management team from the HTML documents of the enterprise web page, such as name and identity.
By converting the target web page document into a document object model tree, we can judge whether the node meets specific conditions in the order from top to bottom, obtain the set of subtrees that meet the conditions, and obtain the character's information by parsing each subtree in the subtree collection. Including gender, age and identity information.
It realizes the accurate locking of the subtree of the characters displayed in the web page, and parsing and extracting the relevant information of the characters on the web page, improving the accuracy and efficiency of information extraction.
Smart Images

Figure CN118626742B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of electronic digital data processing, and in particular to a processing method, device, equipment and medium for character recognition in a web page. Background Art
[0002] In the prior art, some corporate web pages not only display the company's history, products, news and contact information, but also display the company's core management team, which often includes multiple people, such as the company's CEO, CFO, CTO, directors, etc. HTML is a standard markup language for creating web pages. How to extract relevant information (such as the name and identity of each person in the core management team) from the HTML document of the corporate web page is an urgent problem to be solved. Summary of the invention
[0003] The present invention aims to provide a method, device, equipment and medium for processing character recognition in a web page, so as to extract relevant information of a character displayed on the web page from the HTML document of the web page.
[0004] According to a first aspect of the present invention, a method for processing character recognition in a web page is provided, the method comprising the following steps:
[0005] Obtain a target web page document; the target web page document is a web page document in HTML language.
[0006] Obtain a document object model tree corresponding to the target web page document; the document object model tree includes a plurality of nodes.
[0007] Determine whether the nodes in the document object model tree meet the first preset condition in order from the root node of the document object model tree downward. If not, continue to judge the next node; otherwise, stop judging; the first preset condition includes: the node includes more than or equal to 2 child nodes, and the types of the child nodes included in the node are all the same.
[0008] If there is a node that meets the first preset condition in the document object model tree, a subtree set corresponding to the node that meets the first preset condition is obtained; the number of subtrees in the subtree set is the number of child nodes included in the node that meets the first preset condition, and the root node of each subtree in the subtree set is a child node of the node that meets the first preset condition.
[0009] Determine whether the subtree set meets a second preset condition; the second preset condition includes: the number of nodes included in different subtrees in the subtree set is the same, the types of nodes included in different subtrees in the subtree set are the same, and the positions of the nodes of the same type included in different subtrees in the subtree set in the corresponding subtrees are the same.
[0010] If the subtree set meets the second preset condition, it is determined whether each subtree in the subtree set meets a third preset condition; the third preset condition includes: each subtree in the subtree set includes a node of a first preset type.
[0011] If each subtree in the subtree set satisfies the third preset condition, it is determined that each subtree in the subtree set corresponds to a character, and each subtree in the subtree set is parsed to obtain information of the character corresponding to each subtree in the subtree set.
[0012] Furthermore, the nodes of the first preset type include picture type nodes, and the third preset condition also includes: the number of picture type nodes included in each subtree in the subtree set is 1, the picture corresponding to the picture type node included in each subtree in the subtree set contains only one person's head portrait, and the similarity of the backgrounds of the pictures corresponding to the picture type nodes included in different subtrees in the subtree set is greater than or equal to a preset similarity threshold.
[0013] Further, parsing each subtree in the subtree set includes:
[0014] A first picture corresponding to a picture type node of a first subtree in the subtree set is obtained; the first subtree in the subtree set is a subtree in the subtree set.
[0015] The gender and age of the person in the first picture are obtained.
[0016] A first title corresponding to a title type node of a first subtree in the subtree set is obtained; the first title corresponds to a plurality of title type nodes.
[0017] Use the trained named entity recognition model to identify the names of people present in the first title.
[0018] Use a string matching algorithm to determine whether identity information exists in the first title.
[0019] If there is identity information in the first title, extract the identity information in the first title; otherwise, obtain the first paragraph corresponding to the paragraph type node of the first subtree in the subtree set, and extract the identity information from the first paragraph; the first paragraph corresponds to several paragraph type nodes.
[0020] Further, if the subtree set does not satisfy the second preset condition or each subtree in the subtree set does not satisfy the third preset condition, it is continued to be determined whether the child nodes of the node satisfying the first preset condition satisfy the first preset condition.
[0021] Furthermore, before determining in order from the root node of the document object model tree downward whether the nodes in the document object model tree meet the first preset condition, the processing method also includes: deleting nodes from the document object model tree, and the deleting nodes includes: deleting nodes in the document object model tree whose type belongs to a second preset type.
[0022] According to a second aspect of the present invention, a processing device for character recognition in a web page is provided, the processing device comprising:
[0023] The first acquisition module is used to acquire a target web page document; the target web page document is a web page document in HTML language.
[0024] The second acquisition module is used to acquire a document object model tree corresponding to the target web page document; the document object model tree includes a plurality of nodes.
[0025] The first judgment module is used to judge whether the nodes in the document object model tree meet the first preset condition in order from the root node of the document object model tree downward. If not, continue to judge the next node; otherwise, stop judging; the first preset condition includes: the node includes more than or equal to 2 child nodes, and the types of the child nodes included in the node are all the same.
[0026] The third acquisition module is used to obtain a subtree set corresponding to the node that meets the first preset condition if there is a node that meets the first preset condition in the document object model tree; the number of subtrees in the subtree set is the number of child nodes included in the node that meets the first preset condition, and the root node of each subtree in the subtree set is a child node of the node that meets the first preset condition.
[0027] The second judgment module is used to judge whether the subtree set meets the second preset condition; the second preset condition includes: the number of nodes included in different subtrees in the subtree set is the same, the types of nodes included in different subtrees in the subtree set are the same, and the positions of the nodes of the same type included in different subtrees in the subtree set in the corresponding subtrees are the same.
[0028] The third judgment module is used to judge whether each subtree in the subtree set meets a third preset condition if the subtree set meets the second preset condition; the third preset condition includes: each subtree in the subtree set includes a node of a first preset type.
[0029] The parsing module is used to determine that each subtree in the subtree set corresponds to a character if each subtree in the subtree set satisfies the third preset condition, and parse each subtree in the subtree set to obtain information of the character corresponding to each subtree in the subtree set.
[0030] Furthermore, the nodes of the first preset type include picture type nodes, and the third preset condition also includes: the number of picture type nodes included in each subtree in the subtree set is 1, the picture corresponding to the picture type node included in each subtree in the subtree set contains only one person's head portrait, and the similarity of the backgrounds of the pictures corresponding to the picture type nodes included in different subtrees in the subtree set is greater than or equal to a preset similarity threshold.
[0031] Furthermore, the parsing module includes:
[0032] The fourth acquisition module is used to acquire the first picture corresponding to the picture type node of the first subtree in the subtree set; the first subtree in the subtree set is a subtree in the subtree set.
[0033] The fifth acquisition module is used to acquire the gender and age of the person in the first picture.
[0034] The sixth acquisition module is used to acquire the first title corresponding to the title type node of the first subtree in the subtree set; the first title corresponds to a plurality of title type nodes.
[0035] A recognition module is used to recognize a person name present in the first title using a trained named entity recognition model.
[0036] The fourth judgment module is used to use a string matching algorithm to judge whether there is identity information in the first title.
[0037] The extraction module is used to extract the identity information in the first title if there is identity information in the first title; otherwise, obtain the first paragraph corresponding to the paragraph type node of the first subtree in the subtree set, and extract the identity information from the first paragraph; the first paragraph corresponds to a plurality of paragraph type nodes.
[0038] Furthermore, the second judgment module is also used to continue to judge whether the child nodes of the nodes that meet the first preset condition meet the first preset condition if the subtree set does not meet the second preset condition; the third judgment module is also used to continue to judge whether the child nodes of the nodes that meet the first preset condition meet the first preset condition if each subtree in the subtree set does not meet the third preset condition.
[0039] Furthermore, the processing device also includes a deletion module, which is located between the second acquisition module and the first judgment module. The deletion module is used to delete nodes from the document object model tree, and the node deletion process includes: deleting nodes in the document object model tree that belong to a second preset type.
[0040] According to a third aspect of the present invention, there is provided an electronic device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned method for processing person recognition in a web page when executing the computer program.
[0041] According to a fourth aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processing method for identifying a person in a web page is implemented.
[0042] Compared with the prior art, the present invention has at least the following beneficial effects:
[0043] The present invention first converts the target web page document into a corresponding document object model tree, and sequentially judges the nodes in the document object model tree in order from top to bottom. If a certain node includes multiple child nodes of the same type, then the subtree set corresponding to the node is obtained, and it is judged whether the number of nodes included in different subtrees in the subtree set is the same, whether the types of the included nodes are the same, and whether the positions of the nodes of the same type included in the corresponding subtree are the same; if all of them are satisfied, then it is further judged whether each subtree in the subtree set includes a node of the first preset type. If it is included, it is determined that each subtree in the subtree set corresponds to a character, and the information of the character corresponding to each subtree is obtained by parsing each subtree in the subtree set. Therefore, the present invention can accurately lock the subtree that displays the character in the document object model tree corresponding to the target web page document, and realize the function of extracting the relevant information of the character displayed in the web page by parsing the subtree that displays the character. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0045] Figure 1 A flowchart of a method for processing person recognition in a web page provided by Embodiment 1 of the present invention;
[0046] Figure 2 A flowchart of the steps of a process for determining whether the similarity of the backgrounds of images is greater than or equal to a preset similarity threshold provided in the first embodiment of the present invention;
[0047] Figure 3 A flowchart of the steps of parsing each subtree in the subtree set provided in the first embodiment of the present invention;
[0048] Figure 4 A schematic diagram of a processing device for identifying people in a web page provided in Embodiment 2 of the present invention;
[0049] Figure 5 A schematic diagram of a module for determining whether the similarity of the backgrounds of pictures is greater than or equal to a preset similarity threshold provided in the second embodiment of the present invention;
[0050] Figure 6 A schematic diagram of an analysis module provided in Embodiment 2 of the present invention. DETAILED DESCRIPTION
[0051] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0052] Embodiment 1:
[0053] According to this embodiment, Figure 1 As shown, a method for processing character recognition in a web page is provided, and the processing method comprises the following steps:
[0054] S100, obtaining a target web page document; the target web page document is a web page document in HTML language.
[0055] In this embodiment, the target web page document is a web page document in HTML language. Those skilled in the art know that HTML is a standard markup language for creating web pages, which uses a series of tags and elements to define the structure and content of a web page.
[0056] In this embodiment, the target web page document is a web page document for which character information extraction is to be performed. The target web page document may or may not include information of multiple characters.
[0057] S200, obtaining a document object model tree corresponding to a target web page document; the document object model tree includes a plurality of nodes.
[0058] The Document Object Model (DOM) tree is a way to describe a web document in HTML language. Those skilled in the art know that any method in the prior art for converting a web document in HTML language into a corresponding Document Object Model tree falls within the protection scope of the present invention. In the Document Object Model tree, each HTML element, attribute and text is represented as a node, and these nodes form a tree according to their hierarchical relationship in the document, namely the Document Object Model tree.
[0059] S300, judging whether the nodes in the document object model tree meet the first preset condition in order from the root node of the document object model tree downward, if not, continue to judge the next node; otherwise, stop judging; the first preset condition includes: the node includes more than or equal to 2 child nodes, and the types of the child nodes included in the node are all the same.
[0060] In this embodiment, whether the nodes in the document object model tree meet the first preset condition is judged in order from the root node of the document object model tree downward, that is, whether the nodes in the document object model tree meet the first preset condition is judged in order from top to bottom, that is, the top-level node is judged first, if the top-level node does not meet the first preset condition, then the nodes in the second layer are judged, if the nodes in the second layer do not meet the first preset condition, then the nodes in the third layer are judged, and so on, until a node in a certain layer of the document object model tree meets the first preset condition or all the nodes of the document object model tree are judged and do not meet the first preset condition.
[0061] As a specific implementation, the document object model tree includes node types such as html (document root element type), head (header type), title (header title type), body (main body type), main (main area type), section (partial area type), img (picture type), h1 (main body title type), h2 (main body sub-title type), p (paragraph type), script (script type), select (selection box type), input (input type), etc. For example, if a node type of the document object model tree is main, and the node includes 3 child nodes, all of which are section types, then the node meets the first preset condition.
[0062] As a preferred specific implementation, before S300, the processing method further includes: deleting nodes from the document object model tree, and the node deletion processing includes: deleting nodes in the document object model tree that belong to a second preset type. Optionally, the second preset type includes: script, style (style type), br (line break type), select, input, label (form type), comment (comment type), nav (navigation link type). Based on this preferred specific implementation, nodes in the document object model tree that are not related to characters can be excluded, which is conducive to quickly locating the positions of nodes related to characters in the document object model tree, and improving the accuracy and efficiency of the processing method.
[0063] S400, if there is a node that meets the first preset condition in the document object model tree, obtain a subtree set corresponding to the node that meets the first preset condition; the number of subtrees in the subtree set is the number of child nodes included in the node that meets the first preset condition, and the root node of each subtree in the subtree set is a child node of the node that meets the first preset condition.
[0064] In this embodiment, if the node that meets the first preset condition includes n child nodes, then the subtree set corresponding to the node that meets the first preset condition includes n subtrees. For example, the type of the node that meets the first preset condition is main, and the node that meets the first preset condition includes 3 child nodes of type section, then the type of the root node of each subtree in the subtree set corresponding to the node that meets the first preset condition is section. If the above 3 child nodes of type section in the document object model tree include 3 child nodes of types img, h2 and p, respectively, and the child nodes of img, h2 and p do not include child nodes, then each subtree in the subtree set corresponding to the node that meets the first preset condition includes 4 nodes, the root node of each subtree is of type section, the second layer of each subtree includes 3 nodes, and the second layer includes 3 nodes of types img, h2 and p, respectively.
[0065] In this embodiment, if there is no node satisfying the first preset condition in the document object model tree, the steps of obtaining a subtree set and subsequent steps are no longer performed, and the processing method of this embodiment is terminated.
[0066] S500, determine whether the subtree set meets a second preset condition; the second preset condition includes: the number of nodes included in different subtrees in the subtree set is the same, the types of nodes included in different subtrees in the subtree set are the same, and the positions of the nodes of the same type included in different subtrees in the subtree set in the corresponding subtrees are the same.
[0067] In this embodiment, the subtree set is determined to meet the second preset condition only when the number of nodes included in different subtrees in the subtree set is the same, the types of nodes included in different subtrees in the subtree set are the same, and the positions of the nodes of the same type included in different subtrees in the subtree set are the same in the corresponding subtrees.
[0068] As a specific implementation, there are 3 subtrees in the subtree set, each subtree includes only 2 layers of nodes, and the root node of each subtree is of section type. The second layer of each subtree includes 3 nodes, and the types of the 3 nodes in the second layer are img, h2 and p respectively. Then the subtree set meets the second preset condition.
[0069] As a specific implementation, there are 3 subtrees in the subtree set, each subtree includes only 2 layers of nodes, and the root node type of each subtree is section, and the second layer of each subtree includes 3 nodes, but the types of the 3 nodes in the second layer of the first subtree are img, h2 and p respectively, while the types of the 3 nodes in the second layer of the second subtree and the third subtree are h2, img and p respectively, then the subtree set does not meet the second preset condition.
[0070] S600, if the subtree set satisfies the second preset condition, determine whether each subtree in the subtree set satisfies a third preset condition; the third preset condition includes: each subtree in the subtree set includes a node of a first preset type.
[0071] In this embodiment, if the subtree set does not satisfy the second preset condition, it is further determined whether the subnodes of the node satisfying the first preset condition satisfy the first preset condition.
[0072] In this embodiment, the first preset type is a preset type related to the introduction of the character. As a preferred specific implementation, the third preset condition also includes: each subtree includes a person's name and identity information; as a more preferred specific implementation, the node of the first preset type includes a picture type node, and the third preset condition also includes: the number of picture type nodes included in each subtree in the subtree set is 1, the picture corresponding to the picture type node included in each subtree in the subtree set contains only one character's head portrait, and the similarity of the backgrounds of the pictures corresponding to the picture type nodes included in different subtrees in the subtree set is greater than or equal to the preset similarity threshold.
[0073] As an optional specific implementation method, the content corresponding to the nodes of the title type and paragraph type included in each subtree is obtained, and a trained binary classification model is used to determine whether the content contains names and identity information. If so, it is determined that the corresponding subtree includes the names and identity information; if not, it is determined that the corresponding subtree does not include the names and identity information.
[0074] Those skilled in the art know that any face recognition method in the prior art falls within the protection scope of the present invention. Optionally, two or more face recognition methods are used to determine the number of faces in the image, and if the judgment results are all that only one person's head is included, then it is determined that the image contains only one person's head.
[0075] As a preferred specific implementation, the processing method further includes a process of determining whether the similarity of the background of the image is greater than or equal to a preset similarity threshold, such as Figure 2 As shown, the process includes:
[0076] S610, obtaining coordinates of background pixels of the first image.
[0077] In this embodiment, the first picture is a picture corresponding to a picture type node included in a subtree in the subtree set. Those skilled in the art know that any method of distinguishing background pixels from foreground pixels in the prior art falls within the protection scope of the present invention.
[0078] S620: Obtain coordinates of background pixels in the second image.
[0079] In this embodiment, the first picture is a picture corresponding to a picture type node included in another subtree in the subtree set.
[0080] In this embodiment, the second image has the same size and coordinates as the first image, and the coordinates of the pixels at the same position on the first image and the second image are the same.
[0081] S630, obtaining coordinates of common background pixel points corresponding to the first picture and the second picture; the common background pixel points corresponding to the first picture and the second picture are pixel points that are background pixel points in both the first picture and the second picture.
[0082] In this embodiment, if a pixel point on the first image is a background pixel point, but a pixel point at the same position on the second image is a foreground image, then the pixel point at this position is not a common background pixel point.
[0083] S640: Obtain a first color histogram of common background pixels in the first image.
[0084] In this embodiment, the first image is an RGB image, and the first color histogram of the common pixels of the first image includes three sub-histograms, namely, the first sub-histogram corresponding to the R channel, the first sub-histogram corresponding to the G channel, and the first sub-histogram corresponding to the B channel.
[0085] Those skilled in the art know that any method for obtaining a histogram in the prior art falls within the protection scope of the present invention.
[0086] S650: Obtain a second color histogram of common background pixels in the second image.
[0087] In this embodiment, the second image is an RGB image, and the second color histogram of the common pixels of the second image includes three sub-histograms, namely, the second sub-histogram corresponding to the R channel, the second sub-histogram corresponding to the G channel, and the second sub-histogram corresponding to the B channel.
[0088] S660, obtaining a first similarity between the first histogram and the second histogram. If the first similarity is greater than or equal to a preset similarity threshold, proceed to S670; otherwise, determining that the similarity of the background of the picture is less than the preset similarity threshold.
[0089] As a preferred specific implementation, the similarity sim1 between the first subhistogram and the second subhistogram corresponding to the R channel, the similarity sim2 between the first subhistogram and the second subhistogram corresponding to the G channel, and the similarity sim3 between the first subhistogram and the second subhistogram corresponding to the B channel are obtained respectively, and the mean of sim1, sim2 and sim3 is determined as the first similarity between the first histogram and the second histogram. Those skilled in the art know that any method for determining the similarity between two histograms in the prior art falls within the protection scope of the present invention.
[0090] Optionally, the preset similarity threshold is an empirical value. Optionally, the preset similarity threshold is 0.9.
[0091] S670, obtaining a gray value sequence A of a specified background pixel in the first image; A=[a1, a2, …, a i ,…,a z ], a i is the grayscale value of the i-th designated background pixel in the first image, the value range of i is 1 to z, and z is the number of designated background pixels; the designated background pixels are some of the common background pixels.
[0092] Those skilled in the art are aware that any method for obtaining the grayscale value of a pixel in the prior art falls within the protection scope of the present invention.
[0093] S680, obtaining a gray value sequence C of a specified background pixel point in the second image; C=[c1,c2,…,c i ,…,c z ], c i is the gray value of the i-th specified background pixel in the second image, c i with a i The coordinates are the same.
[0094] S690, obtaining a second similarity between A and C. If the second similarity is greater than or equal to a preset similarity threshold, determining that the similarity of the backgrounds of the images is greater than or equal to the preset similarity threshold; otherwise, determining that the similarity of the backgrounds of the images is less than the preset similarity threshold.
[0095] This embodiment further determines the similarity of the backgrounds of the first image and the second image based only on some of the background pixels of the first image and the second image, which is conducive to reducing the amount of calculation and improving the efficiency of determination. As a preferred specific implementation, the designated background pixels are edge pixels of several rectangular boxes included in the background area corresponding to the common background pixels. Based on this preferred specific implementation, it is conducive to improving the accuracy of determining the similarity of the background.
[0096] Those skilled in the art are aware that any method for obtaining sequence similarity in the prior art falls within the protection scope of the present invention.
[0097] The first similarity obtained based on S610-S660 can be used to judge whether the backgrounds of the first image and the second image are similar as a whole. If it is judged that the first similarity is less than the preset similarity threshold, it can be judged that the backgrounds of the first image and the second image are not similar. Only when the first similarity is greater than or equal to the preset similarity threshold, it is further judged based on S670-S690 whether some background pixel points (i.e., designated background pixel points) in the common background pixel points of the first image and the second image are similar. The process of further judging whether they are similar is a detailed judgment to avoid the situation where the pixel values of the pixels included in the backgrounds of the first image and the second image are similar but the positions are different, which is conducive to improving the accuracy of judging whether the backgrounds of the first image and the second image are similar.
[0098] S700: If each subtree in the subtree set satisfies the third preset condition, it is determined that each subtree in the subtree set corresponds to a person, and each subtree in the subtree set is analyzed to obtain information of the person corresponding to each subtree in the subtree set.
[0099] In this embodiment, if each subtree in the subtree set does not satisfy the third preset condition, it is continued to determine whether the child nodes of the node satisfying the first preset condition satisfy the first preset condition.
[0100] As a specific implementation, Figure 3 As shown, parsing each subtree in the subtree set includes:
[0101] S710, obtaining a first picture corresponding to a picture type node of a first subtree in the subtree set; the first subtree in the subtree set is a subtree in the subtree set.
[0102] S720: Obtain the gender and age of the person in the first picture.
[0103] Those skilled in the art know that any method for obtaining the gender and age of a person in a picture in the prior art falls within the protection scope of the present invention.
[0104] S730, obtaining a first title corresponding to a title type node of a first subtree in the subtree set; the first title corresponds to a plurality of title type nodes.
[0105] In this embodiment, if the first subtree includes m nodes of the title type, then the number of titles included in the first title is m. For example, if the first subtree includes only one node of the h2 node type, then m=1, and the first title refers to the title corresponding to the node of the h2 node type; for another example, if the first subtree includes one node of the h2 node type and one node of the h3 (third-level title type) node type, then m=2, and the first title refers to the title corresponding to the node of the h2 node type and the node of the h3 node type.
[0106] S740: Use the trained named entity recognition model to recognize the name of a person in the first title.
[0107] In this embodiment, the trained named entity recognition model has the function of recognizing a person's name. Those skilled in the art are aware that any named entity recognition model in the prior art falls within the protection scope of the present invention.
[0108] S750: Use a string matching algorithm to determine whether identity information exists in the first title.
[0109] In this embodiment, several identity strings are preset, and then a string matching algorithm is used to determine whether the preset identity string exists in the first title. Those skilled in the art know that any string matching algorithm in the prior art falls within the protection scope of the present invention.
[0110] S760, if the identity information exists in the first title, extract the identity information in the first title; otherwise, obtain the first paragraph corresponding to the paragraph type node of the first subtree in the subtree set, and extract the identity information from the first paragraph; the first paragraph corresponds to a plurality of paragraph type nodes.
[0111] In this embodiment, if the identity information does not exist in the first title, it is determined that the identity information of the task appears in the first paragraph corresponding to the node of the paragraph type of the first subtree. The number of paragraphs included in the first paragraph is greater than or equal to 1. If the number of nodes of the paragraph type in the first subtree is p, then the number of paragraphs included in the first paragraph is also p. As an optional specific implementation method, a string matching algorithm is used to extract the identity information in the first paragraph.
[0112] As an optional specific implementation, if the first subtree includes nodes of type anchor (link type), a regular expression is used to extract social links corresponding to the task, such as Weibo, Facebook, or Twitter.
[0113] As a preferred specific implementation, the name, gender, age, identity and social link information corresponding to each character is structured and stored. Optionally, the character information is stored in a relational database or knowledge graph.
[0114] This embodiment first converts the target web page document into a corresponding document object model tree, and judges the nodes in the document object model tree in order from top to bottom. If a node includes multiple child nodes of the same type, the subtree set corresponding to the node is obtained, and it is judged whether the number of nodes included in different subtrees in the subtree set is the same, whether the types of the included nodes are the same, and whether the positions of the nodes of the same type included in the corresponding subtree are the same; if all of them are satisfied, it is further judged whether each subtree in the subtree set includes a node of the first preset type. If it does, it is determined that each subtree in the subtree set corresponds to a character, and the information of the character corresponding to each subtree is obtained by parsing each subtree in the subtree set. Therefore, this embodiment can accurately lock the subtree that displays the character in the document object model tree corresponding to the target web page document, and realize the function of extracting the relevant information of the character displayed in the web page by parsing the subtree that displays the character.
[0115] Embodiment 2:
[0116] According to this embodiment, Figure 4 As shown, a processing device for character recognition in a web page is provided, and the processing device includes:
[0117] The first acquisition module 100 is used to acquire a target web page document; the target web page document is a web page document in HTML language.
[0118] In this embodiment, the target web page document is a web page document in HTML language. Those skilled in the art know that HTML is a standard markup language for creating web pages, which uses a series of tags and elements to define the structure and content of a web page.
[0119] In this embodiment, the target web page document is a web page document for which character information extraction is to be performed. The target web page document may or may not include information of multiple characters.
[0120] The second acquisition module 200 is used to acquire a document object model tree corresponding to the target web page document; the document object model tree includes a plurality of nodes.
[0121] The Document Object Model (DOM) tree is a way to describe a web document in HTML language. Those skilled in the art know that any method in the prior art for converting a web document in HTML language into a corresponding Document Object Model tree falls within the protection scope of the present invention. In the Document Object Model tree, each HTML element, attribute and text is represented as a node, and these nodes form a tree according to their hierarchical relationship in the document, namely the Document Object Model tree.
[0122] The first judgment module 300 is used to judge whether the nodes in the document object model tree meet the first preset condition in order from the root node of the document object model tree downward. If not, continue to judge the next node; otherwise, stop judging; the first preset condition includes: the node includes more than or equal to 2 child nodes, and the types of the child nodes included in the node are all the same.
[0123] In this embodiment, whether the nodes in the document object model tree meet the first preset condition is judged in order from the root node of the document object model tree downward, that is, whether the nodes in the document object model tree meet the first preset condition is judged in order from top to bottom, that is, the top-level node is judged first, if the top-level node does not meet the first preset condition, then the nodes in the second layer are judged, if the nodes in the second layer do not meet the first preset condition, then the nodes in the third layer are judged, and so on, until a node in a certain layer of the document object model tree meets the first preset condition or all the nodes of the document object model tree are judged and do not meet the first preset condition.
[0124] As a specific implementation, the document object model tree includes node types such as html (document root element type), head (header type), title (header title type), body (main body type), main (main area type), section (partial area type), img (picture type), h1 (main body title type), h2 (main body sub-title type), p (paragraph type), script (script type), select (selection box type), input (input type), etc. For example, if a node type of the document object model tree is main, and the node includes 3 child nodes, all of which are section types, then the node meets the first preset condition.
[0125] As a preferred specific implementation, the processing device also includes a module for deleting nodes from the document object model tree, and the node deletion process includes: deleting nodes in the document object model tree that belong to a second preset type. Optionally, the second preset type includes: script, style (style type), br (line break type), select, input, label (form type), comment (comment type), nav (navigation link type). Based on this preferred specific implementation, nodes in the document object model tree that are not related to characters can be excluded, which is conducive to quickly locating the positions of nodes related to characters in the document object model tree, and improving the accuracy and efficiency of the processing method.
[0126] The third acquisition module 400 is used to obtain a subtree set corresponding to the node that meets the first preset condition if there is a node that meets the first preset condition in the document object model tree; the number of subtrees in the subtree set is the number of child nodes included in the node that meets the first preset condition, and the root node of each subtree in the subtree set is a child node of the node that meets the first preset condition.
[0127] In this embodiment, if the node that meets the first preset condition includes n child nodes, then the subtree set corresponding to the node that meets the first preset condition includes n subtrees. For example, the type of the node that meets the first preset condition is main, and the node that meets the first preset condition includes 3 child nodes of type section, then the type of the root node of each subtree in the subtree set corresponding to the node that meets the first preset condition is section. If the above 3 child nodes of type section in the document object model tree include 3 child nodes of types img, h2 and p, respectively, and the child nodes of img, h2 and p do not include child nodes, then each subtree in the subtree set corresponding to the node that meets the first preset condition includes 4 nodes, the root node of each subtree is of type section, the second layer of each subtree includes 3 nodes, and the second layer includes 3 nodes of types img, h2 and p, respectively.
[0128] In this embodiment, if there is no node satisfying the first preset condition in the document object model tree, the steps of obtaining a subtree set and subsequent steps are no longer performed, and the processing method of this embodiment is terminated.
[0129] The second judgment module 500 is used to judge whether the subtree set meets the second preset condition; the second preset condition includes: the number of nodes included in different subtrees in the subtree set is the same, the types of nodes included in different subtrees in the subtree set are the same, and the positions of the nodes of the same type included in different subtrees in the subtree set in the corresponding subtrees are the same.
[0130] In this embodiment, the subtree set is determined to meet the second preset condition only when the number of nodes included in different subtrees in the subtree set is the same, the types of nodes included in different subtrees in the subtree set are the same, and the positions of the nodes of the same type included in different subtrees in the subtree set are the same in the corresponding subtrees.
[0131] As a specific implementation, there are 3 subtrees in the subtree set, each subtree includes only 2 layers of nodes, and the root node of each subtree is of section type. The second layer of each subtree includes 3 nodes, and the types of the 3 nodes in the second layer are img, h2 and p respectively. Then the subtree set meets the second preset condition.
[0132] As a specific implementation, there are 3 subtrees in the subtree set, each subtree includes only 2 layers of nodes, and the root node type of each subtree is section, and the second layer of each subtree includes 3 nodes, but the types of the 3 nodes in the second layer of the first subtree are img, h2 and p respectively, while the types of the 3 nodes in the second layer of the second subtree and the third subtree are h2, img and p respectively, then the subtree set does not meet the second preset condition.
[0133] The third judgment module 600 is used to judge whether each subtree in the subtree set meets a third preset condition if the subtree set meets the second preset condition; the third preset condition includes: each subtree in the subtree set includes a node of a first preset type.
[0134] In this embodiment, if the subtree set does not satisfy the second preset condition, it is further determined whether the subnodes of the node satisfying the first preset condition satisfy the first preset condition.
[0135] In this embodiment, the first preset type is a preset type related to the introduction of the character. As a preferred specific implementation, the third preset condition also includes: each subtree includes a person's name and identity information; as a more preferred specific implementation, the node of the first preset type includes a picture type node, and the third preset condition also includes: the number of picture type nodes included in each subtree in the subtree set is 1, the picture corresponding to the picture type node included in each subtree in the subtree set contains only one character's head portrait, and the similarity of the backgrounds of the pictures corresponding to the picture type nodes included in different subtrees in the subtree set is greater than or equal to the preset similarity threshold.
[0136] As an optional specific implementation method, the content corresponding to the nodes of the title type and paragraph type included in each subtree is obtained, and a trained binary classification model is used to determine whether the content contains names and identity information. If so, it is determined that the corresponding subtree includes the names and identity information; if not, it is determined that the corresponding subtree does not include the names and identity information.
[0137] Those skilled in the art know that any face recognition method in the prior art falls within the protection scope of the present invention. Optionally, two or more face recognition methods are used to determine the number of faces in the image, and if the judgment results are all that only one person's head is included, then it is determined that the image contains only one person's head.
[0138] As a preferred specific implementation, the processing device further includes a module for determining whether the similarity of the background of the picture is greater than or equal to a preset similarity threshold, such as Figure 5 As shown, the module for determining whether the similarity of the backgrounds of the pictures is greater than or equal to a preset similarity threshold comprises:
[0139] The first coordinate acquisition module 610 is used to acquire the coordinates of background pixels of the first image.
[0140] In this embodiment, the first picture is a picture corresponding to a picture type node included in a subtree in the subtree set. Those skilled in the art know that any method of distinguishing background pixels from foreground pixels in the prior art falls within the protection scope of the present invention.
[0141] The second coordinate acquisition module 620 is used to acquire the coordinates of background pixels in the second image.
[0142] In this embodiment, the first picture is a picture corresponding to a picture type node included in another subtree in the subtree set.
[0143] In this embodiment, the second image has the same size and coordinates as the first image, and the coordinates of the pixels at the same position on the first image and the second image are the same.
[0144] The third coordinate acquisition module 630 is used to obtain the coordinates of the common background pixel points corresponding to the first picture and the second picture; the common background pixel points corresponding to the first picture and the second picture are the pixel points that are background pixels on both the first picture and the second picture.
[0145] In this embodiment, if a pixel point on the first image is a background pixel point, but a pixel point at the same position on the second image is a foreground image, then the pixel point at this position is not a common background pixel point.
[0146] The first histogram acquisition module 640 is used to acquire a first color histogram of common background pixels in the first image.
[0147] In this embodiment, the first image is an RGB image, and the first color histogram of the common pixels of the first image includes three sub-histograms, namely, the first sub-histogram corresponding to the R channel, the first sub-histogram corresponding to the G channel, and the first sub-histogram corresponding to the B channel.
[0148] Those skilled in the art know that any method for obtaining a histogram in the prior art falls within the protection scope of the present invention.
[0149] The second histogram acquisition module 650 is used to acquire a second color histogram of common background pixels in the second image.
[0150] In this embodiment, the second image is an RGB image, and the second color histogram of the common pixels of the second image includes three sub-histograms, namely, the second sub-histogram corresponding to the R channel, the second sub-histogram corresponding to the G channel, and the second sub-histogram corresponding to the B channel.
[0151] The first similarity acquisition module 660 is used to obtain the first similarity between the first histogram and the second histogram. If the first similarity is greater than or equal to a preset similarity threshold, the first sequence acquisition module 670 is entered; otherwise, it is determined that the similarity of the background of the picture is less than the preset similarity threshold.
[0152] As a preferred specific implementation, the similarity sim1 between the first subhistogram and the second subhistogram corresponding to the R channel, the similarity sim2 between the first subhistogram and the second subhistogram corresponding to the G channel, and the similarity sim3 between the first subhistogram and the second subhistogram corresponding to the B channel are obtained respectively, and the mean of sim1, sim2 and sim3 is determined as the first similarity between the first histogram and the second histogram. Those skilled in the art know that any method for determining the similarity between two histograms in the prior art falls within the protection scope of the present invention.
[0153] Optionally, the preset similarity threshold is an empirical value. Optionally, the preset similarity threshold is 0.9.
[0154] The first sequence acquisition module 670 is used to acquire the gray value sequence A of the specified background pixel points in the first image; A=[a1, a2, ..., a i ,…,a z ], a i is the grayscale value of the i-th designated background pixel in the first image, the value range of i is 1 to z, and z is the number of designated background pixels; the designated background pixels are some of the common background pixels.
[0155] Those skilled in the art are aware that any method for obtaining the grayscale value of a pixel in the prior art falls within the protection scope of the present invention.
[0156] The second sequence acquisition module 680 is used to acquire the gray value sequence C of the specified background pixel points in the second image; C=[c1,c2,…,c i ,…,c z ], c i is the gray value of the i-th specified background pixel in the second image, c i with a i The coordinates are the same.
[0157] The second similarity acquisition module 690 is used to obtain the second similarity between A and C. If the second similarity is greater than or equal to a preset similarity threshold, it is determined that the similarity of the background of the picture is greater than or equal to the preset similarity threshold; otherwise, it is determined that the similarity of the background of the picture is less than the preset similarity threshold.
[0158] This embodiment further determines the similarity of the backgrounds of the first image and the second image based only on some of the background pixels of the first image and the second image, which is conducive to reducing the amount of calculation and improving the efficiency of determination. As a preferred specific implementation, the designated background pixels are edge pixels of several rectangular boxes included in the background area corresponding to the common background pixels. Based on this preferred specific implementation, it is conducive to improving the accuracy of determining the similarity of the background.
[0159] Those skilled in the art are aware that any method for obtaining sequence similarity in the prior art falls within the protection scope of the present invention.
[0160] The first similarity obtained based on modules 610-660 can determine whether the backgrounds of the first image and the second image are similar as a whole. If it is determined that the first similarity is less than the preset similarity threshold, it can be determined that the backgrounds of the first image and the second image are not similar. Only when the first similarity is greater than or equal to the preset similarity threshold, it is further determined based on modules 670-690 whether some background pixel points (i.e., designated background pixel points) in the common background pixel points of the first image and the second image are similar. The process of further determining whether they are similar is a detailed judgment to avoid the situation where the pixel values of the pixels included in the backgrounds of the first image and the second image are similar but the positions are different, which is conducive to improving the accuracy of the judgment on whether the backgrounds of the first image and the second image are similar.
[0161] The parsing module 700 is used to determine that each subtree in the subtree set corresponds to a character if each subtree in the subtree set satisfies the third preset condition, and parse each subtree in the subtree set to obtain information about the character corresponding to each subtree in the subtree set.
[0162] In this embodiment, if each subtree in the subtree set does not satisfy the third preset condition, it is continued to determine whether the child nodes of the node satisfying the first preset condition satisfy the first preset condition.
[0163] As a specific implementation, Figure 6 As shown, the parsing module includes:
[0164] The fourth acquisition module 710 is used to acquire a first picture corresponding to a picture type node of a first subtree in the subtree set; the first subtree in the subtree set is a subtree in the subtree set.
[0165] The fifth acquisition module 720 is used to acquire the gender and age of the person in the first picture.
[0166] Those skilled in the art know that any method for obtaining the gender and age of a person in a picture in the prior art falls within the protection scope of the present invention.
[0167] The sixth acquisition module 730 is used to acquire the first title corresponding to the title type node of the first subtree in the subtree set; the first title corresponds to a plurality of title type nodes.
[0168] In this embodiment, if the first subtree includes m nodes of the title type, then the number of titles included in the first title is m. For example, if the first subtree includes only one node of the h2 node type, then m=1, and the first title refers to the title corresponding to the node of the h2 node type; for another example, if the first subtree includes one node of the h2 node type and one node of the h3 (third-level title type) node type, then m=2, and the first title refers to the title corresponding to the node of the h2 node type and the node of the h3 node type.
[0169] The recognition module 740 is used to recognize the name of a person in the first title using the trained named entity recognition model.
[0170] In this embodiment, the trained named entity recognition model has the function of recognizing a person's name. Those skilled in the art are aware that any named entity recognition model in the prior art falls within the protection scope of the present invention.
[0171] The fourth determination module 750 is configured to use a string matching algorithm to determine whether there is identity information in the first title.
[0172] In this embodiment, several identity strings are preset, and then a string matching algorithm is used to determine whether the preset identity string exists in the first title. Those skilled in the art know that any string matching algorithm in the prior art falls within the protection scope of the present invention.
[0173] The extraction module 760 is used to extract the identity information in the first title if there is identity information in the first title; otherwise, obtain the first paragraph corresponding to the paragraph type node of the first subtree in the subtree set, and extract the identity information from the first paragraph; the first paragraph corresponds to a plurality of paragraph type nodes.
[0174] In this embodiment, if the identity information does not exist in the first title, it is determined that the identity information of the task appears in the first paragraph corresponding to the node of the paragraph type of the first subtree. The number of paragraphs included in the first paragraph is greater than or equal to 1. If the number of nodes of the paragraph type in the first subtree is p, then the number of paragraphs included in the first paragraph is also p. As an optional specific implementation method, a string matching algorithm is used to extract the identity information in the first paragraph.
[0175] As an optional specific implementation, if the first subtree includes nodes of type anchor (link type), a regular expression is used to extract social links corresponding to the task, such as Weibo, Facebook, or Twitter.
[0176] As a preferred specific implementation, the name, gender, age, identity and social link information corresponding to each character is structured and stored. Optionally, the character information is stored in a relational database or knowledge graph.
[0177] This embodiment first converts the target web page document into a corresponding document object model tree, and judges the nodes in the document object model tree in order from top to bottom. If a node includes multiple child nodes of the same type, the subtree set corresponding to the node is obtained, and it is judged whether the number of nodes included in different subtrees in the subtree set is the same, whether the types of the included nodes are the same, and whether the positions of the nodes of the same type included in the corresponding subtree are the same; if all of them are satisfied, it is further judged whether each subtree in the subtree set includes a node of the first preset type. If it does, it is determined that each subtree in the subtree set corresponds to a character, and the information of the character corresponding to each subtree is obtained by parsing each subtree in the subtree set. Therefore, this embodiment can accurately lock the subtree that displays the character in the document object model tree corresponding to the target web page document, and realize the function of extracting the relevant information of the character displayed in the web page by parsing the subtree that displays the character.
[0178] Embodiment three:
[0179] This embodiment provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the following steps are implemented:
[0180] Obtain a target web page document; the target web page document is a web page document in HTML language.
[0181] Obtain a document object model tree corresponding to the target web page document; the document object model tree includes a plurality of nodes.
[0182] Determine whether the nodes in the document object model tree meet the first preset condition in order from the root node of the document object model tree downward. If not, continue to judge the next node; otherwise, stop judging; the first preset condition includes: the node includes more than or equal to 2 child nodes, and the types of the child nodes included in the node are all the same.
[0183] If there is a node that meets the first preset condition in the document object model tree, a subtree set corresponding to the node that meets the first preset condition is obtained; the number of subtrees in the subtree set is the number of child nodes included in the node that meets the first preset condition, and the root node of each subtree in the subtree set is a child node of the node that meets the first preset condition.
[0184] Determine whether the subtree set meets a second preset condition; the second preset condition includes: the number of nodes included in different subtrees in the subtree set is the same, the types of nodes included in different subtrees in the subtree set are the same, and the positions of the nodes of the same type included in different subtrees in the subtree set in the corresponding subtrees are the same.
[0185] If the subtree set meets the second preset condition, it is determined whether each subtree in the subtree set meets a third preset condition; the third preset condition includes: each subtree in the subtree set includes a node of a first preset type.
[0186] If each subtree in the subtree set satisfies the third preset condition, it is determined that each subtree in the subtree set corresponds to a character, and each subtree in the subtree set is parsed to obtain information of the character corresponding to each subtree in the subtree set.
[0187] Embodiment 4:
[0188] This embodiment provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:
[0189] Obtain a target web page document; the target web page document is a web page document in HTML language.
[0190] Obtain a document object model tree corresponding to the target web page document; the document object model tree includes a plurality of nodes.
[0191] Determine whether the nodes in the document object model tree meet the first preset condition in order from the root node of the document object model tree downward. If not, continue to judge the next node; otherwise, stop judging; the first preset condition includes: the node includes more than or equal to 2 child nodes, and the types of the child nodes included in the node are all the same.
[0192] If there is a node that meets the first preset condition in the document object model tree, a subtree set corresponding to the node that meets the first preset condition is obtained; the number of subtrees in the subtree set is the number of child nodes included in the node that meets the first preset condition, and the root node of each subtree in the subtree set is a child node of the node that meets the first preset condition.
[0193] Determine whether the subtree set meets a second preset condition; the second preset condition includes: the number of nodes included in different subtrees in the subtree set is the same, the types of nodes included in different subtrees in the subtree set are the same, and the positions of the nodes of the same type included in different subtrees in the subtree set in the corresponding subtrees are the same.
[0194] If the subtree set meets the second preset condition, it is determined whether each subtree in the subtree set meets a third preset condition; the third preset condition includes: each subtree in the subtree set includes a node of a first preset type.
[0195] If each subtree in the subtree set satisfies the third preset condition, it is determined that each subtree in the subtree set corresponds to a character, and each subtree in the subtree set is parsed to obtain information of the character corresponding to each subtree in the subtree set.
[0196] 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.
[0197] Although some specific embodiments of the present invention have been described in detail by way of example, it will be appreciated by those skilled in the art that the above examples are for illustration only and are not intended to limit the scope of the present invention. It will also be appreciated by those skilled in the art that various modifications may be made to the embodiments without departing from the scope and spirit of the present invention. The scope of the present invention is defined by the appended claims.
Claims
1. A method for processing character recognition in a web page, characterized in that: The processing method comprises the following steps: Obtaining a target web page document; the target web page document is a web page document in HTML language; Obtaining a document object model tree corresponding to a target web page document; the document object model tree includes a plurality of nodes; Determine whether the nodes in the document object model tree meet a first preset condition in order from the root node of the document object model tree downwards, and if not, continue to determine the next node; otherwise, stop determining; the first preset condition includes: the node includes more than or equal to 2 child nodes, and the types of the child nodes included in the node are all the same; If there is a node satisfying the first preset condition in the document object model tree, a subtree set corresponding to the node satisfying the first preset condition is obtained; the number of subtrees in the subtree set is the number of child nodes included in the node satisfying the first preset condition, and the root node of each subtree in the subtree set is a child node of the node satisfying the first preset condition; Determine whether the subtree set satisfies a second preset condition; the second preset condition includes: different subtrees in the subtree set have the same number of nodes, different subtrees in the subtree set have the same type of nodes, and nodes of the same type in different subtrees in the subtree set have the same position in the corresponding subtree; If the subtree set satisfies the second preset condition, then determining whether each subtree in the subtree set satisfies a third preset condition; the third preset condition includes: each subtree in the subtree set includes a node of a first preset type; If each subtree in the subtree set satisfies the third preset condition, it is determined that each subtree in the subtree set corresponds to a character, and each subtree in the subtree set is parsed to obtain information of the character corresponding to each subtree in the subtree set; The nodes of the first preset type include picture type nodes, and the third preset condition also includes: the number of picture type nodes included in each subtree in the subtree set is 1, the picture corresponding to the picture type node included in each subtree in the subtree set contains only one person's head portrait, and the similarity of the backgrounds of the pictures corresponding to the picture type nodes included in different subtrees in the subtree set is greater than or equal to a preset similarity threshold.
2. The method for processing character recognition in a web page according to claim 1, characterized in that: Parsing each subtree in the subtree set includes: Obtaining a first picture corresponding to a picture type node of a first subtree in the subtree set; the first subtree in the subtree set is a subtree in the subtree set; Obtaining the gender and age of the person in the first picture; Obtaining a first title corresponding to a title type node of a first subtree in the subtree set; the first title corresponds to a plurality of title type nodes; Using the trained named entity recognition model, identify the names of people present in the first title; Use a string matching algorithm to determine whether identity information exists in the first title; If there is identity information in the first title, extract the identity information in the first title; otherwise, obtain the first paragraph corresponding to the paragraph type node of the first subtree in the subtree set, and extract the identity information from the first paragraph; the first paragraph corresponds to several paragraph type nodes.
3. The method for processing character recognition in a web page according to claim 1, characterized in that: If the subtree set does not satisfy the second preset condition or each subtree in the subtree set does not satisfy the third preset condition, it is continued to be determined whether the child nodes of the node satisfying the first preset condition satisfy the first preset condition.
4. The method for processing character recognition in a web page according to claim 1, characterized in that: Before determining whether the nodes in the document object model tree satisfy a first preset condition in order from the root node of the document object model tree downward, the processing method further includes: performing node deletion processing on the document object model tree, wherein the node deletion processing includes: deleting nodes in the document object model tree whose type belongs to a second preset type.
5. A processing device for identifying people in a web page, characterized in that: The processing device comprises: A first acquisition module is used to acquire a target web page document; the target web page document is a web page document in HTML language; A second acquisition module is used to acquire a document object model tree corresponding to the target web page document; the document object model tree includes a plurality of nodes; A first judgment module is used to judge whether the nodes in the document object model tree meet a first preset condition in order from the root node of the document object model tree downwards, and if not, continue to judge the next node; otherwise, stop judging; the first preset condition includes: the node includes more than or equal to 2 child nodes, and the types of the child nodes included in the node are all the same; A third acquisition module is used to acquire a subtree set corresponding to the node that meets the first preset condition if there is a node that meets the first preset condition in the document object model tree; the number of subtrees in the subtree set is the number of child nodes included in the node that meets the first preset condition, and the root node of each subtree in the subtree set is a child node of the node that meets the first preset condition; A second judgment module is used to judge whether the subtree set meets a second preset condition; the second preset condition includes: the number of nodes included in different subtrees in the subtree set is the same, the types of nodes included in different subtrees in the subtree set are the same, and the positions of the nodes of the same type included in different subtrees in the subtree set in the corresponding subtrees are the same; A third judgment module is used to judge whether each subtree in the subtree set meets a third preset condition if the subtree set meets the second preset condition; the third preset condition includes: each subtree in the subtree set includes a node of a first preset type; A parsing module, configured to determine that each subtree in the subtree set corresponds to a character if each subtree in the subtree set satisfies a third preset condition, and parse each subtree in the subtree set to obtain information of the character corresponding to each subtree in the subtree set; The nodes of the first preset type include picture type nodes, and the third preset condition also includes: the number of picture type nodes included in each subtree in the subtree set is 1, the picture corresponding to the picture type node included in each subtree in the subtree set contains only one person's head portrait, and the similarity of the backgrounds of the pictures corresponding to the picture type nodes included in different subtrees in the subtree set is greater than or equal to a preset similarity threshold.
6. The processing device for identifying people in a web page according to claim 5, characterized in that: The parsing module comprises: A fourth acquisition module is used to acquire a first picture corresponding to a picture type node of a first subtree in the subtree set; the first subtree in the subtree set is a subtree in the subtree set; A fifth acquisition module, used to acquire the gender and age of the person in the first picture; A sixth acquisition module is used to acquire a first title corresponding to a title type node of a first subtree in the subtree set; the first title corresponds to a plurality of title type nodes; A recognition module, for recognizing a person's name present in the first title using a trained named entity recognition model; A fourth determination module, configured to determine whether identity information exists in the first title by using a string matching algorithm; The extraction module is used to extract the identity information in the first title if there is identity information in the first title; otherwise, obtain the first paragraph corresponding to the paragraph type node of the first subtree in the subtree set, and extract the identity information from the first paragraph; the first paragraph corresponds to a plurality of paragraph type nodes.
7. The processing device for identifying people in a web page according to claim 5, characterized in that: The second judgment module is also used to continue to judge whether the child nodes of the nodes that meet the first preset condition meet the first preset condition if the subtree set does not meet the second preset condition; the third judgment module is also used to continue to judge whether the child nodes of the nodes that meet the first preset condition meet the first preset condition if each subtree in the subtree set does not meet the third preset condition.
8. The processing device for identifying people in a web page according to claim 5, characterized in that: The processing device also includes a deletion module, which is located between the second acquisition module and the first judgment module. The deletion module is used to delete nodes from the document object model tree. The node deletion process includes: deleting nodes in the document object model tree that belong to a second preset type.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method for processing person recognition in a web page as described in any one of claims 1 to 4 is implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method for processing person recognition in a web page as claimed in any one of claims 1 to 4 is implemented.
