Data extraction device, data extraction method, and program

The data extraction device enhances data extraction accuracy by combining character and positional similarity analysis, addressing the inefficiencies of existing methods in handling web page format variations and reducing extraction costs.

WO2024180608A1PCT designated stage expired Publication Date: 2024-09-06NT T INC
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
PCT/JP2023/007062
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Filing Date
2023-02-27
Publication Date
2024-09-06

AI Technical Summary

Technical Problem

Current data extraction methods from web pages face challenges in accurately identifying and extracting desired data due to variations in web page structure and information format, leading to high costs and inefficiencies, as they either rely solely on structural information or character similarity, which fails to consider positional relationships and commonalities within the same web page.

Method used

A data extraction device and method that selects extraction candidates based on both character and meaning similarity, followed by positional similarity to accurately identify and extract desired data, using regular expressions and edit distance for XPath comparison to prioritize correct data extraction.

Benefits of technology

Improves the accuracy of data extraction by considering both character and positional similarities, reducing costs associated with script settings and maintenance, and ensuring consistent data extraction across varying web page formats.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure JP2023007062_06092024_PF_FP
    Figure JP2023007062_06092024_PF_FP
Patent Text Reader

Abstract

This data extraction device comprises: an extraction candidate selection unit configured so as to select a plurality of extraction candidate strings from a group of strings included in a plurality of items of document data on the basis of similarity with a plurality of strings that include a feature in common; and an extraction data identification unit configured so as to identify a string to be extracted from the extraction candidate strings on the basis of similarity between the location of any one string among the plurality of strings in document data in which said string is present and the locations of the extraction candidate strings in document data items including said extraction candidate strings. The foregoing improves the accuracy of extraction of desired data.
Need to check novelty before this filing date? Find Prior Art

Description

Data extraction device, data extraction method and program

[0001] The present invention relates to a data extraction device, a data extraction method, and a program.

[0002] Large amounts of data are required for machine learning and data analysis. A large amount of data exists on the web pages that make up a website, and is used as auxiliary data for data analysis and other purposes. It is not economical to manually collect large amounts of target data from web pages. Therefore, in order to obtain large amounts of data at low cost, it is necessary to automatically collect large amounts of data from web pages. Here, data refers to, for example, character strings displayed on web pages. The type of character string required varies depending on the purpose of machine learning or data analysis.

[0003] In order to automatically collect data from a plurality of web pages in a unified manner, it is necessary to automatically determine whether or not data present in each web page is necessary (whether or not it should be extracted).

[0004] Because web pages are created and updated by different operators, page structure and information formatting are not completely unified. This means that data extraction scripts must individually configure the extraction targets, which is extremely costly.

[0005] In order to reduce the cost of individual settings, the following methods have been used to identify data to be extracted from within a web page by finding commonalities across the data to be extracted: (1) A method of extracting data by determining commonalities in the structure of the web page and the location of the data (location in HTML) (Non-Patent Document 1) (2) A method of extracting data by determining commonalities in the characters and meanings of the data (Non-Patent Document 2)

[0006] Mohammad Raza and Sumit Gulwani., "Automated Data Extraction Using Predictive Program Synthesis", In AAAI, Satinder P. Singh and Shaul Markovitch (Eds.). AAAI Press, pp. 882-890, 2017B. Bhardwaj, SI Ahmed, J. Jaiharie, R. Sorabh Dadhich and M. Ganesan, "Web Scraping Using Summarization and Named Entity Recognition (NER)", 2021 7th International Conference on Advanced Computing and Communication Systems (ICACCS), 2021, pp. 261-265, doi: 10.1109 / ICACCS51430.2021.9441888

[0007] Generally, the location of data on a web page can be identified using structural information such as an XPath. Method (1) involves inputting the URL of a web page within the search range for the data to be extracted and an XPath indicating the location of the data to be extracted, and extracting data related to the XPath from the web page. For example, a group of web pages on the same website are often created based on a common template and therefore share a common structure. If multiple web pages share a common structure, desired data can be extracted from the multiple web pages based on a single XPath. However, if some web pages have a structure that differs from the expected structure, an inconsistency occurs between the input XPath and the web page, making it difficult to identify the extracted data.

[0008] Therefore, in the method (1), commonality such as id and class that constitute HTML is also taken into consideration, thereby complementing the location information and increasing the possibility of identifying the extracted data.

[0009] A problem with the method (1) is that if there is a lot of data with the same ID or tag in a web page, it becomes difficult to identify the extracted data.

[0010] Furthermore, even within the same website, different IDs and classes may be assigned to the same data, making it difficult to extract similar data from multiple web pages.

[0011] Method (2) extracts data similar to a string entered as an example of the data to be extracted. For example, when "2023 / 02" is entered, method (2) extracts "2023 / 01" or "2022 / 12", etc. Method (2) is a data extraction method that does not use HTML information other than the characters displayed as text on the web, and does not rely on structure or position.

[0012] In this method, semantic similarity is the closeness of the feature vectors of the words used in each string. In addition, character similarity in this method is the degree of agreement regarding the order and type of characters used in each piece of data. Basically, character similarity is often expressed as the number of strings that can be replaced by a regular expression.

[0013] For example, when the following data exists, Data 3 has a higher similarity to Data 1 than Data 2: Data 1: "2022 / 01 / 01" Data 2: "01 / 01 / 2022" Data 3: "2022 / 01 / 02" A feature of method (2) is that if the meaning and character structure characteristics of the desired data match, it can always be identified as an extraction target.

