A method for converting patent search expressions into search engine query statements
By defining an extensible patent search expression syntax structure and a method for generating standard syntax trees, the problem of cross-search engine and data format adaptation is solved, enabling flexible and efficient conversion of patent search.
Patent Information
- Application Number
- CN202211201513.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-29
- Publication Date
- 2026-01-02
- Estimated Expiration
- 2042-09-29
AI Technical Summary
Existing technologies cannot adapt to different search engines and data formats, resulting in patent search expressions being unable to be effectively converted into search engine query statements, lacking scalability and adaptability.
Define an extensible patent search expression syntax structure, use a tokenizer to parse the patent search expression to generate a standard syntax tree, and use a syntax converter to transform it into a query statement for the target search engine.
It achieves cross-search engine and data format compatibility, improving the flexibility and efficiency of patent retrieval.
Smart Images

Figure CN115587162B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the technical field of data retrieval and language processing, and particularly relates to a method for converting a patent retrieval expression into a search engine query statement. BACKGROUND
[0002] With the rapid development of technology in various fields of human society, numerous wisdom crystallizations have emerged. At the same time, people's awareness of protecting the property rights of these knowledge is also increasing. As a kind of intellectual property, there are currently more than one hundred million patents in the world. These massive patents contain high value. Therefore, how to better extract and query the information of these patents is the basis for realizing the utilization of patent value. With the improvement of the informatization construction level in the field of intellectual property rights, the data management of patents is no longer a major problem. At present, multi-dimensional retrieval of patent data has become a key technology and core competence that can solve the query of patent information.
[0003] Multi-dimensional retrieval of patent data usually needs to parse and convert a patent retrieval expression into a query language that can be recognized by a search engine, such as the invention patent "Method and system for converting expression retrieval into Elasticsearch search statement" applied by Daerquan Information Technology (Shanghai) Co., Ltd. An expression composed of retrieval words and logical operators is parsed into a retrieval command that can be recognized and executed by an Elasticsearch search engine, and the retrieval result is obtained through Elasticsearch.
[0004] However, the current prior art is only applicable to a specific search engine, such as Elasticsearch mentioned above. At the same time, in the face of heterogeneous data retrieval, the prior art has no adaptability and scalability. Moreover, the formats of patent data in different countries are different, and the storage methods of data are also various, and the prior art cannot adapt to different data formats and data storage methods. SUMMARY
[0005] In order to solve the above problems existing in the prior art, the present application provides a method for converting a patent retrieval expression into a search engine query statement. The technical problem to be solved by the present application is solved by the following technical scheme:
[0006] obtaining a patent retrieval expression to be processed;
[0007] parsing a string corresponding to the patent retrieval expression by using a pre-constructed tokenizer to obtain a plurality of parsed words; wherein the patent retrieval expression and the tokenizer are constructed based on a pre-defined extensible patent retrieval expression syntax structure;
[0008] based on the patent retrieval expression syntax structure, the plurality of words are processed into a list of standard syntax nodes;
[0009] a standard syntax tree is generated according to the list of standard syntax nodes;
[0010] the standard syntax tree is converted into a query statement of the target search engine by using a pre-constructed syntax converter matched with the target search engine.
[0011] The present application has the following advantages:
[0012] In the scheme provided by the present application, an extensible patent retrieval expression syntax structure is defined in advance, so that any patent retrieval expression to be processed is expressed according to the patent retrieval expression syntax structure. Meanwhile, a general word segmenter is pre-constructed on the basis of the patent retrieval expression syntax structure, and a syntax converter matched with different target search engines is pre-constructed. The patent retrieval expression to be processed is converted into a query statement of the corresponding target search engine based on the constructed word segmenter and syntax converter. Specifically, the word segmenter is used to analyze the string corresponding to the patent retrieval expression to be processed after the patent retrieval expression to be processed is obtained, so as to obtain a plurality of words parsed. The plurality of words are processed into a list of standard syntax nodes based on the patent retrieval expression syntax structure. Then, a standard syntax tree is generated according to the list of standard syntax nodes, so as to model the patent retrieval expression into a standard data structure. Since the standard syntax tree is a general semantic structure, which is independent of actual data structure, data storage mode and data query engine, and has a high degree of standardization, the standard syntax tree has a high degree of adaptability to various data formats, data storage modes, data query engines and heterogeneous retrievals. Finally, the standard syntax tree is converted into a query statement of the target search engine by using the syntax converter, so as to perform patent retrieval. Since the syntax converter can be easily constructed according to the search engine used for actual patent query, the standard syntax tree can be converted into a query language of a specific search engine, so that the syntax converter has a strong adaptability and extensibility, and provides great convenience for patent retrieval. BRIEF DESCRIPTION OF DRAWINGS
[0013] Figure 1 a flowchart of a method for converting a patent retrieval expression into a search engine query statement provided by the present application;
[0014] Figure 2 a flowchart of an algorithm of the next function provided by the present application;
[0015] Figure 3 a graphical expression form of the standard syntax tree generated by example one in the present application;
[0016] Figures 4(a) to 4(c) The content after different transformations in Example 1 is respectively in Figure 3 The form of expression in;
[0017] Figure 5 This is a graphical representation of the standard syntax tree generated in Embodiment 2 of the present invention;
[0018] Figures 6(a) to 6(b) The content after different transformations in Example 2 is respectively in Figure 5 The expression form in Chinese. Detailed Implementation
[0019] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0020] To be compatible with multiple search engines, provide adaptability and scalability of search expressions for retrieving heterogeneous data, and adapt to different data formats and data storage methods, embodiments of the present invention provide a method for converting patent search expressions into search engine query statements.
[0021] It should be noted that the execution entity of the method for converting a patent search expression into a search engine query statement provided in this embodiment of the invention can be a device for converting a patent search expression into a search engine query statement, and the device can run in an electronic device. This electronic device can be a server or a terminal device, but is not limited to these.
[0022] like Figure 1 As shown in the embodiment of the present invention, a method for converting a patent search expression into a search engine query statement may include the following steps:
[0023] S1, Obtain the patent search expression to be processed;
[0024] To improve adaptability to various search engines and data structures, formats, and storage methods, this invention predefines an extensible patent search expression syntax structure and implements the method based on this structure. The patent search expression to be processed is constructed based on this predefined extensible patent search expression syntax structure. To facilitate understanding of the embodiments of this invention, this extensible patent search expression syntax structure is first introduced.
[0025] In an alternative embodiment, any patent search expression constructed based on a predefined extensible patent search expression syntax structure comprises:
[0026] a field name, an operator, and a field value.
[0027] The field name represents the name of a search field for a patent. It can be understood that the field name is a content item appearing in the cataloging items of the patent text, the text content, and other patent input information. For example, the field name can include the application number, the title, the specification, the current applicant (patentee), the inventor, the agency, the application date, the priority country, the IPC classification number, the application field classification, and the like. Of course, the field name can also include content items such as references, homologues, legal status, licenses, litigation, and right transfers, which are not listed here. The format of the field name can include any character such as Chinese, English, and symbols, but the field name does not contain characters involved in the operator. For example, the field name can be the patent title, AP, IPC-MAIN, and the like.
[0028] The field value includes the search content for the field name. For example, if it is desired to search for a patent containing the engine in the title, the field name is the title, and the field value is the engine. The field value can be a number, a date, a single string, and a string with a wildcard, and the like. For example, the field value can be car, comput*, 20190101, 7, and the like. Among them, car and 7 are single strings; 20190101 is a date; and comput* is a string with a wildcard, where the * represents a wildcard representing 0 or more characters, and the meaning of comput* is to match the patents whose content before the field name contains the string comput.
[0029] The operator represents the operation of the field name and the field value, and the operation of the sub-expression in the patent search expression.
[0030] In the embodiment of the application, the operator at least includes the following 8 types. They are respectively:
[0031] 1) Logical operators, such as AND, OR, NOT, and the like.
[0032] Specifically, AND indicates that the search terms on both sides exist at the same time; OR indicates that the search terms on both sides appear at least one of them; and NOT indicates excluding the search term after it.
[0033] 2) Truncation symbols, such as "*", "?", "$", and the like.
[0034] Among them, the symbol in the double quotes is the example of the truncation symbol. The truncation symbol is used to fuzzy search the file. "*" is an unlimited truncation symbol, which is used to replace zero, single or multiple characters at the end of the word; "?" is often used in the middle of the word to replace a character; "$" is used to replace zero or one character.
[0035] 3) Position operator. For example, (w), (n), etc.
[0036] Specifically, (W) means that the search terms on both sides must appear in the order of before and after, and no other words are allowed to be inserted between the search terms on both sides, but only spaces or a punctuation mark. (N) means that the positions of the search terms on both sides can be interchanged, and no other words are allowed to be inserted between the search terms on both sides, but spaces or punctuation marks are allowed.
[0037] 4) Same sentence operator. For example, (s), etc.
[0038] Specifically, (s) means that the connected search terms must appear in the same sentence at the same time, but the relative order of the connected search terms and the number of intervening words are not limited.
[0039] 5) Same paragraph operator. For example, (p), etc.
[0040] Specifically, (p) means that the connected search terms must appear in the same paragraph at the same time, but the relative order of the connected search terms and the number of intervening words are not limited.
[0041] 6) Range search symbol. For example, to, >, >=, <, <=, =, ==, etc.
[0042] Specifically, among them, == means complete content matching, and the meanings of the rest of the range search symbols are not described. 7) Special character. For example, ".", " / ", etc.
[0043] Among them, the symbol in the double quotes is the example of the special character. The special character has no actual meaning when searching and will be ignored.
[0044] 8) C-CETS character. For example, n, / HIGH, / LOW, / SEN, / FREC, etc.
[0045] Specifically, the %n operator can be used to search the frequency of each classification number, n takes a value greater than 1, and searches for documents with the classification number appearing n times; / HIGH means that the classification number itself and the upper grouping classification number in the extended search search formula are searched; / LOW means that the classification number itself and the lower grouping classification number in the extended search search formula are searched; / SEN means searching for the position of the classification number, supporting setting the position range of the searched classification number; / FREC means searching for the number of occurrences of the entire C-SETS classification number.
[0046] The specific meanings and usage rules of the above eight operators are described in the relevant technical understanding, and will not be described in detail here.
[0047] Any of the above operators can be connected with field names and field values, alone or in combination according to certain rules to obtain a patent search expression. In order to facilitate understanding, the following gives several examples to illustrate the form of the patent search expression to be processed by the embodiments of the present application.
[0048] Example 1: "TI=(engine OR motor NOT engine)", this patent search expression is used to search for patents whose title (the abbreviation of title is TI) contains the two words "engine" or "motor", but the title cannot contain the word "engine". In this example, the field name is TI; the field values are engine, motor, engine; and the operators include the two logical operators OR and NOT.
[0049] Example 2: "TI=en???er", this patent search expression indicates that the patent title needs to have a part that matches the rule that there must be two characters between en and er. In this example, the field name is TI; the field values are en, er; and the operator is the truncation symbol "?", which represents 1 character.
[0050] Example 3: "TI=(different(3w)focus(9w)photograph)", this patent search expression indicates that the patent title needs to contain the three words "different", "focus", and "photograph", and there must be 0-3 characters between "different" and "focus", and 0-9 characters between "focus" and "photograph". In this example, the field name is TI; the field values are different, focus, photograph; and the operator is the position operator (w), and the value before w indicates the upper limit value of the interval characters.
[0051] Example 4: "Description=(transformer(p)capacitor(p)feedback loop)", this patent search expression indicates that a certain paragraph in the patent description must contain the three words "transformer", "capacitor", and "feedback loop". In this example, the field name is Description; the field values are transformer, capacitor, feedback loop; and the operator is the same paragraph operator (p).
[0052] Example 5: "TI=computer AND specification=computer device", the patent search expression is composed of two sub-expressions: "TI=computer" and "specification=computer device", any sub-expression includes field name, operator and field value; two sub-expressions are connected by AND logical operator, which means that the word "computer" must be included in the patent title, and the word "computer device" must be included in the patent specification. It can be understood that in this example, the field names in the front and back two sub-expressions are TI and specification respectively; the field values are computer and computer device respectively; and the operator is the logical operator AND.
[0053] It should be noted that in the embodiments of the present application, the field name and the operator are extensible. That is, they can be freely extended according to actual needs, and are not limited to the above examples, so that the syntax structure of the patent search expression defined in the embodiments of the present application is extensible.
[0054] S2, using a pre-constructed tokenizer to parse the string corresponding to the patent search expression to obtain a plurality of parsed tokens;
[0055] The tokenizer is constructed based on the pre-defined extensible patent search expression syntax structure.
[0056] Specifically, after defining the above-mentioned patent search expression syntax structure, the tokenizer for parsing can be constructed for the patent search expression under its specification.
[0057] The working principle of the tokenizer is to disassemble the content of the string corresponding to the patent search expression according to the blank symbol set, the symbol set and the keyword set defined by the embodiments of the present application, and divide it into multiple tokens. Each token obtained does not have logic and only represents the basic unit after the string corresponding to the patent search expression is divided.
[0058] The blank symbol set is composed of multiple blank symbols, and the blank symbol is used to realize the function of separation. The blank symbol in the embodiments of the present application includes space symbol, carriage return symbol, line feed symbol and tab symbol. The space symbol is a space; the carriage return symbol, the line feed symbol and the tab symbol are represented as \r, \n and \t respectively.
[0059] The symbol set is composed of multiple symbols, which includes various commonly used symbols such as =, ==, >, >=, <, <=, (, ), " and the like. Compared with the symbols used in the field name and the symbols used in the operator, the symbol set contains a larger range of symbols.
[0060] The keyword set is composed of multiple keywords, each keyword is complete and has semantics, which can be Chinese, English or other characters, such as student, car, bag, and, or, not, to, etc.
[0061] In the embodiment of the present application, the tokenizer is initialized first when the tokenization is performed, the blank symbol set, the symbol set and the keyword set are introduced, and a pointer is maintained, which points to the offset position of the current processed patent search expression, that is, the current position pointed by the pointer is the position of the current patent search expression to be processed. The tokenization of the patent search expression is completed by judging the character at the current position pointed by the pointer and moving the pointer to the next position after the operation at the current position is completed so as to continue the operation of the subsequent character.
[0062] In an optional embodiment, the tokenizer is used to analyze the string corresponding to the patent search expression, and a plurality of tokens obtained by the analysis are obtained, including:
[0063] Based on the pre-defined blank symbol set, the symbol set and the keyword set, the next function is used to obtain the next token in the patent search expression from the current position pointed by the pointer, and the pointer position is updated to repeat the process of obtaining the next token in the patent search expression until the next token cannot be obtained, and the plurality of tokens obtained by the analysis of the patent search expression are obtained.
[0064] In order to simplify the processing and improve the efficiency, the next function is provided to obtain the next token from the position pointed by the current pointer. The next function ignores the blank symbol, and the type of any token is one of the symbol, the keyword or the string. The string is the character and the character combination except the elements in the blank symbol set, the symbol set and the keyword set.
[0065] In an optional embodiment, please refer to Figure 2 Based on the pre-defined blank symbol set, the symbol set and the keyword set, the next function is used to obtain the next token in the patent search expression from the current position pointed by the pointer, including:
[0066] In step a1, it is judged whether there is an unprocessed matching result in the last matching result before the current position pointed by the pointer. If yes, step a2 is executed; if no, step a5 is executed.
[0067] The current position pointed by the pointer is a current position to be processed of the patent search expression at any time. According to the current position pointed by the pointer, a last matching result before the current position can be obtained, which can be one matching result or multiple matching results. Each matching result indicates that part of a string corresponding to the patent search expression is confirmed to be any one of a blank symbol, a symbol and a keyword after being read. For one matching result, it can be immediately determined to be a word or not a word, and at this time, it is a processed matching result; it can also be not immediately determined to be a word or not a word because whether there is a matching result associated with it after it is unknown, and thus needs to be determined later, and at this time, the matching result is an unprocessed matching result; that is, the unprocessed matching result indicates that the corresponding content is confirmed to be any one of a blank symbol, a symbol and a keyword, but a word determination result is not obtained; the word determination result is a word or not a word. For example, the unprocessed matching result in the last matching result is the keyword “I”, and the reason why it is an unprocessed matching result is that there is a keyword “we” in the keyword set, and thus the keyword “I” cannot be immediately determined to be a word in the case that the matching result of the subsequent character is unknown.
[0068] Step a2, obtaining a last unprocessed matching result;
[0069] If there are multiple unprocessed matching results last time, the closest one to the current position is obtained.
[0070] Step a3, determining whether the obtained last unprocessed matching result is a blank symbol; if yes, executing step a1; if no, executing step a4;
[0071] Specifically, since the blank symbol is only used as an interval and does not have actual meaning, if the obtained last unprocessed matching result is a blank symbol, it cannot be determined to be a word, and it is returned to step a1 as a processed matching result to find the next word. It can be understood that the pointer will be moved to the blank symbol after the return to step a1.
[0072] Step a4, determining the obtained last unprocessed matching result to be a word;
[0073] Specifically, if the obtained last unprocessed matching result is not a blank symbol, it can be determined to be a word.
[0074] Step a5, trying to obtain a next matching result by moving the pointer character by character;
[0075] Specifically, the pointer is moved character by character from the current position, and at each stop position, it is determined whether the content moved is any of a blank symbol, a symbol and a keyword; if so, the matched content is determined as a match result; if not, the pointer is moved to continue the determination. Wherein, when the match result is determined, the stop position of the pointer is the end position corresponding to the match result.
[0076] Step a6, it is determined whether the next match result can be obtained; if not, step a7 is executed; if so, step a8 is executed;
[0077] Step a7, before attempting to obtain the next match result, all remaining texts after the current position pointed by the pointer are determined as a word segmentation result.
[0078] Specifically, if the pointer is moved character by character, the next match result cannot be obtained, and before attempting to obtain the next match result, all remaining texts after the current position pointed by the pointer are determined as a word segmentation result.
[0079] Step a8, it is determined whether there is text between the end position corresponding to the next match result obtained and the current position pointed by the pointer before attempting to obtain the next match result; if so, step a9 is executed; if not, step a10 is executed.
[0080] Specifically, if the pointer is moved character by character, the next match result can be obtained, and the content between the end position corresponding to the next match result and the current position pointed by the pointer before attempting to obtain the next match result is determined whether it is a text.
[0081] Step a9, the part corresponding to the text is determined as a word segmentation result, and the obtained next match result is temporarily stored.
[0082] Specifically, if there is text between the end position corresponding to the next match result and the current position pointed by the pointer before attempting to obtain the next match result, the part corresponding to the text is directly determined as a word segmentation result, the current word segmentation analysis is completed, and the obtained next match result is temporarily stored to be determined whether it is a word segmentation result next time. At this time, it can be understood that the pointer points to the end position of the next match result.
[0083] Step a10, it is determined whether the obtained next match result is a blank symbol; if so, step a1 is executed; if not, step a11 is executed.
[0084] Specifically, if there is no text between the end position corresponding to the next matching result and the current position pointed by the pointer before the next matching result is acquired, it is further needed to determine whether the acquired next matching result is a blank symbol, if yes, it cannot be determined as a word, and it is returned to step a1 to find the next word as a processed matching result. It can be understood that before returning to step a1, the pointer is moved to the blank symbol.
[0085] Step a11, the acquired next matching result is determined as a word.
[0086] Specifically, the acquired next matching result can be directly determined as a word.
[0087] S3, based on the syntax structure of the patent search expression, processing the multiple words into a list of standard syntax nodes;
[0088] Since the words obtained by the word segmenter do not reflect the syntax of the patent search expression, it is needed to determine and process the words to process all the words into standard syntax nodes conforming to the syntax structure of the patent search expression.
[0089] In an optional embodiment, S3 can include the following steps:
[0090] Step b1, acquiring a next word from the word segmenter; acquiring a standard syntax node according to the word, and determining whether the node is empty; if yes, ending the process; if no, executing step b2;
[0091] Wherein, the corresponding next word for the first execution is the first word; the standard syntax node indicates that the content type belongs to any one of the field name, the operator or the field value; the node being empty indicates that the next word cannot be acquired from the word segmenter. The process of acquiring the standard syntax node according to the word is described below.
[0092] If the node is empty, it indicates that all the words have been processed, at this time, the list of standard syntax nodes has been constructed, and thus the process is ended. If the node is not empty, it indicates that the processing needs to be continued, and thus step b2 is executed.
[0093] Step b2, determining whether the standard syntax node is not a left square bracket; if yes, executing step b3; if no, executing step b4;
[0094] Step b3, adding the standard syntax node to the list of standard syntax nodes, and repeating step b1;
[0095] Specifically, in the patent search expression, when a search string is needed, it is usually limited by the left square bracket and the right square bracket. For example, when some date range is searched or some quantity range is searched, such as searching for a patent with an application date of 20220901 to 20220916, the patent search expression is APD:[20220901TO 20220916], wherein APD is an abbreviation of the application date field name. Or, search for a patent with a claim number of 1 to 10, the patent search expression is CLAIM_COUNT:[1TO 10], wherein CLAIM_COUNT is an abbreviation of the claim number field name.
[0096] Therefore, for each standard syntax node, it is first determined whether it is a left square bracket; if the standard syntax node is not a left square bracket, it means that it can be used as a single standard syntax node, and therefore the standard syntax node can be added to the list of standard syntax nodes. If the standard syntax node is a left square bracket, it means that it cannot be used as a single standard syntax node, and the content between the left and right square brackets needs to be found for judgment.
[0097] Step b4, get the next token from the tokenizer; get the standard syntax node according to the token; and determine whether the node is empty or the node content is not a string; if yes, throw an exception and terminate the process; if no, execute step b5;
[0098] Specifically, if the node is empty, it means that the process needs to be ended, and if the node content is not a string, it does not meet the normal definition of the left and right square brackets in the patent search expression, indicating that an exception occurs. If the node is not empty and the node content is a string, it means that the state is normal, and step b5 needs to be executed.
[0099] Step b5, get the next token from the tokenizer; get the standard syntax node according to the token; and determine whether the node is empty or the node content is not the character "to"; if yes, throw an exception and terminate the process; if no, execute step b6;
[0100] Specifically, when the left square bracket and the right square bracket in the patent search expression perform string search, according to the regulation, there should be a character "to" in the string, and if the node content is not the character "to", it means that an exception occurs. If the node is not empty and the node content is the character "to", it means that the state is normal, and step b6 needs to be executed.
[0101] It should be noted that the character "to" in the embodiment of the application is not case-sensitive.
[0102] Step b6, get the next token from the tokenizer; get the standard grammar node according to the token; and determine whether the node is empty or the node content is not a string; if yes, throw an exception and terminate the process; if no, execute step b7;
[0103] It can be understood that step b4 is used to determine the content between the left square bracket and the character "to", and step b6 is used to determine the content between the character "to" and the right square bracket, and the execution manner is similar.
[0104] Step b7, get the next token from the tokenizer; get the standard grammar node according to the token; and determine whether the node is empty or the node content is not a right square bracket; if yes, throw an exception and terminate the process; if no, execute step b8;
[0105] Specifically, if the node is empty or the node content is not a right square bracket, it indicates that an exception occurs; if the node is not empty and the node content is a right square bracket, it indicates that the state is normal and the entire content between the left and right square brackets has been found.
[0106] Step b8, combine all the standard grammar nodes obtained before into a string grammar node in order, and add it to the list of standard grammar nodes, and then repeat step b1;
[0107] Specifically, all the standard grammar nodes obtained in steps b1-b7 are combined into a string grammar node in order, wherein the string grammar node is a special type of standard grammar node. After the string grammar node is added to the list of standard grammar nodes, step b1 is repeated until step b1 gets the next token from the tokenizer, and when the standard grammar node is obtained according to the token, it is determined that the node is empty, and the process is ended to obtain the final list of standard grammar nodes.
[0108] The process of obtaining the standard grammar node according to the token is described below.
[0109] In an optional implementation, obtaining the standard grammar node according to the token includes:
[0110] Step c1, if the type of the token is not a symbol, directly wrap the token into a normal standard grammar node; otherwise, execute step c2;
[0111] Step c2, if the token is not a double quotation mark in English form, directly wrap the token into a normal standard grammar node; otherwise, execute step c3;
[0112] Step c3, determine whether the next matching double quotation mark can be found backward; if no, throw an exception; if yes, execute step c4;
[0113] Step c4, wrap the content between two double quotes into a string syntax node.
[0114] Wherein, the symbol in step c1 is an element in the symbol set. The next matched double quote in step c3 is the one after a pair of double quotes in English form; the normal standard syntax node is relative to the string syntax node which is a special standard syntax node.
[0115] After S3, all the tokens in the patent search expression can be extracted by a tokenizer and processed into a list of standard syntax nodes by certain rules for subsequent construction of a standard syntax tree.
[0116] S4, generating a standard syntax tree according to the list of standard syntax nodes;
[0117] S4 mainly processes the list of standard syntax nodes obtained in S3 into a standard syntax tree according to the defined syntax structure of the patent search expression, wherein the semantics and priority of different operators need to be considered. The standard syntax tree generated by S4 has only one final root node, each node can have 0-2 child nodes, all the leaf nodes are field names or field values, and all the internal nodes are operators.
[0118] In an optional implementation, S4 includes:
[0119] Step d1, defining a stack valueStack for storing field name nodes, field value nodes or sub-expression root nodes, and defining a stack symbolStack for storing operator nodes;
[0120] Wherein, the initial state of valueStack and symbolStack is empty.
[0121] Step d2, defining a pointer i pointing to the position of the current node to be processed in nodeList;
[0122] Wherein, nodeList represents the list of standard syntax nodes.
[0123] Step d3, if i is greater than or equal to the total number of nodes in nodeList, executing step d4; otherwise, executing step d5;
[0124] Specifically, if i is greater than or equal to the total number of nodes in nodeList, it indicates that all nodes have been processed.
[0125] Step d4, take out an operator node a from the current symbolStack, and take out two nodes b and c from the current valueStack, construct a binary operation node with node a as the operator, node b as the left child node, and node c as the right child node, and then press the binary operation node into the current valueStack, repeat the step until the current symbolStack is empty, and execute step d12;
[0126] Wherein, a, b, c only represent the code of the node, and do not limit the content of the node.
[0127] Step d5, get the node n at position i from the nodeList, and add 1 to i; if the segmentation type of node n is a string, execute step d6; otherwise, execute step d7;
[0128] Step d6, if the segmentation type of the previous node of node n is also a string, press node n and an AND operator into the current valueStack, and then repeat step d3; if the segmentation type of the previous node of node n is not a string, only press node n into the current valueStack, and then repeat step d3;
[0129] Step d7, if the current symbolStack is empty, press node n into the current symbolStack, and then repeat step d3; otherwise, execute step d8;
[0130] Step d8, if node n is a left parenthesis, press node n into the current symbolStack, and then repeat step d3; otherwise, execute step d9;
[0131] Step d9, check the priority of the top node t of the current symbolStack, if the priority of node n is less than or equal to the priority of the top node t, execute step d10; otherwise, execute step d11; wherein, the priority of each operator is predefined;
[0132] Step d10, take out the top node t, and take out two nodes e and f from the current valueStack, construct a binary operation node with the top node t as the operator, node e as the left child node, and node f as the right child node, and then press the binary operation node into the current valueStack, and then repeat step d9;
[0133] Similarly, t, e, f only represent the code, and do not limit the content of the node.
[0134] Step d11, press node n into the current symbolStack, and then repeat step d3;
[0135] Step d12, judging whether there is only one node left in the current valueStack, if yes, taking the remaining node as the root node of the finally generated standard syntax tree; if no, throwing an exception and stopping the flow.
[0136] It can be understood that after obtaining the root node of the finally generated standard syntax tree, the standard syntax tree can be obtained according to the known relationship between the nodes.
[0137] The standard syntax tree generated in S4 contains the logical semantics of the entire patent search expression, and the semantics is universal and irrelevant to specific data formats, data storage methods and data query engines. Therefore, it can adapt to various data formats, data storage methods, data query engines and heterogeneous search.
[0138] For specific processing procedures of each step in S4, please refer to the relevant technical understanding, which will not be described in detail here.
[0139] Among them, the priority of each operator in the embodiment of the application is shown in part in Table 1.
[0140] Table 1 Predefined operator priority (part)
[0141]
[0142]
[0143] S5, using a pre-constructed syntax converter matched with the target search engine, converting the standard syntax tree into a query statement of the target search engine.
[0144] In the embodiment of the application, the target search engine includes Elasticsearch and mysql. For the concepts of the two, please refer to the relevant technical understanding. Of course, the target search engine of the embodiment of the application is not limited to the two.
[0145] In order to adapt to specific search environment, the embodiment of the application needs to customize a matching syntax converter for each target search engine, so as to convert the standard syntax tree into a query statement of the target search engine, and realize search in specific environment.
[0146] The following describes the case where the target search engine is Elasticsearch and mysql respectively.
[0147] (1) The target search engine is Elasticsearch
[0148] In an optional implementation, when the target search engine is Elasticsearch, a pre-constructed syntax converter matching the target search engine is used to convert the standard syntax tree into a query statement of the target search engine, including:
[0149] Step e1, obtain the root node r currently being processed, and perform step e2;
[0150] In the first execution, the root node r currently being processed is the root node of the standard syntax tree. It can be understood that after the first execution, the root node r currently being processed can be a root node at a level below the root node of the standard syntax tree.
[0151] Step e2, if the root node r currently being processed is not a binary operation node, an exception is thrown and the process is terminated; otherwise, step e3 is performed;
[0152] It can be understood that the root node r currently being processed should be a binary operation node in a normal state.
[0153] Step e3, if the operator of the root node r currently being processed is a logical operator, step e4 is performed; otherwise, step e7 is performed;
[0154] Step e4, obtain the root node r-left of the left subtree of the root node r currently being processed, and recursively perform step e2 to obtain the left clause left of the root node r currently being processed;
[0155] It can be understood that the root node r-left of the left subtree of the root node r currently being processed is the root node r currently being processed when recursively performing step e2.
[0156] Step e5, obtain the root node r-right of the right subtree of the root node r currently being processed, and recursively perform step e2 to obtain the right clause right of the root node r currently being processed;
[0157] It can be understood that the root node r-right of the right subtree of the root node r currently being processed is the root node r currently being processed when recursively performing step e2.
[0158] The concepts of left subtree and right subtree are understood in combination with related technologies and are not described in detail here.
[0159] Step e6, according to the logical operator of the root node r currently being processed, combine the left clause left and the right clause right into a bool query statement of Elasticsearch; and return to step e3;
[0160] The concepts of left clause left and right clause right are understood in combination with related technologies and are not described in detail here.
[0161] Step e7, taking the left child tree of the current processing root node r as the field name k and the right child tree as the field value v, converting k and v into a query statement in Elasticsearch according to the conversion algorithm corresponding to the operator op of the current processing root node r, and returning to step e3.
[0162] It can be understood that when step e7 is executed, the left child tree of the current processing root node r is taken as the field name k and the right child tree is taken as the field value v.
[0163] Among them, since the conversion algorithms of different operators op have different algorithm logics, an example is taken for illustration.
[0164] When the operator op of the current processing root node r is the match symbol “=”, according to the conversion algorithm corresponding to the operator op of the current processing root node r, k and v are converted into a query statement in Elasticsearch, including:
[0165] Step g1, if the segmentation type of v is a string, step g2 is executed; otherwise, step g3 is executed.
[0166] Step g2, according to the content of v, k and v are packaged into a corresponding Elasticsearch query statement, and the process ends.
[0167] Among them, the Elasticsearch query statement includes the term query statement, the range query statement or the wildcard query statement of Elasticsearch. The specific concept of the above query statements can be referred to related technical understanding, which is not described here.
[0168] Step g3, if the operator of v is not a logical operator, an exception is thrown, and the process ends; otherwise, step g4 is executed.
[0169] Step g4, taking the root node v-left of the left child tree of v, recursively executing step g1 to obtain the left clause left of v.
[0170] Step g5, taking the root node v-right of the right child tree of v, recursively executing step g1 to obtain the right clause right of v.
[0171] Step g6, according to the logical operator of v, the left clause left and the right clause right of v are combined into a bool query statement of Elasticsearch, and the process ends.
[0172] (2) The target search engine is mysql
[0173] In an optional embodiment, when the target search engine is mysql, a pre-constructed syntax converter matching the target search engine is used to convert the standard syntax tree into a query statement of the target search engine, comprising:
[0174] In step f1, the root node r currently being processed is obtained, and step f2 is executed; when executed for the first time, the root node r currently being processed is the root node of the standard syntax tree;
[0175] In step f2, if the root node r currently being processed is not a binary operation node, an exception is thrown, and the process is terminated; otherwise, step f3 is executed;
[0176] In step f3, if the operator of the root node r currently being processed is a logical operator, step f4 is executed; otherwise, step f7 is executed;
[0177] In step f4, the root node r-left of the left subtree of the root node r currently being processed is taken out, and the left clause left of the root node r currently being processed is obtained by recursively executing step f2;
[0178] In step f5, the root node r-right of the right subtree of the root node r currently being processed is taken out, and the right clause right of the root node r currently being processed is obtained by recursively executing step f2;
[0179] In step f6, the left clause left and the right clause right are combined into an and, or or not query statement of mysql according to the logical operator of the root node r currently being processed; and step f3 is returned;
[0180] In step f7, the left subtree of the root node r currently being processed is taken as the field name k, and the right subtree is taken as the field value v; k and v are converted into a query statement in mysql according to the conversion algorithm corresponding to the operator op of the root node r currently being processed; and step f3 is returned.
[0181] For specific steps, please refer to the corresponding understanding of the above-mentioned related steps of Elasticsearch, which will not be described in detail here. The conversion algorithms of different operators op also have different algorithm logics, which will not be illustrated here.
[0182] In the scheme provided by the embodiment of the application, an extensible patent retrieval expression syntax structure is defined in advance, so that any to-be-processed patent retrieval expression is expressed according to the patent retrieval expression syntax structure; meanwhile, a general tokenizer is constructed in advance on the basis of the patent retrieval expression syntax structure, and a matching syntax converter is constructed in advance for different target search engines. The to-be-processed patent retrieval expression is converted into a query statement of a corresponding target search engine based on the constructed tokenizer and syntax converter.
[0183] Specifically, after obtaining the patent retrieval expression to be processed, the string corresponding to the patent retrieval expression is parsed by using a word segmenter to obtain a plurality of parsed words; the plurality of parsed words are processed into a list of standard syntax nodes based on the syntax structure of the patent retrieval expression; then a standard syntax tree is generated according to the list of standard syntax nodes, so as to model the patent retrieval expression into a standard data structure; since the standard syntax tree is a general semantic structure, which is irrelevant to actual data structure, data storage mode and data query engine, and has a high degree of standardization, the adaptability to various data formats, data storage modes, data query engines and heterogeneous retrievals is high. Finally, the standard syntax tree is converted into a query statement of a target search engine by using a syntax converter to perform patent retrieval. Since the syntax converter can be conveniently constructed according to the search engine used for actual patent query, the standard syntax tree is converted into a query language of a specific search engine, so that the syntax converter has high adaptability and expansibility, and provides great convenience for patent retrieval.
[0184] In order to facilitate understanding of the execution process of the method of the embodiment of the present application, two specific embodiments are described below.
[0185] (1) Embodiment One:
[0186] For S1, the patent retrieval expression to be processed is as follows:
[0187] “title=((bicycle OR bike) AND tandem) OR description=(cycling gears two wheeled)”
[0188] For S2, the parsed words obtained after the patent retrieval expression is parsed by the word segmenter are shown in Table 2.
[0189] Table 2 Parsed words obtained after the patent retrieval expression of embodiment one is parsed by the word segmenter
[0190]
[0191]
[0192] For S3-S4, the process of generating the standard syntax tree is shown in Table 3.
[0193] Table 3 Process of generating the standard syntax tree of embodiment one
[0194]
[0195] The graphical expression form of the finally generated standard syntax tree is shown in Figure 3 , Figure 3The graphical expression form of the standard syntax tree generated in the first embodiment of the present application.
[0196] The final generated string expression form of the standard syntax tree is:
[0197] "Title=((bicycle OR bike) AND double) OR Description=((ride AND gear) AND two-wheel)"
[0198] To verify, the standard syntax tree can be compared with the patent search expression to be processed in S1 of the first embodiment, and it is found that the standard syntax tree completely conforms to the original semantics of the patent search expression, proving that the standard syntax tree is indeed the standard syntax tree of the patent search expression. However, it needs to be made clear that in the actual implementation of the method of the embodiment of the present application, the above verification process is not required. Moreover, in the embodiment of the present application Figure 3 Each node is provided with a unique number in order to facilitate the description of the subsequent process.
[0199] For S5, take the target search engine Elasticsearch as an example. The specific process is as follows:
[0200] Starting from the root node 1, since node 1 is a logical operator, it is necessary to recursively process its left and right subtrees, i.e., nodes 2 and 3.
[0201] Taking the processing of node 2 as an example, node 2 is a non-logical operator "=", indicating a matching relationship, and its left subtree is the field name and its right subtree is the field value. According to the description of the step in the introduction of Elasticsearch in S5 above, when the operator op of the currently processed root node r is the matching symbol "=", according to the operator op of the currently processed root node r, k and v are converted into the query statement of Elasticsearch.
[0202] Since node 5 is a logical operator, it is necessary to recursively process its left and right subtrees, i.e., nodes 8 and 9.
[0203] Taking the processing of node 8 as an example, since node 8 is a logical operator, it is necessary to recursively process its left and right subtrees, i.e., nodes 12 and 13.
[0204] Taking the processing of node 12 as an example, since the type of node 12 is a string, combining node 4, node 2, and node 12, the semantics here is that "bicycle" is contained in the title, and the query statement of Elasticsearch is: {"match_phrase": {"title": "bicycle"}}.
[0205] The converted content is represented in Figure 3 Figure 4(a).
[0206] Similarly, the query statement of node 13 converted to Elasticsearch is: {"match_phrase": {"title": "bicycle"}}. The specific process is not described in detail.
[0207] After the processing of node 12 and node 13, node 8 can be processed. The logical operator of node 8 is OR, which means that the conditions of node 12 and node 13 can be met at the same time. Therefore, the contents of node 12 and node 13 are combined into the bool query of Elasticsearch, and the relationship is represented by should. The query statement of node 8 converted to Elasticsearch is: {"bool": {"should": [{"match_phrase": {"title": "bicycle"}}, {"match_phrase": {"title": "bicycle"}} ]}}.
[0208] The converted content is represented in Figure 3 Figure 4(b).
[0209] The processing of node 9 is the same as that of node 12 and node 13, which is not described here.
[0210] After the processing of node 8 and node 9, node 5 can be processed. The logical operator of node 5 is AND, which means that the conditions of node 8 and node 9 must be met at the same time. Therefore, the contents of node 8 and node 9 are combined into the bool query of Elasticsearch, and the relationship is represented by must. The query statement of node 5 converted to Elasticsearch is:
[0211] {"bool": {"must": [{"bool": {"should": [{"match_phrase": {"title": "bicycle"}}, {"match_phrase": {"title": "bicycle"}} ]}}, {"match_phrase": {"title": "double"}} ]}}.
[0212] After the processing of node 5, node 2 is processed. The converted content is represented in Figure 3 Figure 4(c).
[0213] The processing of node 3 is the same as that of node 2, which is not described here. The query statement of node 3 converted to Elasticsearch is:
[0214] {"bool":{"must":[{"bool":{"must":[{"match_phrase":{"description":"riding"}},
[0215] {"wildcard":{"description":{"value":"variable*"}}}]}},{"match_phrase":{"description":"two-wheel"}}]}}.
[0216] Finally, back to the processing of node 1, the contents of node 2 and node 3 are combined into the bool query of Elasticsearch, and the relationship is expressed by should, that is, the entire standard syntax tree can be converted into the query statement of Elasticsearch:
[0217] {"bool":{"should":[{"bool":{"must":[{"bool":{"should":[{"match_phrase":{"title":"bicycle"}},{"match_phrase":{"title":"pedal car"}}]}},{"match_phrase":{"title":"two-person"}}]}},{"bool":{"must":[{"bool":{"must":[{"match_phrase":{"description":"riding"}},{"wildcard":{"description":{"value":"variable*"}}}]}},{"match_phrase":{"description":"two-wheel"}}]}}]}}.
[0218] At this point, the patent search expression to be processed in embodiment one S1 is converted into the query statement of search engine Elasticsearch. The specific process can be understood in combination with each specific step in S5, and will not be described in detail here.
[0219] (2) Example two:
[0220] For S1, the patent search expression to be processed is as follows:
[0221] "Application date = [20110101 to 20130505] AND title = (computer OR algorithm)"
[0222] For S2, the tokenization of the patent search expression after being parsed by the tokenizer is shown in Table 4:
[0223] Table 4 Tokenization of the patent search expression in example two after being parsed by the tokenizer
[0224] Word type Word content String Filing date Symbol = String [20110101 to 20130505] Keyword AND String Title Symbol = Symbol ( String Computer Keyword OR String Algorithm Symbol )
[0225] For S3-S4, the process of generating the standard syntax tree is shown in Table 5.
[0226] Table 5 Process of generating the standard syntax tree in Example 2
[0227]
[0228]
[0229] The graphical representation of the finally generated standard syntax tree is shown in Figure 5 , Figure 5 The graphical representation of the standard syntax tree generated in Example 2 of the present application.
[0230] The string representation of the finally generated standard syntax tree is:
[0231] "Application date = [20110101 to 20130505] AND Title = (computer OR algorithm)"
[0232] Similarly, to verify, the standard syntax tree can be compared with the patent search expression to be processed in S1 of Example 2, and it is found that the standard syntax tree completely conforms to the original semantics of the patent search expression, proving that the standard syntax tree is indeed the standard syntax tree of the patent search expression.
[0233] Similarly, Figure 5 Each node is provided with a unique number.
[0234] For S5, take the target search engine mysql as an example. The specific process is as follows:
[0235] Starting from the root node 1, since node 1 is a logical operator, it is necessary to recursively process the left subtree and the right subtree, i.e. nodes 2 and 3.
[0236] Taking the processing of node 2 as an example, since node 2 is a non-logical operator "=", indicating a matching relationship, the left subtree is the field name and the right subtree is the field value, therefore according to the description in the foregoing S5 of the introduction of mysql, when the operator op of the currently processed root node r is the matching symbol "=", according to the operator op of the currently processed root node r, k and v are converted into the query statement of Elasticsearch according to the corresponding conversion algorithm, it is necessary to first process the right subtree, i.e. node 5.
[0237] Since node 5 represents a date range, combining node 4, node 2 and node 5, the semantics here is: "the application date is between 2011-01-01 and 2013-05-05", which is converted into the mysql query statement: application date between '2011-01-01' and '2013-05-05'.
[0238] After node 5 is processed, node 2 is also processed, and the converted content is represented in Figure 5 , as shown in Fig. 6(a).
[0239] After node 2 is processed, node 3 is processed, which is a non-logical operator "=". The left subtree of node 3 is a field name, and the right subtree of node 3 is a field value. Therefore, the right subtree, i.e. node 7, needs to be processed first.
[0240] Since node 7 is a logical operator, the left subtree and the right subtree of node 7, i.e. node 8 and node 9, need to be processed recursively.
[0241] Taking the processing of node 8 as an example, the type of node 8 is a string. Therefore, combining node 6, node 3 and node 8, the semantics here is: "the title contains 'computer'", which is converted into the mysql query statement: title like '%computer%'.
[0242] The processing of node 9 is the same as that of node 8, which will not be described herein.
[0243] After node 8 and node 9 are processed, node 7 can be processed. The logical operator of node 7 is OR, which means that the conditions of node 8 and node 9 are satisfied as long as one of them is satisfied. Therefore, the contents of node 8 and node 9 are combined into the or query of mysql, i.e. the mysql query statement is converted into: title like '%computer%' or title like '%algorithm%'.
[0244] After node 7 is processed, node 3 is also processed, and the converted content is represented in Figure 5 , as shown in Fig. 6(b).
[0245] Finally, the contents of node 2 and node 3 are combined into the and query of mysql, and the entire standard syntax tree is converted into the structured query statement of mysql:
[0246] ( application date between '2011-01-01' and '2013-05-05 ') and ( title like '%computer%' or title like '%algorithm%' ).
[0247] At this point, the patent search expression to be processed in Embodiment Two S1 is converted into a query statement of the search engine Elasticsearch. The specific process can be understood in combination with the specific steps in S5, and will not be described in detail here.
[0248] It can be seen that the method of the embodiments of the present application can convert the patent search expression to be processed into the query statement of the corresponding search engine for different search engines, so as to perform patent search in the corresponding search engine subsequently.
[0249] The above is only a preferred embodiment of the present application, and is not used to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application is included in the protection scope of the present application.
Claims
1. A method of converting a patent search expression into a search engine query statement, characterized by, The method comprises the following steps: acquiring a patent search expression to be processed; parsing a string corresponding to the patent search expression by using a pre-constructed tokenizer to obtain a plurality of parsed tokens; wherein the patent search expression and the tokenizer are constructed based on a pre-defined extensible patent search expression syntax structure; processing the plurality of tokens into a list of standard syntax nodes based on the patent search expression syntax structure; generating a standard syntax tree according to the list of standard syntax nodes; converting the standard syntax tree into a query statement of a target search engine by using a pre-constructed syntax converter matched with the target search engine; wherein any patent search expression constructed based on the pre-defined extensible patent search expression syntax structure comprises a field name, an operator and a field value; wherein the field name represents the name of a search field for patents; the field value comprises search content for the field name; the operator represents an operation on the field name and the field value, and an operation on a sub-expression in the patent search expression; any sub-expression comprises the field name, the operator and the field value; the field name does not contain characters involved in the operator; the parsing of the string corresponding to the patent search expression by using the pre-constructed tokenizer to obtain the plurality of parsed tokens comprises: based on a pre-defined set of white spaces, a set of symbols and a set of keywords, using a pre-set next function to obtain the next token in the patent search expression from a current position pointed by a pointer in the string corresponding to the patent search expression, and updating the position of the pointer to repeat the process of obtaining the next token in the patent search expression until no next token can be obtained, thereby obtaining the plurality of parsed tokens of the patent search expression; wherein the type of any token is one of a symbol, a keyword or a string; the string is characters and character combinations other than elements in the set of white spaces, the set of symbols and the set of keywords.
2. The method of converting patent search expressions into search engine query statements of claim 1, wherein, the obtaining of the next token in the patent search expression from the current position pointed by the pointer in the string corresponding to the patent search expression based on the pre-defined set of white spaces, the set of symbols and the set of keywords by using the pre-set next function comprises: step a1, judging whether there is an unprocessed matching result in a last matching result located before the current position pointed by the pointer; if yes, performing step a2; if no, performing step a5; wherein the unprocessed matching result means that the type of the corresponding content has been confirmed to be any one of white space, symbol and keyword, but no token judgment result has been obtained; the token judgment result is that it is a token or it is not a token; step a2, obtaining the last unprocessed matching result; step a3, judging whether the obtained last unprocessed matching result is a white space; if yes, performing step a1; if no, performing step a4; step a4, determining the obtained last unprocessed matching result as a token; Step a5, try to get the next matching result by moving the pointer character by character; Step a6, determine whether the next matching result can be obtained; if not, execute step a7; if yes, execute step a8; Step a7, determine the remaining text after the current position pointed by the pointer before trying to get the next matching result as the token; Step a8, determine whether there is text between the end position corresponding to the next matching result obtained and the current position pointed by the pointer before trying to get the next matching result; if yes, execute step a9; if not, execute step a10; Step a9, determine the part corresponding to the text as the token, and temporarily store the next matching result obtained; Step a10, determine whether the next matching result obtained is a blank symbol; if yes, execute step a1; if not, execute step a11; Step a11, determine the next matching result obtained as the token.
3. The method of converting patent search expressions into search engine query statements of claim 2, wherein, The method for processing the patent search expression syntax structure into a list of standard syntax nodes comprises: Step b1, get the next token from the tokenizer; get the standard syntax node according to the token, and determine whether the node is empty; if yes, end the process; if not, execute step b2; wherein the corresponding next token for the first execution is the first token; the standard syntax node indicates that the content type belongs to any one of the field name, operator or field value; the empty node indicates that the next token cannot be obtained from the tokenizer; Step b2, determine whether the standard syntax node is not a left square bracket; if yes, execute step b3; if not, execute step b4; Step b3, add the standard syntax node to the list of standard syntax nodes, and repeat step b1; Step b4, get the next token from the tokenizer; get the standard syntax node according to the token; and determine whether the node is empty or the node content is not a string; if yes, throw an exception and terminate the process; if not, execute step b5; Step b5, get the next token from the tokenizer; get the standard syntax node according to the token; and determine whether the node is empty or the node content is not the character "to"; if yes, throw an exception and terminate the process; if not, execute step b6; Step b6, get the next token from the tokenizer; get the standard syntax node according to the token; and determine whether the node is empty or the node content is not a string; if yes, throw an exception and terminate the process; if not, execute step b7; Step b7, get the next token from the tokenizer; get the standard syntax node according to the token; and determine whether the node is empty or the node content is not a right square bracket; if yes, throw an exception and terminate the process; if not, execute step b8; Step b8, combine all the standard syntax nodes obtained into a string syntax node in order, and add it to the list of standard syntax nodes, and then repeat step b1; wherein the string syntax node is a special type of standard syntax node.
4. The method of converting patent search expressions into search engine query statements of claim 3, wherein, The method for getting the standard syntax node according to the token comprises: Step c1, if the type of the token is not a symbol, directly wrap the token into a normal standard syntax node; otherwise, execute step c2; Step c2, if the token is not a double quote in English form, directly wrap the token into a normal standard syntax node; otherwise, execute step c3; Step c3, judge whether the next matching double quote can be found backwardly; if not, throw an exception; if yes, execute step c4; Step c4, wrap the content between the two double quotes into a string syntax node.
5. The method of converting patent search expressions into search engine query statements of claim 4, wherein, The generating a standard syntax tree according to the list of standard syntax nodes comprises: Step d1, define a stack valueStack for storing field name nodes, field value nodes or child expression root nodes, and define a stack symbolStack for storing operator nodes; Step d2, define a pointer i pointing to the position of the current node to be processed in nodeList; wherein, nodeList represents the list of standard syntax nodes; Step d3, if i is greater than or equal to the total number of nodes in the nodeList, execute step d4; otherwise, execute step d5; Step d4, take an operator node a from the current symbolStack, and take two nodes b and c from the current valueStack, take node a as an operator, take node b as a left child node, and take node c as a right child node, construct a binary operation node with the three nodes, and press the binary operation node into the current valueStack, repeat the step until the current symbolStack is empty, and execute step d12; Step d5, get the node n at position i in the nodeList, and add 1 to i; if the token type of the node n is a string, execute step d6; otherwise, execute step d7; Step d6, if the token type of the previous node of the node n is also a string, press the node n and an AND operator into the current valueStack, and then repeat step d3; if the token type of the previous node of the node n is not a string, only press the node n into the current valueStack, and then repeat step d3; Step d7, if the current symbolStack is empty, press the node n into the current symbolStack, and then repeat step d3; otherwise, execute step d8; Step d8, if the node n is a left parenthesis, press the node n into the current symbolStack, and then repeat step d3; otherwise, execute step d9; Step d9, check the priority of the top node t of the current symbolStack, if the priority of the node n is less than or equal to the priority of the top node t, execute step d10; otherwise, execute step d11; wherein, the priority of each operator is predefined; Step d10, press the node n into the current valueStack, and then repeat step d3; otherwise, execute step d11; Step d10, the stack top node t is taken out, two nodes e and f are taken out from the current valueStack, the stack top node t is taken as an operator, the node e is taken as a left child node, and the node f is taken as a right child node, three nodes are constructed into a binary operation node, the binary operation node is pressed into the current valueStack, and then step d9 is repeated; Step d11, the node n is pressed into the current symbolStack, and then step d3 is repeated; Step d12, it is judged whether there is only one node left in the current valueStack, if yes, the remaining node is taken as a root node of a finally generated standard syntax tree, and if not, an exception is thrown to stop the flow.
6. The method of converting a patent search expression into a search engine query statement according to claim 1 or 5, wherein, The target search engine includes Elasticsearch and mysql.
7. The method of converting patent search expressions into search engine query statements of claim 6, wherein, When the target search engine is Elasticsearch, the standard syntax tree is converted into a query statement of the target search engine by using a syntax converter that is constructed in advance and matches the target search engine, and the method includes the following steps: Step e1, a currently processed root node r is obtained, and step e2 is executed; when the step is executed for the first time, the currently processed root node r is a root node of the standard syntax tree; Step e2, if the currently processed root node r is not a binary operation node, an exception is thrown to stop the flow; otherwise, step e3 is executed; Step e3, if an operator of the currently processed root node r is a logical operator, step e4 is executed; otherwise, step e7 is executed; Step e4, a root node r-left of a left subtree of the currently processed root node r is taken out, and a left clause left of the currently processed root node r is obtained by recursively executing step e2; Step e5, a root node r-right of a right subtree of the currently processed root node r is taken out, and a right clause right of the currently processed root node r is obtained by recursively executing step e2; Step e6, the left clause left and the right clause right are combined into an Elasticsearch bool query statement according to the logical operator of the currently processed root node r; and step e3 is returned; Step e7, a left subtree of the currently processed root node r is taken as a field name k, a right subtree is taken as a field value v, and k and v are converted into a query statement in Elasticsearch according to a conversion algorithm corresponding to an operator op of the currently processed root node r; and step e3 is returned.
8. The method of converting patent search expressions into search engine query statements of claim 6, wherein, When the target search engine is mysql, the standard syntax tree is converted into a query statement of the target search engine by using a syntax converter that is constructed in advance and matches the target search engine, and the method includes the following steps: Step f1, a currently processed root node r is obtained, and step f2 is executed; when the step is executed for the first time, the currently processed root node r is a root node of the standard syntax tree; Step f2, if the currently processed root node r is not a binary operation node, an exception is thrown to stop the flow; otherwise, step f3 is executed; Step f3, if the operator of the root node r currently processed is a logical operator, then step f4 is executed; otherwise, step f7 is executed; Step f4, the root node r-left of the left sub-tree of the root node r currently processed is taken out, and step f2 is executed recursively to obtain the left clause left of the root node r currently processed; Step f5, the root node r-right of the right sub-tree of the root node r currently processed is taken out, and step f2 is executed recursively to obtain the right clause right of the root node r currently processed; Step f6, according to the logical operator of the root node r currently processed, the left clause left and the right clause right are combined into an and, or or not query statement of mysql; and step f3 is returned; Step f7, the left sub-tree of the root node r currently processed is taken as the field name k, and the right sub-tree is taken as the field value v, according to the operator op of the root node r currently processed, k and v are converted into a query statement in mysql according to the conversion algorithm corresponding to the operator op; and step f3 is returned.
Citation Information
Patent Citations
Search engine type audit analysis method
CN106503102A
Memory system for storing and retrieving experience and knowledge with natural language
US5715468A