Retrieval method and device based on document space layout, electronic equipment and medium
By introducing polar coordinate encoding and Gaussian spatial layout position calibration in document retrieval, combining the spatial layout information of words and words, the problem of low document search accuracy in the prior art is solved, and a more efficient document search effect is achieved.
Patent Information
- Application Number
- CN202411677256.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-21
- Publication Date
- 2025-03-14
AI Technical Summary
The prior art only relies on semantic coding in document retrieval, resulting in low retrieval accuracy and inability to effectively utilize the spatial layout information of the document.
A search method based on document spatial layout is proposed. Through polar coordinate encoding and Gaussian spatial layout position calibration, combining the spatial layout information of words and words, the accuracy of document retrieval is improved.
It significantly improves the accuracy of document retrieval, and enhances the matching of search results by integrating the semantic and spatial layout information of the document.
Smart Images

Figure CN119621873A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, is applicable to the field of financial technology, and in particular to a retrieval method and device, electronic device and medium based on document spatial layout. Background Art
[0002] At present, document retrieval is usually achieved by preliminarily collecting documents related to the retrieval, and semantically encoding the words in each sentence in the document in order through traditional text encoders (such as Transformer) to obtain the contextual semantics of the words, and performing keyword retrieval based on the contextual semantics of the words. For example, in the financial technology scenario, if the information to be retrieved is: introduction to health insurance products, preliminary documents related to health insurance products are initially screened out from the documents, and the preliminary documents and the information to be retrieved are semantically encoded according to the order of words in the sentence through the text encoder to obtain document semantic information and retrieval semantic information. According to the retrieval semantic information and document semantic information, the keywords "health insurance" and "introduction" are retrieved in the preliminary documents to obtain information such as product features and prices of health insurance products. However, the retrieval of this method only encodes the semantic information of the document, which makes the accuracy of document retrieval low. Therefore, how to improve the accuracy of document retrieval has become an urgent problem to be solved. Summary of the invention
[0003] The main purpose of the embodiments of the present application is to propose a retrieval method and device, electronic device and medium based on document spatial layout, aiming to improve the accuracy of document retrieval.
[0004] To achieve the above-mentioned purpose, a first aspect of an embodiment of the present application proposes a retrieval method based on document spatial layout, the method comprising:
[0005] In response to a document retrieval request, obtaining retrieval instruction information and a target retrieval document;
[0006] Obtaining candidate document paragraph blocks and candidate document title blocks of the target retrieval document;
[0007] Segmenting the candidate document paragraph blocks to obtain segmentation candidate paragraphs; segmenting the candidate document title blocks to obtain segmentation candidate titles;
[0008] Performing polar coordinate coding on the candidate word segmentation paragraphs to obtain paragraph word position information; performing polar coordinate coding on the candidate word segmentation titles to obtain title word position information;
[0009] Performing Gaussian space layout position calibration on the paragraph word position information to obtain calibrated paragraph word position information; performing Gaussian space layout position calibration on the title word position information to obtain calibrated title word position information;
[0010] Perform title search on the candidate document title block according to the search indication information and the calibrated title word position information to obtain a target document title block;
[0011] The candidate document paragraph blocks are subjected to paragraph retrieval according to the target document title block to obtain target retrieval data matching the retrieval indication information.
[0012] In some embodiments, the performing Gaussian space layout position calibration on the paragraph word position information to obtain the calibrated paragraph word position information includes:
[0013] Adding the paragraph word position information to a preset Gaussian matrix according to a preset covariance matrix and a preset parameter matrix to obtain paragraph Gaussian position information;
[0014] The spatial layout position of the paragraph word position information is calibrated based on the paragraph Gaussian position information and preset spatial position adjustment parameters to obtain the calibrated paragraph word position information.
[0015] In some embodiments, performing polar coordinate encoding on the candidate paragraphs to obtain paragraph word position information includes:
[0016] Obtaining candidate paragraph word coordinates of the word segmentation candidate paragraph;
[0017] Calculate the paragraph word distance and paragraph word angle between the candidate paragraphs of the word segmentation according to the candidate paragraph word coordinates;
[0018] The paragraph word position information is determined according to the paragraph word distance and the paragraph word angle.
[0019] In some embodiments, the step of obtaining the candidate document paragraph blocks and candidate document title blocks of the target retrieval document includes:
[0020] Performing text character recognition on the target search document to obtain target text characters;
[0021] Performing position coordinate recognition on the target text characters to obtain character position coordinates;
[0022] Perform paragraph text detection on the target search document according to the character position coordinates to obtain multiple paragraph text areas;
[0023] Merging the multiple paragraph text areas according to a preset merging rule to obtain the candidate document paragraph block;
[0024] The target retrieval document is subjected to title text detection according to the character position coordinates to obtain a plurality of title text regions.
[0025] In some embodiments, performing title search on the candidate document title block according to the search indication information and the calibration title word position information to obtain the target document title block includes:
[0026] Position-encoding the retrieval indication information to obtain encoded indication position information;
[0027] Calculating the position similarity between the encoding indication position information and the calibration title word position information;
[0028] The candidate document title block with the greatest similarity is selected from the position similarities as the target document title block.
[0029] In some embodiments, performing paragraph retrieval on the candidate document paragraph block according to the target document title block to obtain target retrieval data matching the retrieval indication information includes:
[0030] Obtain a target title paragraph hash index of the target document title block;
[0031] The candidate document paragraph block is subjected to paragraph retrieval according to the target title paragraph hash index to obtain target retrieval data matching the retrieval indication information.
[0032] In some embodiments, before obtaining the target title paragraph hash index of the target document title block, the method further includes:
[0033] Calculating the title paragraph similarity between the calibrated paragraph word position information and the calibrated title word position information;
[0034] Obtaining the title block identifier of the candidate document title block, and obtaining the paragraph block identifier of the candidate document paragraph block;
[0035] According to the title block identifier, the paragraph block identifier and the title paragraph similarity, the candidate document title block and the candidate document paragraph block are content-associated to obtain title paragraph associated content;
[0036] A title paragraph hash index between the candidate document title block and the candidate document paragraph blocks is constructed according to a preset hash function and the title paragraph associated content.
[0037] To achieve the above-mentioned purpose, a second aspect of an embodiment of the present application proposes a retrieval device based on document spatial layout, the device comprising:
[0038] A retrieval instruction and retrieval document acquisition module, used to obtain retrieval instruction information and target retrieval documents in response to a document retrieval request;
[0039] A paragraph block and title block acquisition module, used to acquire candidate document paragraph blocks and candidate document title blocks of the target retrieval document;
[0040] A word segmentation module is used to segment the candidate document paragraph blocks to obtain segmentation candidate paragraphs; segment the candidate document title blocks to obtain segmentation candidate titles;
[0041] A polar coordinate encoding module is used to perform polar coordinate encoding on the candidate segmentation paragraphs to obtain paragraph word position information; and to perform polar coordinate encoding on the candidate segmentation titles to obtain title word position information;
[0042] A spatial layout position calibration module is used to perform Gaussian spatial layout position calibration on the paragraph word position information to obtain calibrated paragraph word position information; perform Gaussian spatial layout position calibration on the title word position information to obtain calibrated title word position information;
[0043] A title search module, used to perform title search on the candidate document title block according to the search indication information and the calibration title word position information, to obtain a target document title block;
[0044] The paragraph retrieval module is used to perform paragraph retrieval on the candidate document paragraph block according to the target document title block to obtain target retrieval data matching the retrieval indication information.
[0045] To achieve the above objectives, a third aspect of an embodiment of the present application proposes an electronic device, which includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the method described in the first aspect is implemented.
[0046] To achieve the above-mentioned purpose, the fourth aspect of an embodiment of the present application proposes a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described in the first aspect is implemented.
[0047] The document space layout-based retrieval method and device, electronic device and medium proposed in the present application obtain retrieval indication information and target retrieval document in response to a document retrieval request; obtain candidate document paragraph blocks and candidate document title blocks of the target retrieval document; perform word segmentation on the candidate document paragraph blocks to obtain word segmentation candidate paragraphs; perform word segmentation on the candidate document title blocks to obtain word segmentation candidate titles; perform polar coordinate encoding on the word segmentation candidate paragraphs to obtain paragraph word position information; perform polar coordinate encoding on the word segmentation candidate titles to obtain title word position information; perform Gaussian space layout position calibration on the paragraph word position information to obtain calibrated paragraph word position information; perform Gaussian space layout position calibration on the title word position information to obtain calibrated title word position information; perform title retrieval on the candidate document title block according to the retrieval indication information and the calibrated title word position information to obtain the target document title block; perform paragraph retrieval on the candidate document paragraph block according to the target document title block to obtain target retrieval data matching the retrieval indication information. The present application firstly performs polar coordinate encoding on the candidate paragraphs and candidate titles for word segmentation, so as to preliminarily determine the initial spatial positions of the paragraph blocks and the title blocks in the document; secondly, by calibrating the Gaussian spatial layout position of the paragraph word position information and the title word position information, it is possible to fuse the spatial layout information of the words while extracting the semantic features of the document to determine the spatial layout of the document, thereby improving the retrieval accuracy based on the spatial layout of the document; finally, based on the calibrated title word position information and the calibrated paragraph word position information, the retrieval indication information is matched with the title block and the paragraph block, thereby significantly improving the accuracy of document retrieval. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 is a flowchart of a retrieval method based on document spatial layout provided in an embodiment of the present application;
[0049] Figure 2 yes Figure 1 Flow chart of step S102 in FIG.
[0050] Figure 3 yes Figure 1 Flow chart of step S104 in FIG.
[0051] Figure 4 yes Figure 1 Flow chart of step S105 in FIG.
[0052] Figure 5 yes Figure 1 Flow chart of step S106 in FIG.
[0053] Figure 6 yes Figure 1 Flow chart of step S107 in FIG.
[0054] Figure 7It is a structural schematic diagram of a retrieval device based on document space layout provided in an embodiment of the present application;
[0055] Figure 8 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0056] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0057] It should be noted that, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first", "second", etc. in the specification, claims and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0058] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0059] First, some nouns involved in this application are analyzed:
[0060] Artificial intelligence (AI) is a new technical science that studies and develops theories, methods, technologies and application systems for simulating, extending and expanding human intelligence. AI is a branch of computer science that attempts to understand the essence of intelligence and produce a new type of intelligent machine that can respond in a similar way to human intelligence. Research in this field includes robotics, speech recognition, image recognition, natural language processing and expert systems. AI can simulate the information process of human consciousness and thinking. AI is also a theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0061] Based on this, the embodiments of the present application provide a retrieval method and device, electronic device and medium based on document spatial layout, aiming to improve the accuracy of document retrieval.
[0062] The retrieval method and device based on document space layout, electronic device and medium provided in the embodiments of the present application are specifically illustrated through the following embodiments. First, the retrieval method based on document space layout in the embodiments of the present application is described.
[0063] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0064] The basic technologies of artificial intelligence generally include sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, processing / interaction systems, mechatronics, etc. Artificial intelligence software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0065] The retrieval method based on document space layout provided in the embodiment of the present application relates to the field of artificial intelligence technology. The retrieval method based on document space layout provided in the embodiment of the present application can be applied to the terminal, can also be applied to the server side, and can also be software running in the terminal or the server side. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, etc.; the server side can be configured as an independent physical server, or it can be configured as a server cluster or a distributed system composed of multiple physical servers, and can also be configured as a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application that implements a retrieval method based on document space layout, etc., but is not limited to the above forms.
[0066] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0067] Figure 1 is an optional flowchart of a retrieval method based on document spatial layout provided in an embodiment of the present application. Figure 1 The method may include but is not limited to steps S101 to S107.
[0068] Step S101, in response to a document retrieval request, obtaining retrieval instruction information and a target retrieval document.
[0069] Step S102, obtaining candidate document paragraph blocks and candidate document title blocks of the target retrieval document.
[0070] Step S103, segmenting the candidate document paragraph blocks to obtain segmentation candidate paragraphs; segmenting the candidate document title blocks to obtain segmentation candidate titles.
[0071] Step S104, performing polar coordinate coding on the candidate paragraphs of the word segmentation to obtain the paragraph word position information; performing polar coordinate coding on the candidate title of the word segmentation to obtain the title word position information.
[0072] Step S105, performing Gaussian space layout position calibration on the paragraph word position information to obtain calibrated paragraph word position information; performing Gaussian space layout position calibration on the title word position information to obtain calibrated title word position information.
[0073] Step S106, performing title search on the candidate document title blocks according to the search indication information and the calibrated title word position information to obtain the target document title block.
[0074] Step S107, performing paragraph retrieval on the candidate document paragraph blocks according to the target document title block to obtain target retrieval data matching the retrieval indication information.
[0075] Steps S101 to S107 shown in the embodiment of the present application are as follows: by responding to a document retrieval request, obtaining retrieval indication information and a target retrieval document; obtaining a candidate document paragraph block and a candidate document title block of the target retrieval document; performing word segmentation on the candidate document paragraph block to obtain a word segmentation candidate paragraph; performing word segmentation on the candidate document title block to obtain a word segmentation candidate title; performing polar coordinate encoding on the word segmentation candidate paragraph to obtain paragraph word position information; performing polar coordinate encoding on the word segmentation candidate title to obtain title word position information; performing Gaussian space layout position calibration on the paragraph word position information to obtain a calibrated paragraph word position information; performing Gaussian space layout position calibration on the title word position information to obtain a calibrated title word position information; performing a title search on the candidate document title block according to the retrieval indication information and the calibrated title word position information to obtain a target document title block; performing a paragraph search on the candidate document paragraph block according to the target document title block to obtain target retrieval data matching the retrieval indication information. The present application firstly performs polar coordinate encoding on the candidate paragraphs and candidate titles for word segmentation, so as to preliminarily determine the initial spatial positions of the paragraph blocks and the title blocks in the document; secondly, by calibrating the Gaussian spatial layout position of the paragraph word position information and the title word position information, it is possible to fuse the spatial layout information of the words while extracting the semantic features of the document to determine the spatial layout of the document, thereby improving the retrieval accuracy based on the spatial layout of the document; finally, based on the calibrated title word position information and the calibrated paragraph word position information, the retrieval indication information is matched with the title block and the paragraph block, thereby significantly improving the accuracy of document retrieval.
[0076] In step S101 of some embodiments, specifically, the search indication information refers to the search conditions or search keywords of the user when performing document search.
[0077] Specifically, the target retrieval document refers to a document associated with the retrieval instruction information, and the document format of the target retrieval document can be a promotional poster, a PPT document, a PDF document, or the like.
[0078] For example, in the financial field, the search indication information may be: I want to buy a car insurance, then the target search document may be a car insurance clause document, a car insurance claim document, and a PDF version of a car insurance policy contract, etc.
[0079] See also Figure 2 In some embodiments, step S102 includes but is not limited to steps S201 to S206:
[0080] Step S201, performing text character recognition on a target search document to obtain target text characters.
[0081] Step S202, identifying the position coordinates of the target text characters to obtain the character position coordinates.
[0082] Step S203: perform paragraph text detection on the target search document according to the character position coordinates to obtain multiple paragraph text regions.
[0083] Step S204: Merge multiple paragraph text regions according to a preset merging rule to obtain a candidate document paragraph block.
[0084] Step S205, performing title text detection on the target search document according to the character position coordinates to obtain a plurality of title text regions.
[0085] Step S206, performing title feature analysis on multiple title text areas to obtain a document title block.
[0086] In step S201 of some embodiments, specifically, the target text characters refer to text characters in the target search document.
[0087] Specifically, the target retrieval document can be scanned through an OCR (Optical Character Recognition) model to obtain a target retrieval document image, text area recognition can be performed on the target retrieval document image to determine the text area, the text in the text area can be segmented into single characters through a projection analysis method, the segmented characters can be recognized, and the characters in the target retrieval document image can be converted into target text characters in text format.
[0088] In step S202 of some embodiments, specifically, the character position coordinates refer to the coordinate information of each character in the document, and the coordinate information is usually the coordinates of the upper left corner and the lower right corner of the character. The coordinate information is usually expressed in the form of (x1, y1, x2, y2), where (x1, y1) is the coordinate of the upper left corner of the character, and (x2, y2) is the coordinate of the lower right corner of the character.
[0089] In step S203 of some embodiments, specifically, the paragraph text area refers to the area in the document where the text paragraph in the target retrieval document is located.
[0090] Specifically, since the paragraph text area is composed of multiple lines of continuous character areas, a horizontal and vertical distance threshold can be set according to the layout and format of the target retrieval document; the character position coordinates of two adjacent words or two characters are obtained, and if the distance between the character position coordinates of adjacent words or characters is less than this threshold, it is determined that the adjacent words or characters are continuous, and so on, and the continuous word or character areas are regarded as multiple paragraph text areas.
[0091] Furthermore, since the vertical spacing between the title text line and the paragraph text line is relatively large, the paragraph text area can be accurately located by setting thresholds of horizontal and vertical distances to determine whether the characters are continuous.
[0092] In step S204 of some embodiments, specifically, the merging rules may be determined based on actual business, and the merging rules include but are not limited to character horizontal merging rules, character vertical merging rules, character spacing processing rules, and the like.
[0093] Specifically, the horizontal character merging rule can be used to merge words or characters with continuous horizontal coordinates into text lines, and the vertical character merging rule can be used to merge all adjacent text lines whose vertical distance is less than the vertical distance threshold into an initial text paragraph. Finally, the character gap processing rule is used to identify and eliminate non-text gaps caused by formatting problems such as line breaks and page breaks to obtain candidate document paragraph blocks.
[0094] Specifically, the candidate document paragraph blocks refer to continuous text segments in the target retrieval document, and the document paragraph blocks are semantically and logically associated, and the association is usually implemented around a text topic.
[0095] For example, in the financial field, candidate document paragraph blocks may be paragraphs describing detailed terms such as insurance product coverage, liability exemptions, and claims procedures, paragraphs describing information such as the insurance policyholder's name, contact information, insurance history, etc., paragraphs describing key information such as the insurance policy number, effective date, insurance period, premium, etc.
[0096] In step S205 of some embodiments, specifically, the title text area refers to the area where the text title in the target retrieval document is located in the document.
[0097] Specifically, since the paragraph text area is composed of independent character areas, and the title is usually located at the top of the micro-single page or the beginning of the paragraph, and is clearly separated from other texts, the title vertical distance threshold between adjacent line characters can be set according to the layout and format of the target retrieval document, and the title vertical distance between adjacent line characters is determined according to the vertical coordinate of the character position coordinate. If the title vertical distance is greater than the title vertical distance threshold, the adjacent line characters are determined to be independent, and so on, all independent text line areas are regarded as multiple title text areas.
[0098] In step S206 of some embodiments, specifically, the document title block is a title used to identify different parts or chapters in the target retrieval document, which is usually located at the beginning of the paragraph block and is used to summarize the main content of the paragraph block.
[0099] For example, in the financial field, the document title block may be an insurance product introduction, customer service terms, and insurance claims guidelines.
[0100] Specifically, the title feature analysis may be to analyze the font size, font style, font alignment, and spacing of the characters in the title text area.
[0101] Furthermore, firstly, since some titles are centered or left-aligned, while the main text is usually left-aligned or justified, the initial title can be preliminarily identified through the alignment of the word segmentation characters, and since the document title usually uses a larger font than the main text, the title can be further locked through the font size analysis of the characters, and then since the title may be highlighted in bold or italics, the text block with bold or italic style features is identified as the title block, and finally, since the distance between the title and the surrounding context is usually large, the document title block can be finally determined through the blank area before and after the characters in the title text area.
[0102] In step S103 of some embodiments, specifically, segmenting candidate paragraphs refers to segmenting the paragraph content of the candidate document paragraph block into a plurality of semantically meaningful words.
[0103] Specifically, the candidate document paragraph blocks can be tokenized by a text encoder (such as an attention mechanism network) to obtain the candidate word segmentation paragraphs. The text encoder includes a polar coordinate encoding layer and a Gaussian calibration layer. The polar coordinate encoding layer is used to perform polar coordinate encoding on the candidate word segmentation titles and candidate word segmentation paragraphs, and the Gaussian calibration layer is used to perform Gaussian spatial layout position calibration on the paragraph word position information and the title word position information.
[0104] Specifically, word segmentation of candidate titles refers to segmenting the title content of the candidate document title block into multiple semantically meaningful words.
[0105] Specifically, the candidate document title blocks may be subjected to Tokenization processing to obtain the word segmentation candidate titles.
[0106] See also Figure 3 In some embodiments, step S104 includes but is not limited to steps S301 to S303:
[0107] Step S301, obtaining the candidate paragraph word coordinates of the word segmentation candidate paragraph.
[0108] Step S302, calculating the paragraph word distance and paragraph word angle between the candidate paragraphs of the word segmentation according to the candidate paragraph word coordinates.
[0109] Step S303, determining paragraph word position information according to the paragraph word distance and the paragraph word angle.
[0110] In step S301 of some embodiments, specifically, the candidate paragraph word coordinates refer to the coordinates of each paragraph word in the search document, and the candidate paragraph word coordinates also include the upper left corner coordinates and the lower right corner coordinates of each paragraph word.
[0111] In step S302 of some embodiments, specifically, the paragraph word distance refers to the polar coordinate distance between two candidate paragraph words.
[0112] Specifically, the paragraph word distance can be calculated by the following formula:
[0113]
[0114] Among them, ρ ij represents the paragraph word distance between the i-th candidate paragraph word and the j-th candidate paragraph word, x j represents the horizontal coordinate of the jth candidate paragraph word, x i Represents the horizontal coordinate of the i-th candidate paragraph word, y j Represents the ordinate of the jth candidate paragraph word, y i Represents the ordinate of the i-th candidate paragraph word.
[0115] Specifically, the paragraph word angle refers to the polar coordinate angle between two candidate paragraph words.
[0116] Specifically, the paragraph word angle can be calculated by the following formula:
[0117] θ ij =tan -1 ((y j -y i ) / (x j -x i ))
[0118] Among them, θ ik represents the paragraph word angle between the i-th candidate paragraph word and the j-th candidate paragraph word, x j represents the horizontal coordinate of the jth candidate paragraph word, x i Represents the horizontal coordinate of the i-th candidate paragraph word, y j Represents the ordinate of the jth candidate paragraph word, y i Represents the ordinate of the i-th candidate paragraph word.
[0119] In step S303 of some embodiments, specifically, the paragraph word position information refers to paragraph word coordinate matrix information composed of paragraph word distance and paragraph word angle.
[0120] Specifically, you can use u ik =(ρ ij ,θ ij ) represents the paragraph word polar coordinate vector information, where u ij represents the paragraph word position information between the i-th candidate paragraph word and the j-th candidate paragraph word, ρ ij represents the paragraph word distance between the i-th candidate paragraph word and the j-th candidate paragraph word, θ ijRepresents the paragraph word angle between the i-th candidate paragraph word and the j-th candidate paragraph word.
[0121] Specifically, the title word position information refers to the title word coordinate matrix information composed of the title word distance and the title word angle.
[0122] Specifically, the method of performing polar coordinate coding on the candidate segmentation titles to obtain the position information of the title words is the same as the method of performing polar coordinate coding on the candidate segmentation paragraphs to obtain the position information of the paragraph words, which will not be repeated here.
[0123] In this embodiment, the paragraph word position information is determined according to the paragraph word distance and the paragraph word angle, so that the specific position of each candidate paragraph word in the document can be obtained, and the position information is represented based on the angle and distance, and the initial spatial position of the paragraph block in the document is preliminarily determined, thereby effectively enhancing the semantic association between words in the paragraph, and facilitating the subsequent improvement of the accuracy of document retrieval.
[0124] See also Figure 4 In some embodiments, step S105 includes but is not limited to steps S401 to S402:
[0125] Step S401 : adding paragraph word position information to a preset Gaussian matrix according to a preset covariance matrix and a preset parameter matrix to obtain paragraph Gaussian position information.
[0126] Step S402 , based on the paragraph Gaussian position information and preset spatial position adjustment parameters, the paragraph word position information is spatially calibrated to obtain calibrated paragraph word position information.
[0127] In step S401 of some embodiments, specifically, the covariance matrix is used to describe the spatial distribution relationship between paragraph words.
[0128] Specifically, the parameter matrix is a component of the covariance matrix, which is used to describe the mean or central tendency of the word positions in the paragraph.
[0129] Specifically, the Gaussian matrix is used to simulate the probability distribution of paragraph word position information, and the Gaussian matrix combines with the covariance matrix and the parameter matrix to jointly describe the Gaussian distribution of paragraph word positions.
[0130] Specifically, the paragraph Gaussian position information is obtained by converting the position information of the paragraph words into the position form of Gaussian distribution.
[0131] Specifically, the paragraph Gaussian position information can be determined by the following formula:
[0132]
[0133] Among them, g(u) represents the paragraph Gaussian position information corresponding to the paragraph word position information u, u represents the paragraph word position information, μ represents the parameter matrix, T represents the transposition processing, which is used to change the row and column direction of the matrix. represents the covariance matrix.
[0134] Specifically, It can be a 2x2 covariance matrix, and μ can be a 2x1 parameter matrix. The initialization values in these two matrices are random. A 2x1 vector is still obtained through u-μ, which is transposed to a 1x2 vector, and the transposed vector is multiplied by the covariance matrix to obtain a 1x2 output vector. The output vector is multiplied by the 2x1 vector of u-μ on the left through the Gaussian kernel function g(u) to obtain a Gaussian bias value, that is, the paragraph word position information can be implied into the Gaussian bias through the Gaussian kernel function g(u) to obtain the Gaussian bias value. Since u represents the paragraph word position information from the i-th candidate paragraph word to the j-th candidate paragraph word, the Gaussian bias value can reflect the relative position and distribution of the paragraph word in the document, and it is symmetrical, that is, the Gaussian bias value between each paragraph word pair is the same.
[0135] In step S402 of some embodiments, specifically, the spatial position adjustment parameter is used to adjust and calibrate the paragraph word position information to better reflect the actual spatial layout of the document.
[0136] Specifically, calibrating the paragraph word position information refers to further adjusting the paragraph word position of the paragraph Gaussian position information according to the spatial position adjustment parameter after obtaining the paragraph Gaussian position information.
[0137] Specifically, the spatial position adjustment parameter can be determined by the following formula:
[0138]
[0139] Among them, α ij represents the spatial position adjustment parameter between the i-th candidate paragraph word and the j-th candidate paragraph word, exp represents the exponential function, N represents the total number of candidate paragraph words, and q i represents the encoded feature vector of the i-th candidate paragraph word, represents the transposed encoding feature vector of the jth candidate paragraph word, d qk represents the vector dimension of the encoding feature vector of the i-th candidate paragraph word and the j-th candidate paragraph word, α represents a hyperparameter used to control g(u ij ) The influence degree of Gaussian bias of the Gaussian position information of the paragraph, g(u ik ) represents the paragraph Gaussian position information between the i-th candidate paragraph word and the j-th candidate paragraph word, u ikRepresents the paragraph word position information between the i-th candidate paragraph word and the j-th candidate paragraph word.
[0140] Specifically, the spatial position adjustment parameter can also represent the attention weight between each pair of candidate paragraph words. After performing the dot product of the q and k encoded feature vectors, the result is divided by the dimension d of the encoded feature vector, and then the paragraph Gaussian position information is subtracted. The attention weight combining the semantic similarity and spatial distribution between each two candidate paragraph words can be calculated. After calculating the i-th candidate paragraph word and all the attention weights from the j=1 candidate paragraph word to the N-th candidate paragraph word, the attention weight of the j-th candidate paragraph word is multiplied with the encoded feature vector of the corresponding j-th candidate paragraph word, and then the vector dimensions of the 1st candidate paragraph word to the N-th candidate paragraph word are added to obtain the feature vector after the attention weight between the i-th candidate paragraph word and all the j-th candidate paragraph words.
[0141] Specifically, the spatial distribution position of the candidate paragraph words is calibrated by adding the spatial information between each pair of candidate paragraph words in the document layout (i.e., the paragraph Gaussian position information) to the attention weight. This means that the attention weight between two candidate paragraph words that are closer in the document layout space will be greater. Therefore, the paragraph Gaussian position information between each pair of candidate paragraph words can be calibrated through the spatial position adjustment parameters, which can compensate for the errors in the paragraph word position information.
[0142] Specifically, calibrating the title word position information refers to further adjusting the title word position of the title Gaussian position information according to the spatial position adjustment parameter after obtaining the title Gaussian position information.
[0143] Furthermore, the method of performing Gaussian space layout position calibration on the title word position information to obtain the calibrated title word position information is the same as the method of performing Gaussian space layout position calibration on the paragraph word position information to obtain the calibrated paragraph word position information, which will not be repeated here.
[0144] In this embodiment, by calibrating the spatial layout position of paragraph word position information based on paragraph Gaussian position information and preset spatial position adjustment parameters, it is possible to fuse the spatial layout information of words while extracting document semantic features, and adjust and optimize the preliminary spatial position information of paragraph words, accurately describing the spatial layout of the document, thereby improving the accuracy of document retrieval.
[0145] See also Figure 5 In some embodiments, step S106 includes but is not limited to steps S501 to S503:
[0146] Step S501, position encoding is performed on the search indication information to obtain encoded indication position information.
[0147] Step S502: calculating the position similarity between the encoded indication position information and the calibration title word position information.
[0148] Step S503: Filter out the candidate document title block with the greatest similarity from the position similarities as the target document title block.
[0149] In step S501 of some embodiments, specifically, the encoded indication position information is used to describe the probability of distribution of the retrieval indication information in the Gaussian space.
[0150] Specifically, position encoding of the retrieval indication information also includes performing polar coordinate encoding on the retrieval indication information to obtain the indication position information; and performing Gaussian space layout position calibration on the indication position information to obtain the final encoded indication position information.
[0151] Specifically, position encoding of the retrieval indication information also includes polar coordinate encoding of the retrieval indication information. The method of obtaining the indication position information is consistent with the method of performing polar coordinate encoding on the candidate paragraphs for segmentation to obtain the paragraph word position information, which will not be repeated here.
[0152] Specifically, the method of performing Gaussian space layout position calibration on the indication position information to obtain the final encoded indication position information is consistent with the method of performing Gaussian space layout position calibration on the paragraph word position information to obtain the calibrated paragraph word position information, and will not be repeated here.
[0153] In this embodiment, by performing position encoding on the retrieval indication information, Menggepi converts the retrieval indication information into a format that can be compared with the position information in the document, which helps to integrate the semantic and spatial information of the document and effectively improves the efficiency of document retrieval.
[0154] In step S502 of some embodiments, specifically, the position similarity can be calculated using the following formula:
[0155]
[0156] Among them, cosC represents the position similarity, A represents the encoding indication position information, and B represents the calibration title word position information.
[0157] For example, if the retrieval instruction is "I want to buy a car insurance", the candidate document title blocks are "Car Insurance Purchase Guide", "Car Insurance Coverage and Cost", "Car Insurance Terms and Conditions", "Car Insurance Quotes and Comparisons", etc. Among them, the position similarity between "I want to buy a car insurance" and "Car Insurance Purchase Guide" is 0.92, the position similarity between "I want to buy a car insurance" and "Car Insurance Coverage and Cost" is 0.84, the position similarity between "I want to buy a car insurance" and "Car Insurance Terms and Conditions" is 0.81, and the position similarity between "I want to buy a car insurance" and "Car Insurance Quotes and Comparisons" is 0.82.
[0158] In step S503 of some embodiments, specifically, the target document title block refers to the document title with the highest matching degree with the search indication information.
[0159] For example, if the position similarity between the retrieval indication information "I want to buy a vehicle insurance" and the candidate document title block "Vehicle Insurance Purchase Guide" is 0.92, the position similarity between "I want to buy a vehicle insurance" and "Auto Insurance Coverage and Cost" is 0.84, the position similarity between "I want to buy a vehicle insurance" and "Vehicle Insurance Terms and Conditions" is 0.81, and the position similarity between "I want to buy a vehicle insurance" and "Vehicle Insurance Quotes and Comparisons" is 0.82, then the Vehicle Insurance Purchase Guide with the highest position similarity is determined as the target document title block.
[0160] In this embodiment, by selecting the candidate document title block with the greatest similarity from the position similarity as the target document title block, the document title most relevant to the retrieval indication information can be identified, thereby providing a more accurate retrieval result.
[0161] See also Figure 6 In some embodiments, step S107 includes but is not limited to steps S601 to S602:
[0162] Step S601, obtaining a target title paragraph hash index of a target document title block.
[0163] Step S602: perform paragraph search on the candidate document paragraph block according to the target title paragraph hash index to obtain target search data matching the search indication information.
[0164] In step S601 of some embodiments, specifically, the target title paragraph hash index refers to using the hash value as the index key of the paragraph and title.
[0165] Specifically, before obtaining the target title paragraph hash index of the target document title block, the retrieval device based on the document spatial layout also includes: calculating the title paragraph similarity between the calibration paragraph word position information and the calibration title word position information; constructing the title paragraph association between the candidate document title block and the candidate document paragraph block based on the title paragraph similarity; obtaining the title block identifier of the candidate document title block, and obtaining the paragraph block identifier of the candidate document paragraph block; content-associating the candidate document title block and the candidate document paragraph block according to the title block identifier, the paragraph block identifier and the title paragraph association to obtain the title paragraph associated content; constructing the title paragraph hash index between the candidate document title block and the candidate document paragraph block according to a preset hash function and the title paragraph associated content.
[0166] Specifically, the title paragraph similarity is used to find the document paragraph that matches the document title. The title paragraph similarity can be calculated by methods such as Euclidean distance, cosine similarity or Manhattan distance.
[0167] Specifically, the title block identifier refers to a unique identifier corresponding to the title block, and the paragraph block identifier refers to a unique identifier corresponding to the paragraph block. For example, the title block identifier can be represented by S1, and the paragraph block identifier can be represented by P1.
[0168] Specifically, the title paragraph similarity can determine the document paragraphs related to each document title, and for the document paragraphs related to the document title, the document paragraph most related to the document title block can be further determined by the position and context of the segmented document paragraph in the document. For example, if the text paragraph follows the document title, then the document paragraph is likely to belong to the document title.
[0169] For example, if the candidate document title block S1 is investment risk assessment, the candidate document paragraph block P1 matching S1 has the highest similarity to the title paragraph of the impact of market fluctuations on investment portfolios, and P1 follows S1 immediately, then the two blocks S1 and P1 are associated to form a new data structure, {S1:[P1]}, indicating that the paragraph P1 is included under the title S1, that is, the title paragraphs of S1 and P1 are associated.
[0170] Specifically, the contents of the candidate document title block and the candidate document paragraph block are converted into hash values of fixed length through a hash function (such as MD5, SHA-256, etc.), and a hash table is constructed through the hash values. The key of the hash table is the hash value, and the value of the hash table can be the candidate document title block that matches the hash value. The position pointer or metadata of the candidate document paragraph block can be obtained, thereby obtaining a title paragraph hash index, which enables rapid positioning of the relevant part in the document directly through the hash value.
[0171] Further, the target title paragraph hash index corresponding to the target document title block is searched in the title paragraph hash index.
[0172] In step S602 of some embodiments, specifically, based on the target paragraph hash value that matches the target title hash value, the corresponding target document paragraph block is found from the target title paragraph hash index, and the content of the target document paragraph block is used as the target retrieval data that matches the retrieval indication information.
[0173] For example, in a financial scenario, if the retrieval instruction information is "I want to buy a vehicle insurance policy", the target document title "Vehicle Insurance Purchase Guide" will be retrieved first, and based on the target title paragraph hash index, the target document paragraph content will be further retrieved as an introduction to basic information about different types of vehicle insurance (such as liability insurance, collision insurance, comprehensive insurance, etc., as well as the scope of liability insurance, collision insurance, and comprehensive insurance); steps to purchase vehicle insurance (including selecting an insurance company, comparing quotes, filling out an application form, submitting required documents, and completing the purchase); providing relevant information on vehicle insurance costs (such as vehicle model, driver age, and driving record that may affect insurance costs); and a detailed description of key terms and conditions in the insurance contract (including insurance liability, deductibles, compensation limits, and exclusions).
[0174] In this embodiment, by performing paragraph retrieval on candidate document paragraph blocks according to the target title paragraph hash index, the paragraph content related to the target document title block can be quickly located, thereby improving the document retrieval efficiency. In addition, the hash index can also accurately index the paragraph content related to the target document title block through the corresponding hash values of each title block and paragraph block, thereby significantly improving the accuracy of document retrieval.
[0175] The embodiment of the present application obtains retrieval indication information and a target retrieval document in response to a document retrieval request; obtains a candidate document paragraph block and a candidate document title block of the target retrieval document; performs word segmentation on the candidate document paragraph block to obtain a word segmentation candidate paragraph; performs word segmentation on the candidate document title block to obtain a word segmentation candidate title; performs polar coordinate encoding on the word segmentation candidate paragraph to obtain paragraph word position information; performs polar coordinate encoding on the word segmentation candidate title to obtain title word position information; performs Gaussian space layout position calibration on the paragraph word position information to obtain calibrated paragraph word position information; performs Gaussian space layout position calibration on the title word position information to obtain calibrated title word position information; performs title retrieval on the candidate document title block according to the retrieval indication information and the calibrated title word position information to obtain a target document title block; performs paragraph retrieval on the candidate document paragraph block according to the target document title block to obtain target retrieval data matching the retrieval indication information. The present application firstly performs polar coordinate encoding on the candidate paragraphs and candidate titles for word segmentation, so as to preliminarily determine the initial spatial positions of the paragraph blocks and the title blocks in the document; secondly, by calibrating the Gaussian spatial layout position of the paragraph word position information and the title word position information, it is possible to fuse the spatial layout information of the words while extracting the semantic features of the document to determine the spatial layout of the document, thereby improving the retrieval accuracy based on the spatial layout of the document; finally, based on the calibrated title word position information and the calibrated paragraph word position information, the retrieval indication information is matched with the title block and the paragraph block, thereby significantly improving the accuracy of document retrieval.
[0176] See also Figure 7 The embodiment of the present application further provides a retrieval device based on document space layout, which can implement the above-mentioned retrieval method based on document space layout, and the device includes:
[0177] A retrieval instruction and retrieval document acquisition module, used to obtain retrieval instruction information and target retrieval documents in response to a document retrieval request;
[0178] A paragraph block and title block acquisition module, used to acquire candidate document paragraph blocks and candidate document title blocks of a target retrieval document;
[0179] The word segmentation module is used to segment candidate document paragraph blocks to obtain segmentation candidate paragraphs; segment candidate document title blocks to obtain segmentation candidate titles;
[0180] The polar coordinate encoding module is used to perform polar coordinate encoding on the candidate paragraphs of the word segmentation to obtain the paragraph word position information; and to perform polar coordinate encoding on the candidate title of the word segmentation to obtain the title word position information;
[0181] A spatial layout position calibration module is used to perform Gaussian spatial layout position calibration on paragraph word position information to obtain calibrated paragraph word position information; perform Gaussian spatial layout position calibration on title word position information to obtain calibrated title word position information;
[0182] A title retrieval module, used to perform title retrieval on the candidate document title block according to the retrieval indication information and the calibration title word position information, and obtain the target document title block;
[0183] The paragraph retrieval module is used to perform paragraph retrieval on the candidate document paragraph blocks according to the target document title block to obtain target retrieval data matching the retrieval indication information.
[0184] The specific implementation of the retrieval device based on document spatial layout is basically the same as the specific implementation of the retrieval method based on document spatial layout mentioned above, and will not be repeated here.
[0185] The embodiment of the present application also provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the above-mentioned retrieval method based on document spatial layout when executing the computer program. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.
[0186] See also Figure 8 , Figure 8 The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes:
[0187] The processor 801 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;
[0188] The memory 802 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 802 can store processing systems and other applications. When the technical solution provided in the embodiments of this specification is implemented by software or firmware, the relevant program code is stored in the memory 802, and the processor 801 calls and executes the retrieval method based on document space layout in the embodiments of this application;
[0189] Input / output interface 803, used to implement information input and output;
[0190] The communication interface 804 is used to realize the communication interaction between the device and other devices. The communication can be realized through a wired manner (such as USB, network cable, etc.) or a wireless manner (such as mobile network, WIFI, Bluetooth, etc.);
[0191] A bus 805 that transmits information between the various components of the device (e.g., the processor 801, the memory 802, the input / output interface 803, and the communication interface 804);
[0192] The processor 801 , the memory 802 , the input / output interface 803 and the communication interface 804 are connected to each other in communication within the device via a bus 805 .
[0193] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned retrieval method based on document spatial layout is implemented.
[0194] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0195] The document spatial layout-based retrieval method, document spatial layout-based retrieval device, electronic device and storage medium provided by the embodiments of the present application obtain retrieval indication information and a target retrieval document in response to a document retrieval request; obtain candidate document paragraph blocks and candidate document title blocks of the target retrieval document; perform word segmentation on the candidate document paragraph blocks to obtain word segmentation candidate paragraphs; perform word segmentation on the candidate document title blocks to obtain word segmentation candidate titles; perform polar coordinate encoding on the word segmentation candidate paragraphs to obtain paragraph word position information; perform polar coordinate encoding on the word segmentation candidate titles to obtain title word position information; perform Gaussian space layout position calibration on the paragraph word position information to obtain calibrated paragraph word position information; perform Gaussian space layout position calibration on the title word position information to obtain calibrated title word position information; perform title retrieval on the candidate document title block according to the retrieval indication information and the calibrated title word position information to obtain the target document title block; perform paragraph retrieval on the candidate document paragraph block according to the target document title block to obtain target retrieval data matching the retrieval indication information. The present application firstly performs polar coordinate encoding on the candidate paragraphs and candidate titles for word segmentation, so as to preliminarily determine the initial spatial positions of the paragraph blocks and the title blocks in the document; secondly, by calibrating the Gaussian spatial layout position of the paragraph word position information and the title word position information, it is possible to fuse the spatial layout information of the words while extracting the semantic features of the document to determine the spatial layout of the document, thereby improving the retrieval accuracy based on the spatial layout of the document; finally, based on the calibrated title word position information and the calibrated paragraph word position information, the retrieval indication information is matched with the title block and the paragraph block, thereby significantly improving the accuracy of document retrieval.
[0196] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0197] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0198] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0199] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.
[0200] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0201] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0202] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. The mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0203] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0204] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0205] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.
[0206] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.
Claims
1. A retrieval method based on document spatial layout, characterized in that: The method comprises: In response to a document retrieval request, obtaining retrieval instruction information and a target retrieval document; Obtaining candidate document paragraph blocks and candidate document title blocks of the target retrieval document; Segmenting the candidate document paragraph blocks to obtain segmentation candidate paragraphs; segmenting the candidate document title blocks to obtain segmentation candidate titles; Performing polar coordinate coding on the candidate segmentation paragraphs to obtain paragraph word position information; performing polar coordinate coding on the candidate segmentation titles to obtain title word position information; Performing Gaussian space layout position calibration on the paragraph word position information to obtain calibrated paragraph word position information; performing Gaussian space layout position calibration on the title word position information to obtain calibrated title word position information; Perform title search on the candidate document title block according to the search indication information and the calibrated title word position information to obtain a target document title block; The candidate document paragraph blocks are subjected to paragraph retrieval according to the target document title block to obtain target retrieval data matching the retrieval indication information.
2. The method according to claim 1, characterized in that The step of performing Gaussian space layout position calibration on the paragraph word position information to obtain calibrated paragraph word position information includes: Adding the paragraph word position information to a preset Gaussian matrix according to a preset covariance matrix and a preset parameter matrix to obtain paragraph Gaussian position information; The spatial layout position of the paragraph word position information is calibrated based on the paragraph Gaussian position information and preset spatial position adjustment parameters to obtain the calibrated paragraph word position information.
3. The method according to claim 1, characterized in that The step of performing polar coordinate coding on the candidate paragraphs to obtain paragraph word position information includes: Obtaining candidate paragraph word coordinates of the word segmentation candidate paragraph; Calculate the paragraph word distance and paragraph word angle between the candidate paragraphs according to the candidate paragraph word coordinates; The paragraph word position information is determined according to the paragraph word distance and the paragraph word angle.
4. The method according to claim 1, characterized in that: The step of obtaining the candidate document paragraph blocks and candidate document title blocks of the target retrieval document includes: Performing text character recognition on the target search document to obtain target text characters; Performing position coordinate recognition on the target text characters to obtain character position coordinates; Perform paragraph text detection on the target search document according to the character position coordinates to obtain multiple paragraph text areas; Merging the multiple paragraph text areas according to a preset merging rule to obtain the candidate document paragraph block; Perform title text detection on the target retrieval document according to the character position coordinates to obtain multiple title text areas; Title feature analysis is performed on the plurality of title text areas to obtain the document title block.
5. The method according to claim 1, characterized in that The step of performing title search on the candidate document title block according to the search indication information and the calibrated title word position information to obtain the target document title block includes: Performing position coding on the retrieval indication information to obtain coded indication position information; Calculating the position similarity between the encoding indication position information and the calibration title word position information; The candidate document title block with the greatest similarity is selected from the position similarities as the target document title block.
6. The method according to claim 1, characterized in that The step of performing paragraph retrieval on the candidate document paragraph block according to the target document title block to obtain target retrieval data matching the retrieval indication information includes: Obtain a target title paragraph hash index of the target document title block; The candidate document paragraph block is subjected to paragraph retrieval according to the target title paragraph hash index to obtain target retrieval data matching the retrieval indication information.
7. The method according to claim 6, characterized in that Before obtaining the target title paragraph hash index of the target document title block, the method further includes: Calculating the title paragraph similarity between the calibrated paragraph word position information and the calibrated title word position information; Obtaining the title block identifier of the candidate document title block, and obtaining the paragraph block identifier of the candidate document paragraph block; According to the title block identifier, the paragraph block identifier and the title paragraph similarity, the candidate document title block and the candidate document paragraph block are content-associated to obtain title paragraph associated content; A title paragraph hash index between the candidate document title block and the candidate document paragraph blocks is constructed according to a preset hash function and the title paragraph associated content.
8. A retrieval device based on document spatial layout, characterized in that: The device comprises: A retrieval instruction and retrieval document acquisition module, used to obtain retrieval instruction information and target retrieval documents in response to a document retrieval request; A paragraph block and title block acquisition module, used to acquire candidate document paragraph blocks and candidate document title blocks of the target retrieval document; A word segmentation module is used to segment the candidate document paragraph blocks to obtain segmentation candidate paragraphs; segment the candidate document title blocks to obtain segmentation candidate titles; A polar coordinate encoding module is used to perform polar coordinate encoding on the candidate segmentation paragraphs to obtain paragraph word position information; and to perform polar coordinate encoding on the candidate segmentation titles to obtain title word position information; A spatial layout position calibration module is used to perform Gaussian spatial layout position calibration on the paragraph word position information to obtain calibrated paragraph word position information; perform Gaussian spatial layout position calibration on the title word position information to obtain calibrated title word position information; A title search module, used to perform title search on the candidate document title block according to the search indication information and the calibration title word position information, to obtain a target document title block; The paragraph retrieval module is used to perform paragraph retrieval on the candidate document paragraph block according to the target document title block to obtain target retrieval data matching the retrieval indication information.
9. An electronic device, characterized in that: The electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the document spatial layout-based retrieval method described in any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the document spatial layout-based retrieval method according to any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Method and system for retrieving DOCX document content based on keywords
CN121029978A
Method and system for keyword-based search of docx document content
CN121029978B