[0014] On the other hand, a challenge with method (2) is that it cannot handle cases where data with similar meanings or character structures exist within the same web page, or where the meaning of data changes depending on the position. For example, suppose you want to collect shipping costs for each product on an e-commerce site. The web pages that make up the e-commerce site also include the price and discount amount for each product. Shipping costs, prices, and discount amounts have the same meaning of "amount," and their character structure is similar. Even if the shipping costs, prices, and discount amounts are listed in different positions, method (2) does not take their positions into account, making it difficult to determine the data to be extracted (here, shipping costs) based solely on meaning and character structure. Thus, when data with similar meanings and character structures exist within the same web page, method (2) makes it difficult to determine which data is most suitable for extraction (i.e., which data is most suitable for machine learning or data analysis, the purpose of data collection). Furthermore, when data is written in a table format, the meaning of the data may change depending on its position relative to other data (which column the data is in), making it difficult to extract only data suitable for the intended machine learning or data analysis. In such cases, even if appropriate data is found, it may be difficult to distinguish it from unnecessary data, and inappropriate data may also be extracted.

[0015] The present invention has been made in view of the above points, and has an object to improve the accuracy of extracting desired data.

[0016] In order to solve the above problem, the data extraction device has an extraction candidate selection unit configured to select a plurality of extraction candidate character strings from a group of character strings included in a plurality of document data based on similarity with a plurality of character strings that have a common feature, and an extraction data identification unit configured to identify a character string to be extracted from the extraction candidate character strings based on similarity between a position of one of the plurality of character strings in document data in which the character string exists and a position of the extraction candidate character string in document data including the extraction candidate character string.

[0017] The accuracy of extracting desired data can be improved.

[0018] FIG. 1 is a diagram illustrating an example of a hardware configuration of a data extraction device 10 according to an embodiment of the present invention. FIG. 2 is a diagram illustrating an example of a functional configuration of the data extraction device 10 according to an embodiment of the present invention. FIG. 3 is a diagram illustrating an example of the internal configuration of an extraction candidate selection unit 11. FIG. 4 is a diagram illustrating an example of symbols treated as delimiters. FIG. 5 is a flowchart illustrating an example of a processing procedure executed by a regular expression generation unit 111. FIG. 6 is a diagram illustrating an example of an output from the regular expression generation unit 111. FIG. 7 is a flowchart illustrating an example of a processing procedure executed by a regular expression selection unit 112. FIG. 8 is a flowchart illustrating an example of a processing procedure executed by an extraction candidate search unit 113. FIG. 9 is a diagram illustrating an example of HTML of a web page. FIG. 10 is a flowchart illustrating an example of a processing procedure executed by an extraction data specification unit 12.

[0019] In this embodiment, a method is disclosed for extracting desired data from a web page by taking into consideration both the similarity of characters and meaning to a string of characters input as an example of data to be extracted, and the similarity of the location of the data to the location given as input.

[0020] When combining character or semantic similarity with location similarity, there is a problem of how to combine them to efficiently refer to the similarities and narrow down the data. For example, if you narrow down the data by referring to both character or semantic similarity and location similarity and try to extract data that contains both, it is possible that the relevant data does not exist.

[0021] In such a case, it is necessary to consider which similarity should be given priority in extracting data, or what scale should be used to narrow down the data extracted based on each similarity.

[0022] However, the priority of character / semantic similarity over positional similarity varies depending on the structure and content of the web pages on the website. Even if a different metric is used, the effectiveness of that metric must be considered for each web page and data type. Therefore, there is a problem in that it is difficult to consistently and efficiently extract data.

[0023] Here, the advantages and disadvantages of extracting data using the similarity of characters or meaning and the similarity of position will be summarized.

[0024] An advantage of extracting data using character or semantic similarity is that even if the example data to be extracted exists on a web page in a format different from that of the actual web page, it is always possible to extract data that has the same characters or similar meaning as the example data to be extracted. For example, if the string given as an example of data to be extracted is "2023 / 01 / 01" and other data existing on a web page in a format different from that of the web page in which the string exists is "2023 / 02 / 02" or "2023 / 01-01," these data can be extracted. On the other hand, a disadvantage of this method is that if data has similar characters or meaning to the example data to be extracted, all data will be extracted, making it difficult to narrow down the extracted data to the most appropriate ones.

[0025] On the other hand, one advantage of using position similarity to extract data is that it is possible to narrow down the data you want to extract to one piece of data. This is because, in many cases, it is possible to identify the data that is closest in distance on the web page (for example, the distance in the hierarchical structure represented by HTML nodes and edges) from the position (position in the hierarchical structure) given as input using XPath or the like. On the other hand, a disadvantage of this method is that, because the content of the data is not examined closely, data that is completely different from the data you want to extract may be extracted.

[0026] In light of the above, in this embodiment, in order to solve the above-mentioned problem, a technology is disclosed in which data of extraction candidates is first narrowed down based on the similarity of meaning and characters with desired data (character string), and then, for the narrowed down extraction candidates, the final extraction target is identified based on the similarity of position with the desired data.

[0027] Specifically, examples of data with characteristics that make it easy to find the data you want to extract (correct data) are referenced, and the extraction candidates are narrowed down from the entire text on the web page, making it easier for the correct data to be included in the extraction candidates.

[0028] Next, in order to identify correct data from the extraction candidates, an extraction method based on the position specified as input and the position where each extraction candidate exists is incorporated into the next step, which makes it easy to narrow down the data to a certain number.

[0029] An embodiment of the present invention will now be described with reference to the accompanying drawings. Fig. 1 is a diagram showing an example of the hardware configuration of a data extraction device 10 according to an embodiment of the present invention. The data extraction device 10 in Fig. 1 includes a drive device 100, an auxiliary storage device 102, a memory device 103, a processor 104, and an interface device 105, all of which are interconnected via a bus B.

[0030] A program for realizing the processing in the data extraction device 10 is provided by a recording medium 101 such as a CD-ROM. When the recording medium 101 storing the program is set in the drive device 100, the program is installed from the recording medium 101 to the auxiliary storage device 102 via the drive device 100. However, the program does not necessarily have to be installed from the recording medium 101, but may be downloaded from another computer via a network. The auxiliary storage device 102 stores the installed program as well as necessary files, data, etc.

[0031] When an instruction to start a program is received, the memory device 103 reads the program from the auxiliary storage device 102 and stores it. The processor 104 is a CPU or a GPU (Graphics Processing Unit), or a CPU and a GPU, and executes functions related to the data extraction device 10 in accordance with the program stored in the memory device 103. The interface device 105 is used as an interface for connecting to a network.

[0032] 2 is a diagram showing an example of the functional configuration of the data extraction device 10 according to an embodiment of the present invention. In FIG. 2, the data extraction device 10 includes an extraction candidate selection unit 11 and an extraction data specification unit 12. These units are realized by the processor 104 executing one or more programs installed in the data extraction device 10.

[0033] The extraction candidate selection unit 11 receives as input multiple character strings representing examples of desired data (hereinafter referred to as "data examples") and a list of URLs of web pages that are the search range for extracted data. Each data example is a character string (example) that exists on a web page other than any of the web pages included in the URL list. However, some or all of the web pages included in the URL list may be web pages that include one or more data examples. The extraction candidate selection unit 11 selects multiple extraction candidate character strings from a group of character strings included in the multiple web pages included in the input URL list based on their similarity to the multiple data examples. The similarity between the data example and each character string constituting the text on the web page is evaluated based on a regular expression that indicates the character composition of the data example. Note that the multiple character strings representing the desired data examples represent examples of multiple character strings extracted for the same purpose (e.g., machine learning, data analysis), and therefore have in common the fact that they contain characteristics suitable for that purpose. In other words, the multiple character strings representing the data examples contain common characteristics. For example, if you want to collect stock prices for each company in order to analyze stock price information to understand social conditions, the multiple strings that represent example data are multiple strings that include characteristics of strings that represent stock prices.

[0034] The extraction data identification unit 12 identifies the data to be ultimately extracted based on the similarity between the position of the data example on the web page (the web page from which the data example was extracted) and the positions of each of the multiple extraction candidates on the web page, and outputs a list of the identified data.

[0035] Each part will be explained in detail below.

[0036] [Extraction Candidate Selection Unit 11] The extraction candidate selection unit 11 accesses the web page associated with each URL included in the input URL list and selects extraction candidates from among the character strings included in the web page based on the input multiple data examples. Specifically, the extraction candidate selection unit 11 generates a regular expression based on the input multiple data examples and uses the regular expression to search for text (text matching the regular expression) present in the web page to select extraction candidates.

[0037] 3 is a diagram showing an example of the internal configuration of the extraction candidate selection unit 11. In FIG. 3, the extraction candidate selection unit 11 includes a regular expression generation unit 111, a regular expression selection unit 112, and an extraction candidate search unit 113.

[0038] The regular expression generating unit 111 generates a plurality of regular expressions based on one of the plurality of data examples input by the extraction candidate selecting unit 11 .

[0039] The regular expression selection unit 112 selects a regular expression suitable for use in searching for extraction candidates from among a plurality of regular expressions, based on data examples that were not used to generate the regular expressions.

[0040] The extraction candidate search unit 113 selects extraction candidates by searching for character strings that match the regular expressions selected by the regular expression selection unit 112 from the web pages related to the input URL list.

[0041] The regular expression generating unit 111, the regular expression selecting unit 112, and the extraction candidate searching unit 113 will be described in detail below.

[0042] [Regular Expression Generation Unit 111] The procedure for generating regular expressions by the regular expression generation unit 111 is outlined below. (1) A character string as an example of data is divided into multiple character strings based on delimiters. Hereinafter, each divided section of the character string as an example of data is referred to as a "divided section," and the character string for each divided section is referred to as a "divided character string." (2) Each of the multiple divided character strings is replaced with a regular expression. Hereinafter, the character string before being replaced with a regular expression is referred to as the "original character string." Note that replacing a string with a regular expression (generating a regular expression for a string) can be performed using known techniques disclosed in, for example, "re --- Regular Expression Operations," [online], Internet <URL: https: / / docs.python.org / ja / 3 / library / re.html>" or "Regular Expression Language - Quick Reference," [online], Internet <URL: https: / / learn.microsoft.com / ja-jp / dotnet / standard / base-types / regular-expression-language-quick-reference>." (3) Generate all possible (multiple) combinations of strings (without duplicates) in which each split section is expressed either by a regular expression or the original string (the split string from which the regular expression is generated). (4) For each combination generated in (3), generate a single regularized string by combining the strings (regular expressions or original strings) of each split section in the order of the split sections. Therefore, a regular expression is generated for each combination, resulting in the generation of multiple regular expressions.

[0043] In this embodiment, regular expressions are generated according to the following rules: The types of characters to be replaced by regular expressions are uppercase alphabets, lowercase alphabets, half-width numbers, half-width symbols, and spaces. Regular expressions are generated based on the type and number of characters. Spaces and the specified symbols shown in FIG. 4 are treated as delimiters. When two or more consecutive delimiter characters exist, a delimiter exists between each delimiter character. Delimiters are also treated as one string (a string of one character).

[0044] As an example, a character string "2022 / 01 / 01 [01h, 01m, 01s]" is split as follows. In the following, commas (,) indicate the split positions: 2022, / ,01, / ,01, ,[,01h,,, ,01m,,, ,01s,] FIG. 5 is a flowchart illustrating an example of a processing procedure executed by the regular expression generation unit 111.

[0045] In step S101, the regular expression generation unit 111 converts any one of the input data examples into A 0 Substitute into

[0046] Next, the regular expression generation unit 111 initializes the divided character string storage list S with an empty list (S102). 0 is a list for storing each divided character string obtained by dividing the character string by delimiters as a single element. In other words, the divided character string storage list S is a list for storing each divided character string before conversion to a normalized expression.

[0047] Next, the regular expression generation unit 111 initializes the segmented string regular expression list S' to an empty list (S103). The segmented string regular expression list S' is a list for storing strings obtained by regularizing each segmented string (regularized strings).

[0048] Next, the regular expression generation unit 111 initializes a variable b, which is used to store the character string of one divided section, to a null character (S104).

[0049] Next, the regular expression generation unit 111 0 A loop process L11 is executed for each character constituting the character a. A character being processed in the loop process L11 is called "character a." 0 In order from the first character in (A 0 The character a is set as the character a in the order of arrangement in the loop process L11. The loop process L11 includes steps S105 to S110.

[0050] In step S105, the regular expression generation unit 111 determines whether the character a is a delimiter. If the character a is not a delimiter (No in S105), the regular expression generation unit 111 adds the character a to the end of the character string b (S106).

[0051] On the other hand, if character a is a delimiter (Yes in S105), the regular expression generation unit 111 determines whether character string b is a null character string (S107). If character string b is not a null character string (Yes in S107), the regular expression generation unit 111 adds an element storing character string b to the end of list S (S108). Next, the regular expression generation unit 111 initializes character string b to a null character string (S109). In other words, character string b is the character string up to the point where a delimiter is detected (the character string of one divided section). Next, the regular expression generation unit 111 adds an element storing character a, which is a delimiter, to the end of list S (S110).

[0052] Loop processing L11 is A 0 After this has been executed for all characters constituting list S, the regular expression generation unit 111 executes loop processing L12 for each element stored in list S. The element being processed in loop processing L12 is referred to as string s. The elements (strings) in S are sequentially treated as strings s (in the order of arrangement in S), starting from the first element (string). Loop processing L12 includes steps S111 and S112. In step S111, the regular expression generation unit 111 converts string s into a regular expression and assigns the result to s'. Next, the regular expression generation unit 111 adds the element storing s' to the end of list S' (S112).

[0053] List S is converted into list S' by executing loop process L12 for all elements of list S. Examples of lists S and S' are shown below. In the example below, list S is the string "2022 / 01" divided into three strings. S: ["2022", " / ", "01"] S': ["[0-9] {4}", "[symbol] {1}", "[0-9] {2}"] Note that the "symbol" in [symbol] in S' refers to the symbols listed in FIG. 4, and the same applies to the examples of regular expressions below.

[0054] Next, the regular expression generation unit 111 executes the combination function (S, S') and assigns the return value of the combination function (S, S') to A' (S113). The combination function (S, S') is a function that calculates the kth (0≦k≦N: N is the number of elements of S) element of S (i.e., A 0 This function outputs a list of regularized strings (hereinafter simply referred to as "regular expressions") obtained by connecting each element related to the combination in order from the beginning, for each of all possible combinations of N elements obtained by substituting the k-th divided section of S with the k-th element of S or the k-th element of S'.

[0055] Next, the regular expression generation unit 111 outputs a list A' of regular expressions (S114). An example of the output (A') from the regular expression generation unit 111 is shown in FIG.

[0056] [Regular Expression Selection Unit 112] The regular expression selection unit 112 selects a regular expression to be used to search for extraction candidates from a web page, based on the output (list of regular expressions) from the regular expression generation unit 111 and data examples that were not used to generate the regular expressions among the multiple input data examples. For example, if the multiple data examples are "2022 / 01," "2022 / 01 / 01," "01 / 01," "2022,01," "2022 01 01," "01 / 2022," and "2022 / 01," and "2022 / 01" is used by the regular expression generation unit 111, the regular expression selection unit 112 selects a regular expression to be used to search for extraction candidates from a web page, based on "2022 / 01 / 01," "01 / 01," "2022,01," "2022 01 01," "01 / 2022," and "2022 / 01." In this case, examples of the plurality of data are dates having specific meanings. For example, a user who manages a store may want to collect a large number of dates of events from web pages that constitute a website that compiles dates of events in the area where the store is located, for the purpose of predicting or analyzing sales.

[0057] The purpose of regular expression selection unit 112 is to select regular expressions that have more common characteristics than the multiple data examples given as input in order to perform efficient searches, since a huge number of regular expressions, equal to the factorial of 2, are generated depending on the number of divisions of the data example (character string) used by regular expression generation unit 111.

[0058] The processing procedure performed by the regular expression selection unit 112 is outlined as follows: (1) For each regular expression generated by the regular expression generation unit 111, it is determined whether it matches any of all data examples (hereinafter referred to as "unused data examples") excluding the data examples used to generate the regular expression (hereinafter referred to as "used data examples"). (2) A regular expression that matches one or more unused data examples (i.e., a regular expression that matches not only the used data examples but also one or more unused data examples) is selected as the regular expression to be used in the search. If there is no regular expression that matches one or more unused data examples, all regular expressions generated by the regular expression generation unit 111 are selected as the regular expressions to be used in the search. However, the used data examples are excluded from the selection targets.

[0059] FIG. 7 is a flowchart illustrating an example of a processing procedure executed by the regular expression selection unit 112.

[0060] In step S201, the regular expression selection unit 112 assigns each unused data example to an element of list I. As a result, list I becomes a list of unused data.

[0061] Next, regular expression selection unit 112 initializes selected regular expression storage list R to an empty list (S202). Selected regular expression storage list R is a list for storing regular expressions selected by regular expression selection unit 112 from list A′ of regular expressions generated by regular expression generation unit 111.

[0062] Next, the regular expression selection unit 112 executes a loop process L21 for each unused data example included in list I. The unused data example being processed in loop process L21 is referred to as an "unused data example i." Loop process L21 includes a loop process L22.

[0063] Loop process L22 is a loop process for each element (regular expression) in list A' of regular expressions. The regular expression being processed in loop process L22 is called "regular expression a'." Elements in list A' are treated as regular expressions a' in order, starting from the first element. Loop process L22 includes steps S203 to S205.

[0064] In step S203, the regular expression selection unit 112 determines whether the unused data example i matches the regular expression a'. If the unused data example i matches the regular expression a' (Yes in S203), the regular expression selection unit 112 determines whether the regular expression a' is included in the list R (S204). If the regular expression a' is not included in the list R (Yes in S204), the regular expression selection unit 112 adds an element storing the regular expression a' to the end of the list R (S205).

[0065] After loop process L22 has been executed for all elements (regular expressions) in list A' of regular expressions and loop process L21 has been executed for all unused data examples included in list I, regular expression selection unit 112 determines whether list R is empty (S206). If list R is empty (Yes in S206), regular expression selection unit 112 assigns list A' of regular expressions to list R (S207).

[0066] Following step S207 or if step S206 is No, the regular expression selection unit 112 outputs list R (S208).

[0067] [Extraction Candidate Searching Unit 113] The extraction candidate searching unit 113 selects extraction candidates by searching for character strings that match the regular expressions selected by the regular expression selecting unit 112 from within the web pages related to the input URL list.

[0068] The processing procedure performed by the extraction candidate search unit 113 is outlined below. (1) The input URL list is accessed to acquire a group of character strings for each web page. (2) Each character string acquired from each web page is determined to be matched with any of the regular expressions. (3) For each web page in the URL list, one or more character strings that match the regular expression with the lowest degree of non-match (in other words, the highest degree of match) among the regular expressions to which at least one character string matches are selected as extraction candidates. The degree of non-match refers to the degree to which the character string does not match the characteristics of the data (character strings) desired (collected) by the user. An example of a rule for calculating the degree of non-match is shown below.

[0069] (Rule 1) The greater the number of segmented strings (segmented strings that are not the original string) expressed by a regular expression, the higher the degree of non-match. Examples of non-match for each regular expression are shown below. Regular Expression 1: "2022 / 01" → Non-match: 0 Regular Expression 2: "2022 / [0-9] {2}" → Non-match: 1 Regular Expression 3: "[0-9] {4} [symbol] {1} 01" → Non-match: 2 Regular Expression 4: "[0-9] {4} [symbol] {1} [0-9] {2}" → Non-match: 3 This is because the more segmented strings expressed by a regular expression (regular expression) contain, the greater its expressive power and ambiguity. The more ambiguous a regular expression is, the greater the likelihood that it will contain strings that are significantly different from the given data example. Therefore, the more ambiguous a regular expression is, the higher the degree of non-match.

[0070] (Rule 2) The degree of non-matching is higher for regular expressions that are more tolerant (specifically, for regular expressions with a larger range of character repetitions). Specifically, in the following examples, regular expressions 5 to 8 have increasing degrees of non-matching in ascending order. Regular expression 5: "2022 / [0-9]{2}" Regular expression 6: "2022 / [0-9]{0,4}" Regular expression 7: "2022 / [0-9]+" Regular expression 8: "2022 / [0-9]*" In the above examples, {2}, {0,4}, +, and * represent the number of repetitions of the character [0-9]. [0-9]{2} in regular expression 5 represents "a string consisting of a character from 0 to 9 repeated twice." [0-9]{0,4} in regular expression 6 represents "a string consisting of a character from 0 to 9 repeated 0 to 4 times." In regular expression 7, [0-9]+ represents "a string of characters consisting of 0 to 9 repeated one or more times." In regular expression 8, [0-9]* represents "a string of characters consisting of 0 to 9 repeated zero or more times." In this case, regular expressions 5 to 8 have increasing expressive power (the number of character strings that can be expressed increases). In other words, regular expressions 5 to 8 have increasing ambiguity.

[0071] As described above, Rule 1 and Rule 2 have in common the fact that the higher the ambiguity, the higher the degree of non-matching. In other words, the degree of non-matching can be said to be an evaluation value relating to the level of ambiguity. A high degree of non-matching is equivalent to a high evaluation value.

[0072] Note that only one of Rule 1 and Rule 2 may be adopted, or both Rule 1 and Rule 2 may be adopted. When both are adopted, the combination of Rule 1 and Rule 2 may be determined appropriately. Furthermore, any rule other than those mentioned above may be adopted as long as it satisfies the idea that the higher the ambiguity, the higher the degree of non-match.

[0073] FIG. 8 is a flowchart illustrating an example of a processing procedure executed by the extraction candidate searching unit 113.

[0074] In step S301, the extraction candidate search unit 113 creates an extraction candidate storage list C of all web pages. all is initialized to an empty list. Extraction candidate storage list C of all web pagesall is a list whose elements are lists of character strings searched as extraction candidates from the web pages for all web pages related to URLs that could be accessed from the input URL list. all The number of elements in is the number of accessible web pages. all A certain element of is a list of character strings searched as extraction candidates from the web page corresponding to the element.

[0075] Next, the extraction candidate search unit 113 executes the sorting function (R) by degree of non-matching and assigns its return value to R' (S302). Here, R is the list of regular expressions output from the regular expression selection unit 112. The sorting function (R) by degree of non-matching is a function that returns the results of sorting the regular expressions stored in the regular expression list R in ascending order of degree of non-matching. Therefore, R' is a list of regular expressions sorted in ascending order of degree of non-matching.

[0076] For example, if R = ["[0-9] {4} [symbol] {1} 01", "[0-9] {4} [symbol] {1} [0-9] {2}", "2022 / [0-9] {2}"], then R' = ["2022 / [0-9] {2}"] "[0-9] {4} [symbol] {1} 01", "[0-9] {4} [symbol] {1} [0-9] {2}"].

[0077] Next, the extraction candidate search unit 113 executes a loop process L31 for each URL included in the input URL list. The URL being processed in the loop process L31 is referred to as "url." The loop process L31 includes steps S303 and S304, a loop process L32, and a step S308.

[0078] In step S303, the extraction candidate search unit 113 executes the text acquisition function (url) and assigns its return value to T. The text acquisition function (url) accesses the web page associated with the url, acquires all character strings displayed on the web page (such as character strings defined as display targets, for example, enclosed in specific tags in the HTML associated with the web page), and returns them in list format. For example, if url = "http: / / www.xxx.co.jp" and the HTML of the web page accessible via the url is as shown in FIG. 9, the return value of the text acquisition function (url) is ["foo", "bar", "baz", "qux", "quux"].

[0079] Next, the extraction candidate search unit 113 initializes the extraction candidate storage list C for each web page to an empty list (S304). The extraction candidate storage list C for each web page is a list for storing extraction candidates searched for from one web page related to the URL. In other words, C is all This is one element of the above.

[0080] Next, the extraction candidate search unit 113 executes a loop process L32 for each element (regular expression) in the list R' of regular expressions sorted in ascending order of non-matching degree. The regular expression being processed in the loop process L32 is referred to as "regular expression r'." The elements in the list R' are treated as regular expressions r' in order from the first element (i.e., from the regular expression with the lowest non-matching degree). The loop process L32 includes a loop process L33 and step S307.

[0081] Loop process L33 is a loop process for each element (string) of list T of strings obtained from the web page related to the URL. The string being processed in loop process L33 is hereinafter referred to as "string t." Loop process L33 includes steps S305 and S306.

[0082] In step S305, the extraction candidate search unit 113 determines whether the character string t matches the regular expression r'. If the character string t matches the regular expression r' (Yes in S305), the extraction candidate search unit 113 adds an element storing the character string t to the end of list C (S306).

[0083] When the loop process L33 is completed for all elements of list T, the extraction candidate search unit 113 determines whether list C is empty (S307). If list C is empty (that is, if there is no character string in list T that matches regular expression r') (Yes in S307), loop process L32 is repeated. If list C is not empty (No in S307), the extraction candidate search unit 113 exits loop process L32 and stores the elements stored in list C in C. all (S308) The content of C at this time is a list of character strings (extraction candidates) that match the regular expression with the lowest degree of non-match among the elements of the list R' of regular expressions that match any character string obtained from the web page related to the URL.

[0084] When the loop process L31 is executed for all URLs included in the URL list, the extraction candidate search unit 113 all is output (S309).

[0085] For example, if the URL list is [URL of Web page 1, URL of Web page 2], the URL of the first loop L31 is "URL of Web page 1." In this case, if the list C of extraction candidates for Web page 1 is ["foo", "bar"], the element storing ["foo", "bar"] is C. all The URL of the second loop L31 is the URL of Web page 2. In this case, if the list C of extraction candidates for Web page 2 is ["baz", "qux"], the element storing ["baz", "qux"] is C. all As a result, the C output in step S309 all The contents of is [["foo", "bar"], ["baz", "qux"]].

[0086] [Extraction Data Identification Unit 12] Next, the extraction data identification unit 12 will be described. The extraction data identification unit 12 compares the similarity between each extraction candidate and a certain data example with respect to the location on the web page, thereby identifying the extraction candidate that is closest in location to the data example. The location of a certain data example on a web page refers to the location of the data example on the web page from which the data example was extracted. The location of a certain extraction candidate on a web page refers to the location of the extraction candidate on the web page from which the extraction candidate was extracted.

[0087] In this embodiment, the edit distance for the XPath is used as the position similarity.

[0088] The reason for using edit distance is that web pages are structured in a tree, and even on the same web page, changes such as inserting, deleting, or moving advertisements or elements can change the tree structure (some nodes on the tree may be replaced or the positions of some nodes on the tree may change before and after the change).

[0089] Since the XPath is written by tracing the position of the HTML element up through the parent tree, even if some nodes in the tree structure are deleted or replaced, the XPath of nodes that have not been replaced in the hierarchy between them and the parent will match that before the operation.

[0090] Therefore, in this embodiment, instead of simply comparing XPaths as character strings, an edit distance is used in which the number of operations due to deletion or replacement of HTML elements is used as the distance.

[0091] The processing procedure performed by the extraction data identification unit 12 is outlined below. (1) For one of the example data provided as input (regardless of whether it was used to generate a regular expression) and each extraction candidate obtained from the extraction candidate selection unit 11, the respective positions on the web page are obtained as XPaths. (2) The edit distance between the XPath of the example data and the XPath of the extraction candidate is calculated. In this case, the comparison is performed using the XPath tag (an HTML element, which is a node in the tree) as a unit, rather than comparing each character individually. Specifically, while the units of comparison when calculating the edit distance of the character string "HTML" are generally H, T, M, and L, for the XPath "html / body / div[2] / p," the units of comparison when calculating the edit distance are html, body, div[2], and p. (3) For each web page, the extraction candidate with the shortest edit distance is identified as the extraction target. If there are multiple extraction candidates with the shortest edit distance, all of them are identified as extraction targets.

[0092] FIG. 10 is a flowchart illustrating an example of a processing procedure executed by the extracted data specifying unit 12. As shown in FIG.

[0093] In step S401, the extracted data specifying unit 12 selects any one of the input data examples as A 0 The example data may or may not be the example data used to generate the regular expression.

[0094] Next, the extracted data specifying unit 12 creates an extracted data list D of all the web pages. all is initialized to an empty list (S402).

[0095] Next, the extracted data specifying unit 12 uses the XPath acquisition function (A 0 ) to execute the example XPath get function (A 0 ) return value to xpath a (S403). 0 ) is data example A 0 Data example A on the web page from which the data was extracted 0 It is a function that returns a character string indicating the XPath of the location of A.0 is "foo" and A 0 If the source of the extraction is the web page in FIG. 9, the XPath acquisition function (A 0 ) returns "html / body / div / h1". 0 The URL of the web page from which the data is extracted is the XPath acquisition function (A 0 For example, the URL is known to the XPath get function (A 0 Alternatively, the extracted data may be stored in a configuration file or the like referenced by the URL list of the web pages that are the search range for the extracted data. 0 In this case, the XPath acquisition function (A 0 ) accesses the web page related to the URL and 0 The XPath of the above may be acquired.

[0096] Next, the extraction data specifying unit 12 creates an extraction candidate storage list C for each URL included in the URL list and for all Web pages. all A loop process L41 is executed for each element of the above. The URL to be processed in the loop process L41 is called "url", and the C all The elements of are referred to as C. That is, C is a list of extraction candidates extracted from the web page related to the url. The loop process L41 includes steps S404 and S405, a loop process L42, and a step S413.

[0097] In step S404, the extracted data specifying unit 12 calculates the minimum distance d min is initialized to a sufficiently large value. For example, in a web page that can be accessed by URL, a The edit distance between the two is greater than the maximum possible value.

[0098] Next, the extracted data specifying unit 12 initializes the extracted data storage list D to an empty list (S405). The extracted data storage list D is a list for storing extracted data from a web page that can be accessed by a URL.

[0099] Next, the extracted data specifying unit 12 executes a loop process L42 for each element of the list C. The element being processed in the loop process L42 is referred to as a character string c. The loop process L42 includes steps S406 to S412.

[0100] In step S406, the extracted data specifying unit 12 executes the XPath acquisition function (url, c) and returns the return value of the XPath acquisition function (url, c) as xpath. c The XPath acquisition function (url, c) is a function that returns a character string indicating the XPath of the location where the character string c exists on the web page related to the url. Suppose the url is "http: / / www.xxx.co.jp" and c is "baz". If the web page related to "http: / / www.xxx.co.jp" is the web page in Figure 9, the XPath acquisition function (url, c) returns "html / body / h3".

[0101] Next, the extracted data specifying unit 12 uses a distance calculation function (xpath a , xpath c ) and execute the distance calculation function (xpath a , xpath c The return value of the distance calculation function (xpath) is assigned to d (S407). a , xpath c ) is xpath a and xpath c It is a function that returns the edit distance between xpath and xpath as a value greater than or equal to 0. a is "html / body / div / h1" and xpath c is "html / body / h3", then the distance calculation function (xpath a , xpath c ) returns 3.

[0102] Next, the extracted data specifying unit 12 determines whether the edit distance d is d min It is determined whether the edit distance d is less than d (S408). min If it is less than d (Yes in S408), the extracted data specifying unit 12 minThen, the extracted data specifying unit 12 assigns d to .sub.i (S409). Next, the extracted data specifying unit 12 initializes the extracted data storage list D with an empty list (S410). The extracted data storage list D is a list for storing extracted data from the web page associated with the URL (i.e., from list C).

[0103] If the answer is No in step S410 or S408, the extracted data specifying unit 12 determines whether the edit distance d is d min It is determined whether the edit distance d is equal to or less than d (S411). min If it is equal to or less than that (Yes in S411), the extracted data specifying unit 12 adds the element storing c to the end of list D (S412).

[0104] When the loop process L42 is executed for all elements (character strings of extraction candidates) of list C, the extraction data specifying unit 12 stores the elements of list D in list D. all (S413).

[0105] List C of all URLs and all web pages in the URL list all When the loop process L41 is executed for all elements of D all is output (S414). all List D all is a list that has an element for each web page, and stores a list of extracted data (character strings with the smallest edit distance from the data example) from the web page corresponding to the element. all The contents of this are a list of data desired by the user.

[0106] As described above, according to this embodiment, the data to be extracted is identified from the extraction candidates narrowed down based on the data example of the desired data, based on the positional similarity with the data example, thereby improving the accuracy of extracting the desired data.

[0107] Furthermore, because data can be extracted consistently regardless of differences in the format of the web page, costs associated with extracting data, such as changing settings in the script, that arise due to differences in format, can be reduced.

[0108] Furthermore, since this embodiment does not use a machine learning method such as the method in Non-Patent Document 2, it is possible to reduce the need for maintenance such as re-learning when new words appear.

[0109] Although the present embodiment has been described with reference to an example in which data (character strings) are extracted from a web page, the present embodiment may also be applied to cases in which data (character strings) are extracted from multiple document data other than web pages. In this case, the document data may be text data or data representing a structured document other than HTML. For example, the document data may be in the format of XML (eXtensible Markup Language) or may have the structure of another structured document.

[0110] Although the embodiments of the present invention have been described in detail above, the present invention is not limited to such specific embodiments, and various modifications and changes are possible within the scope of the gist of the present invention described in the claims.

[0111] REFERENCE SIGNS LIST 10 Data extraction device 11 Extraction candidate selection unit 12 Extraction data identification unit 100 Drive device 101 Recording medium 102 Auxiliary storage device 103 Memory device 104 Processor 105 Interface device 111 Regular expression generation unit 112 Regular expression selection unit 113 Extraction candidate search unit B Bus

Claims

1. A data extraction device comprising: an extraction candidate selection unit configured to select a plurality of extraction candidate character strings from a group of character strings contained in a plurality of document data based on similarity with a plurality of character strings having a common feature; and an extraction data identification unit configured to identify a character string to be extracted from the extraction candidate character strings based on similarity between a position of any one of the plurality of character strings in document data in which the character string exists and a position of the extraction candidate character string in document data including the extraction candidate character string.

2. The data extraction device according to claim 1, characterized in that the extraction candidate selection unit includes: a regular expression generation unit configured to generate a plurality of regular expressions based on a first character string of the plurality of character strings; a regular expression selection unit configured to select, from the plurality of regular expressions, a regular expression that also applies to any character string other than the first character string of the plurality of character strings; and an extraction candidate search unit configured to search, as the extraction candidate, a character string that applies to the regular expression selected by the regular expression selection unit from a group of character strings included in a plurality of document data.

3. The data extraction device according to claim 2, characterized in that the regular expression generation unit is configured to generate a regular expression for each divided section in the first string separated by a predetermined symbol, and the regular expression selection unit is configured to select a regular expression that also applies to any string other than the first string among the multiple strings from among multiple regular expressions in which each divided section is expressed either by a regular expression or by the string from which the regular expression was generated.

4. The data extraction device according to claim 2, characterized in that the extraction candidate search unit is configured to search for, for each of a plurality of document data, a character string that matches a regular expression having the lowest evaluation value regarding ambiguity among regular expressions that match any of a group of character strings contained in the document data, as the extraction candidate.

5. The data extraction device according to claim 1, characterized in that the document data is data representing a structured document, and the extraction data identification unit is configured to identify a character string to be extracted from among the character strings of the extraction candidates based on a similarity between a position of any one of the plurality of character strings in a hierarchical structure of document data in which the character string exists, and a position of the character string of the extraction candidate in a hierarchical structure of document data including the character string of the extraction candidate.

6. A data extraction method, characterized in that a computer executes the following steps: an extraction candidate selection step for selecting a plurality of extraction candidate character strings from a group of character strings contained in a plurality of document data based on similarity with a plurality of character strings having a common feature; and an extraction data identification step for identifying a character string to be extracted from the extraction candidate character strings based on similarity between a position of any one of the plurality of character strings in document data in which the character string exists and a position of the extraction candidate character string in document data including the extraction candidate character string.

7. A program causing a computer to execute the following steps: an extraction candidate selection step for selecting a plurality of extraction candidate character strings from a group of character strings contained in a plurality of document data based on similarity with a plurality of character strings having a common feature; and an extraction data identification step for identifying a character string to be extracted from the extraction candidate character strings based on similarity between a position of any one of the plurality of character strings in document data in which the character string exists and a position of the extraction candidate character string in document data including the extraction candidate character string.

Citation Information

Patent Citations

  • Program, information processor, and method

    JP2015028699A

  • Image processing device and program

    JP2016167236A