Document automatic rendering method and free text fill-in-the-blank gap identification method and device

CN123013859APending Publication Date: 2026-10-30BEIJING QINGSONG YIKANG INFORMATION TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611131546.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-29
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

同时,作答数据以槽位键值对形式离散稀疏存储,序列化传输后无法保证键序,与模板中空位的空间先后顺序不匹配,直接沿用存储顺序填充文档会出现内容排布错乱

Benefits of technology

[0010]本公开实施例提供的文档自动渲染方法,首先获取待渲染文档中每个自由文本字段的字段类型,识别类型为占位模板类型的自由文本字段,记为目标字段,从每个该字段中识别符号连续段,获段长在预设长度范围内的符号连续段,记为候选空位;提取该文档已作答键值对信息,据此对应的序号预设排序进行作答基数重建,获得目标作答基数与作答向量;根据目标作答基数动态修正候选空位在自由文本中的空位元信息,然后据此生成作答向量与候选空位的标记关系,并根据标记关系执行对应字段的渲染,获得渲染文档。该方法能够不改造既有题库、不在题干中预埋标记、不依赖通道保序的前提下,确定性地识别出真实空位的重复字符游程,并能将其与对应作答正确绑定,保证结果可复现,即能够稳定、准确地将无序离散作答数据匹配至真实填空,实现文档的可靠、精准渲染。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123013859A_ABST
    Figure CN123013859A_ABST
Patent Text Reader

Abstract

The application discloses a document automatic rendering method and a free text fill-in-the-blank vacancy identification method and device. The document automatic rendering method comprises the following steps: acquiring the field type of each free text field in a to-be-rendered document, identifying a free text field of a placeholder template type, and marking the free text field as a target field; identifying a symbol continuous segment from each target field, obtaining a symbol continuous segment with a segment length within a preset length range, and marking the symbol continuous segment as a candidate vacancy; extracting key-value pair information of the document with an answer, performing answer cardinality reconstruction on the basis of a corresponding serial number and a preset order, obtaining a target answer cardinality and an answer vector; dynamically correcting vacancy element information of the candidate vacancy in the free text according to the target answer cardinality, then generating a marking relationship between the answer vector and the candidate vacancy on the basis of the vacancy element information, and performing rendering on the corresponding field according to the marking relationship, so as to obtain a rendered document. The method can stably and accurately match disordered and discrete answer data to real fill-in-the-blanks, and realizes reliable and accurate rendering of the document.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the fields of computer data processing and automatic document rendering technology, and in particular to an automatic document rendering method, a free text filling and blank space recognition method, and an apparatus. Background Technology

[0002] In business systems such as electronic forms, online questionnaires, and case report forms (CRF), the question stems with fill-in-the-blanks and user responses are stored and transmitted separately. The question stems are manually written free text templates, and all fill-in-the-blank positions within the template rely solely on repeating character runs of varying lengths, such as continuous underscores, as visual placeholders. These placeholders only control the display width and do not carry semantic information such as serial numbers or names; there are no explicit identifiers like {{name}} or [blank1]. User responses are stored discretely, sparsely, and in a non-determined order as key-value objects with slot identifiers and values, such as JSON: blank0, blank1, blank2, etc. The order of the key-value pairs does not have a fixed correspondence with the order in which the fill-in-the-blanks appear in the template. The business scenario ultimately requires the automatic generation of structured PDF documents that can be signed, reviewed, and archived. The system is required to accurately match the unordered discrete response data to the valid fill-in-the-blank positions within the text template and complete the rendering and filling.

[0003] Existing technologies typically employ template engines and regular expression matching. However, relying solely on the template's text information is insufficient to distinguish between placeholders and decorative characters in the main text. Using regular expression matching to identify continuous underscores can incorrectly capture various separator lines and underscores within URLs, artificially inflating the total number of identified empty spaces and leading to mismatches in the entire set of answer data. Placeholder runs composed of continuous fill characters inherently contain lexical boundary ambiguities. Conventional matching logic easily fragments complete fill areas, creating fragmented markers and completely disrupting the one-to-one correspondence between fill positions and content. Furthermore, answer data is stored discretely and sparsely in slot key-value pairs. Serialization transmission cannot guarantee the key order, resulting in a mismatch with the spatial order of empty spaces in the template. Directly filling the document using the storage order will lead to content layout errors. Converting the template to a standard format string for rendering also presents the risk of a mismatch between the number of fills and answer items. The inclusion of special formatting characters such as percent signs in the template can further induce program errors or output documents with content errors. Summary of the Invention

[0004] In view of this, the present disclosure provides a document automatic rendering method, a free text fill-in-the-blank space recognition method and apparatus, which can solve the problem that the prior art is difficult to stably and accurately match disordered discrete answer data to real fill-in-the-blanks, and cannot achieve reliable and accurate document rendering.

[0005] In a first aspect, embodiments of this disclosure provide a method for automatic document rendering, including: Get the field type of each free text field in the document to be rendered; Identify all free text fields whose field type is placeholder template, and denote them as target fields; Identify consecutive segments of symbols from each of the target fields; the length of each consecutive segment of symbols is less than the length of the target field. The continuous segments of symbols whose lengths are within a preset length range are identified as candidate empty segments; Extract the answered key-value pair information corresponding to the document to be rendered from the answer repository, and reconstruct the answer cardinality based on the preset sorting of the serial numbers corresponding to the answered key-value pair information to obtain the target answer cardinality and answer vector; The candidate empty spaces in the free text are dynamically corrected based on the target response base. Based on the empty space information, a labeling relationship between the answer vector and the candidate empty space is generated, and the corresponding field is rendered according to the labeling relationship to obtain a rendered document.

[0006] Secondly, this disclosure also provides a method for identifying blank spaces in free text filling, including: Get the field type of each free text field in the document to be rendered; Identify all free text fields whose field type is placeholder template, and denote them as target fields; Identify consecutive segments of symbols from each of the target fields; the length of each consecutive segment of symbols is less than the length of the target field. The continuous segments of symbols whose lengths are within a preset length range are identified as candidate empty segments; Extract the answered key-value pair information corresponding to the document to be rendered from the answer repository, and reconstruct the answer cardinality based on the preset sorting of the serial numbers corresponding to the answered key-value pair information to obtain the target answer cardinality and answer vector; The candidate blanks are dynamically corrected based on the target number of responses, and the corrected candidate blanks are used as blanks for free text filling.

[0007] Thirdly, this disclosure also provides a computer device, which adopts the following technical solution: The computer device includes: At least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor; the instructions are executed by the at least one processor to enable the at least one processor to perform either the document automatic rendering method or the free text fill-in-the-blank and blank recognition method described above.

[0008] Fourthly, embodiments of this disclosure also provide a computer-readable storage medium storing computer instructions; the computer instructions are used to cause a computer to execute any of the document automatic rendering methods or the free text fill-in-the-blank and blank recognition methods described above.

[0009] Fifthly, embodiments of this disclosure also provide a computer program product, including a computer program / instructions that, when executed by a processor, implement the steps of any of the methods described above.

[0010] The document automatic rendering method provided in this disclosure first obtains the field type of each free text field in the document to be rendered, identifies free text fields of type placeholder template as target fields, identifies continuous segments of symbols in each field, and obtains continuous segments of symbols with a length within a preset range as candidate blanks; extracts the key-value pairs of answers in the document, reconstructs the answer cardinality based on the corresponding preset order, and obtains the target answer cardinality and answer vector; dynamically corrects the blank element information of the candidate blanks in the free text according to the target answer cardinality, then generates the labeling relationship between the answer vector and the candidate blanks, and performs rendering of the corresponding fields according to the labeling relationship to obtain the rendered document. This method can deterministically identify the repeating character runs of real blanks without modifying the existing question bank, without pre-embedding marks in the question stem, and without relying on channel order preservation, and can correctly bind them with the corresponding answers, ensuring that the results are reproducible. That is, it can stably and accurately match disordered discrete answer data to real fill-in-the-blanks, and achieve reliable and accurate document rendering.

[0011] The above description is merely an overview of the technical solution disclosed herein. In order to better understand the technical means of this disclosure and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this disclosure more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0012] To more clearly illustrate the technical solutions of the embodiments of this disclosure, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0013] Figure 1This is a flowchart illustrating the document automatic rendering method provided in an embodiment of the present disclosure.

[0014] Figure 2 This is a flowchart illustrating a method for obtaining the field type of each free text field in a document to be rendered, as provided in an embodiment of this disclosure.

[0015] Figure 3 A flowchart illustrating the method for obtaining candidate vacancy positions provided in an embodiment of this disclosure.

[0016] Figure 4 This is a schematic flowchart provided for an embodiment of the present disclosure.

[0017] Figure 5 This is a flowchart illustrating the free text fill-in-the-blank and blank recognition method provided in this embodiment of the disclosure.

[0018] Figure 6 This is a schematic diagram of the structure of a computer device provided in an embodiment of the present disclosure. Detailed Implementation

[0019] The embodiments of this disclosure will now be described in detail with reference to the accompanying drawings.

[0020] It should be understood that the following specific examples illustrate the implementation of this disclosure, and those skilled in the art can easily understand other advantages and effects of this disclosure from the content disclosed in this specification. Obviously, the described embodiments are only a part of the embodiments of this disclosure, and not all of them. This disclosure can also be implemented or applied through other different specific implementation methods, and the details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of this disclosure. It should be noted that, in the absence of conflict, the following embodiments and features in the embodiments can be combined with each other. Based on the embodiments in this disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.

[0021] It should be noted that various aspects of embodiments within the scope of the appended claims are described below. It will be apparent that the aspects described herein can be embodied in a wide variety of forms, and any particular structure and / or function described herein is merely illustrative. Based on this disclosure, those skilled in the art will understand that one aspect described herein can be implemented independently of any other aspect, and two or more of these aspects can be combined in various ways. For example, any number of aspects set forth herein can be used to implement the device and / or practice the method. Additionally, this device and / or method can be implemented using structures and / or functionalities other than one or more of the aspects set forth herein.

[0022] It should also be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of this disclosure. The drawings only show the components related to this disclosure and are not drawn according to the number, shape and size of the components in actual implementation. In actual implementation, the form, quantity and proportion of each component can be arbitrarily changed, and the layout of the components may also be more complex.

[0023] Furthermore, specific details are provided in the following description to facilitate a thorough understanding of the examples. However, those skilled in the art will understand that the described aspects can be practiced without these specific details.

[0024] Reference Figure 1 This application discloses a method for automatic document rendering, including: S100, obtain the field type of each free text field in the document to be rendered.

[0025] The document to be rendered is free text containing placeholder runs of variable-length repeating fill characters without explicit markings. This type of text has issues such as blanks without explicit markings, text containing homograph repeating characters, and sparse and disordered answers. In other words, this application mainly targets a special type of free text template that relies solely on continuous repeating symbols of varying lengths as markers for blank positions, without any explicit labels specifically marking the blank areas.

[0026] A free text segment is a free text segment containing variable-length repeating filler character placeholder runs without explicit markings. That is, an anonymous variable-length run without any explicit markings and with the same shape as the main text. It is a continuous repeating symbol without numbering, unique labels, and fixed length. It looks exactly the same as ordinary decorative lines in the document, and there are no special markings to directly distinguish whether it is a filler or not.

[0027] S200 identifies all free text fields whose field type is placeholder template and denotes them as target fields; S300, Identify continuous symbol segments from each target field; the length of the continuous symbol segment is less than the length of the target field; S400: Obtain symbol continuum segments whose lengths are within a preset length range, and record them as candidate empty spaces; S500: Extract the answered key-value pair information corresponding to the document to be rendered from the answer repository, and reconstruct the answer cardinality based on the preset sorting of the serial numbers corresponding to the answered key-value pair information to obtain the target answer cardinality and answer vector. S600 dynamically corrects the empty space information of candidate empty spaces in the free text based on the number of responses.

[0028] The vacancy information includes the number and location of candidate vacancy slots.

[0029] S700 generates a labeling relationship between the answer vector and the candidate empty space based on the empty space information, and performs rendering of the corresponding fields according to the labeling relationship to obtain the rendered document.

[0030] The document automatic rendering method disclosed in this application handles anonymous variable-length runs that are identical in form to the main text without any explicit markers. It requires no modification to existing question banks or pre-embedded markers. This method does not rely on serialization channels for order preservation; instead, it stably reconstructs the spatial order and cardinality using the embedded sequence number within the answer key, making it robust to non-order-preserving channels. Specifically, a preset length range determines out-of-bounds text such as indicator lines / separator lines / URL underscores as non-empty spaces and preserves the original text, fundamentally avoiding misjudgments in one-sided matching. By constraining the answer cardinality and selecting / segmenting according to deterministic rules, the number of actual empty spaces is equal to the number of answers, eliminating incorrect fillings and misalignments, correctly binding them to the corresponding answers, and ensuring reproducible results. This method does not require pre-embedded named / ordered placeholders in the question stem and is compatible with existing free text question banks.

[0031] Reference Figure 2 The methods for obtaining the field type of each free text field in the document to be rendered in S100 include: S110: Based on the configured form template, construct the mapping relationship between field identifiers and control types.

[0032] Specifically, obtain the complete form template configuration data. The template contains configuration information for all form fields. Filter out invalid components that do not carry business data, such as dividers, group titles, and operation buttons.

[0033] Iterate through all remaining valid business field configuration items, extract the globally unique field identifier corresponding to each field and the predefined control type information, and bind the two one by one to form a pair association.

[0034] A hash key-value structure is used to store the corresponding relationships in a unified manner, thus constructing a complete, conflict-free, and efficiently queried mapping relationship between field identifiers and control types.

[0035] Furthermore, the mapping between field identifiers and control types can be categorized into three types. The first type is the core correspondence mapping between slot identifiers and basic input control types. Slot identifiers are unordered discrete key names such as blank0, blank1, and blank2 in the answer data. The corresponding control types are tailored to the filling scenarios of CRF medical records, electronic forms, and online questionnaires, including single-line free text input controls, multi-line long descriptive text controls, numeric input controls, integer numeric controls, decimal numeric controls, date selection controls, time selection controls, date and time combination controls, single-select dropdown selection controls, multi-select checkboxes, single-item checkboxes, image attachment upload controls, and signature handwriting controls.

[0036] The second category is the association mapping between the form of fill-in-the-blank placeholders and the attributes of auxiliary controls. The mapping is established based on the character length of the run of the underline placeholder in the template and the characteristics of the text boundary before and after the placeholder. Short underline placeholders are associated with single-line short text controls, long continuous underline placeholders are associated with multi-line text controls, underline placeholders with unit prefixes are associated with numerical controls, and independent single-line centered long underline placeholders are associated with handwritten signature controls. At the same time, easily confused decorative underlines (separators, URL underlines) are marked as invalid non-fill-in-the-blank placeholders to filter out misidentified content.

[0037] The third category is the extended mapping between semantic tags for business fields and control types. Based on the pre-defined business field codes and names in the original form template configuration, a bidirectional association is formed with the slot blank number, synchronously binding the corresponding control type. For example, the code for the chief complaint field in a medical record is associated with a multi-line text control, the code for the age field is associated with an integer control, the code for the date of consultation is associated with a date control, and the code for the diagnosis result is associated with a single-select or multi-select composite control.

[0038] S120 preprocesses the document to be rendered, identifying free text fields in the preprocessed document.

[0039] The preprocessing includes at least escaping formatting-sensitive characters and standardizing typesetting characters in the question stem. Specifically, special symbols such as percent signs that may interfere with parsing are escaped, and messy line breaks, spaces, and other typesetting symbols are standardized. At the same time, the number of valid characters remains unchanged before and after the processing to ensure that the escaping operation does not destroy the original content of the question stem.

[0040] In this step, preprocessing can first escape format-sensitive characters and ensure that the number of elements is constant, thus eliminating runtime exceptions during rendering; it also isolates by field, preventing local failures from spreading.

[0041] S130, determine the field type of each free text field according to the mapping relationship.

[0042] This step allows you to quickly determine the field type of each free text field based on the needs of different scenarios and the corresponding mapping relationships.

[0043] The method for obtaining the target field of S200 includes: determining the placeholder template type; and identifying the free text field whose field type is the placeholder template type as the target field.

[0044] Among them, the placeholder template type is a type with several blank spaces, such as FieldMultipleBlanks, for example, the free text field "The patient was diagnosed with ____ disease in ____ year ____ month" belongs to a target field.

[0045] In this embodiment, the original value is retained for free text fields of non-placeholder template types.

[0046] Further, several fill-in blanks are preferably in the form of underlined placeholders without labels, for example, requiring that only underscores are used as placeholders in the text, while there are at least two groups of consecutive underscore segments with a length of no less than two digits, and there are no descriptive text labels paired with colons or enumeration commas at the starting position of the text. A field is formally marked as a target field only when both of the two content constraints are satisfied, and any failure to meet any one of the criteria will directly exclude the field.

[0047] For example, for the field text with the template identifier FieldMultipleBlanks: __Li Ming__, 20260713, Beijing, Chaoyang District__, there are no preceding description labels, and the content to be extracted is only wrapped by multiple consecutive underscores, which will be identified as a target field. The consecutive symbol segments between the underscores can be extracted subsequently, even if the content wrapped by the underscores is mixed with numbers or other special symbols, it will not affect the field determination. In this embodiment, by limiting the template type to only process free text fields of the placeholder template type, the false matching problems caused by asterisks, pound signs, and fields with text labels are avoided from the source, irrelevant fields such as single-fill fields and ordinary texts are distinguished, and invalid recognition results are reduced.

[0048] In addition, the several fill-in blanks can also be underscores, asterisks, ellipses, spaces, etc., and the screening rules can be flexibly configured according to actual scenarios.

[0049] Identifying consecutive symbol segments from each target field in S300 includes: determining a target format; identifying consecutive segments consistent with the target format from each target field, which are recorded as consecutive symbol segments.

[0050] Wherein, the target format includes at least two consecutive identical filling characters, and the filling characters are placeholder symbols such as underscores and asterisks, which distinguish ordinary texts, numbers from placeholder filling characters.

[0051] Specifically, the definition boundary of the target format is clarified, that is, it clearly contains at least two consecutive identical filling characters. Traverse all target fields to be processed, split the text units in each field, first locate the identification prefix carried by the field itself, such as fixed separation labels like "Name:", "Mobile Phone Number:", "ID Number:", then search backward for the consecutive repeated filling character intervals appearing in the text. When two or more groups of consecutive filling characters of the same type are retrieved, the text content wrapped between the two groups of filling characters is intercepted as a consecutive symbol segment. Taking "Name: ------" as an example, two consecutive underscores on the front and rear sides form a compliant target format. After identification, the prefix "Name:" and the underscore filling characters on both sides are removed, and the consecutive symbol segment "------" is finally extracted.

[0052] Among them, at least two consecutive identical fill characters can be underscores, asterisks, ellipses, spaces, etc.

[0053] Reference Figure 3 The methods for obtaining S400 candidate vacancy slots include: S410, Get the length of all consecutive segments of symbols in the document to be rendered; S420: Obtain a continuous segment of symbols whose length is within the preset length range, and record it as the initial empty space.

[0054] The preset length range is: , This serves as the lower limit, used to distinguish between small decorative items and potential empty spaces; The upper limit indicates the maximum length allowed for filling in blanks in the form editor. Excessively long repeating characters exceeding the editor's generation limit N are treated as text and retained as original content; characters shorter than the lower limit m are treated as decorations and neither is included in the filling process.

[0055] Furthermore, the editor's maximum space length N is automatically set to the maximum length of consecutive segments of symbols in the entire document, but it can also be configured manually.

[0056] The initial set of empty spaces contains all fillable blank areas within the template that meet the size requirements. Since it has not been screened or verified, there are potential problems such as overlapping empty spaces, mixed long and short sizes, easy merging of independent empty spaces, and long empty spaces being covered by short empty spaces.

[0057] S430: Sort all initial empty spaces in descending order of their segment length, and then perform monotonically reduced constraint processing on the sorted initial empty spaces to obtain effective target empty spaces.

[0058] Monotonic reduction constraint means that the processing order is unidirectional and irreversible. The long blank space selected first has higher priority and will not be modified by the subsequent short blank spaces. That is, once a blank space is selected, the whole space is used completely and will never be divided into multiple small segments to prevent a large filling position from being cut into multiple scattered small blank spaces by the algorithm (fragmented blank space), thus ensuring that the filling area is a complete piece.

[0059] Specifically, the selected initial empty spaces are sorted from longest to shortest, with the larger empty spaces processed first, followed by the smaller ones.

[0060] Each initial empty space is analyzed by interval mutual exclusion verification. Interval mutual exclusion means that multiple valid empty space coordinates are not allowed to overlap. That is, during the analysis process, it is determined in real time whether the template coordinate interval of the current empty space overlaps with the previously locked empty space interval.

[0061] If the current initial empty space does not overlap with the locked interval, it means that the interval mutual exclusion condition is met. Then, a unique internal temporary marker is assigned to the initial empty space, and the template interval corresponding to the initial empty space is recorded. The template interval includes the interval coordinates, segment length, and position information. The template interval corresponding to the empty space is locked and included in the set of valid empty spaces.

[0062] If there is overlapping intervals, the current initial empty space is discarded. Interval mutual exclusion check is used to implement the filtering logic of prioritizing long empty spaces and avoiding short empty spaces, ensuring that the final valid empty spaces do not overlap.

[0063] During the analysis of each initial empty space, the constraints of ensuring the integrity of a single candidate empty space and avoiding the fragmentation of empty space intervals are satisfied, while the constraint of not merging initial empty spaces with mutually isolated intervals is also satisfied, preventing the swallowing of adjacent independent empty spaces. Specifically, the original intervals of the initial empty spaces are not split or cut, completely eliminating the problem of empty space fragmentation, ensuring that each identified filling empty space is a complete, continuous, and independent interval, and avoiding the breaking down of a single complete filling area into multiple fragmented and invalid empty spaces. If there is text or a separator between two blank segments, and they are independent and their intervals do not touch, even if they are very close, they are not allowed to be merged into one empty space, avoiding the merging of two adjacent independent filling positions into a super-large empty space, thus effectively preventing the swallowing of adjacent empty spaces.

[0064] S440: Reorder the template intervals of each valid target empty space in ascending order to obtain candidate empty spaces.

[0065] In existing technologies, directly scanning the text in a forward sequence will break up continuous fill symbols into fragmented spaces; if only decreasing-length scanning is used to directly assign output markers, the order of the space marker numbers and the text in the question stem will be disordered, affecting subsequent fill-in-the-blank matching and answer sheet positioning. This embodiment first uses decreasing-length scanning to solve the core technical defects of fragmented spaces and incorrect merging of adjacent spaces, and then corrects the marker order by rearranging the intervals in ascending order, while taking into account both recognition accuracy and consistency of business output order. The internal temporary markers only serve interval conflict verification, while the external business standard markers are based on the text position.

[0066] The method for obtaining candidate empty spaces disclosed in this embodiment is applicable to scenarios such as the automatic identification of blank filling areas in paper form digitization, label-free document templates, and structured format documents. It can accurately extract blank empty spaces in the template that can be filled with content and effectively avoid the defects of traditional recognition algorithms such as fragmented empty spaces, merging of adjacent empty spaces, and misidentification of overlapping empty spaces.

[0067] Reference Figure 4 Methods for reconstructing the response base for S500 include: S510, extract the answered key-value pair information corresponding to the document to be rendered from the answer repository.

[0068] In this embodiment, the extracted key-value pairs of answers are not strictly arranged in the correct order. This is because in business systems such as electronic forms, online questionnaires, and case report forms (CRF), the question stems with fill-in-the-blanks and the user's answer data are stored and transmitted separately. The question stems are free text templates written by humans. All the fill-in-the-blank positions in the template rely solely on repeated character runs such as continuous underscores of varying lengths as visual placeholders. These placeholders only control the display width and do not carry semantic information such as serial numbers or names. There are no explicit identifiers such as {{name}} or [blank1]. The user's answer data is stored discretely, sparsely, and in a non-determined order as key-value objects with slot identifiers and values, such as JSON: blank0, blank1, blank2, etc. The order of the key-value pairs does not have a fixed correspondence with the order in which the fill-in-the-blanks appear in the template.

[0069] S520: Extract the embedded sequence number from the answered key-value pair information, sort the sequence numbers in ascending order from smallest to largest, and obtain the answered sequence.

[0070] Extracting embedded serial numbers from the answered key-value pairs and sorting them in ascending order to generate an answered sequence can eliminate the data disorder problem caused by document text partitioning and recognition traversal order, stably restore the original filling arrangement order of the form, and ensure that consistent and ordered results can be output when parsing the same document multiple times.

[0071] S530, according to the preset order of the serial number, the already answered sequence is densely padded to obtain the target answer cardinality and answer vector.

[0072] In this embodiment, dense padding refers to using the minimum and maximum sequence numbers extracted from all current fill keys as complete boundaries, and filling in every consecutive natural number sequence number in the middle of the interval. Regardless of whether there is a corresponding blank key in the original data, the missing sequence number positions are uniformly filled with empty values ​​to eliminate sequence number gaps and form a continuous and uninterrupted ordered data sequence.

[0073] Taking the input answer storage object {blank0:"Zhang San", blank3:"Male", blank2:"18"} as an example, firstly, without relying on the original arrangement order of the keys after JSON serialization, the embedded numbers at the end of each blank prefix key name are extracted as unique sorting identifiers, and three sets of serial numbers 0, 3, and 2 are extracted respectively.

[0074] The sequence number is sorted in a stable ascending order based on the size of the numbers, resulting in an ordered sequence of numbers 0, 2, 3. This sorting logic corresponds to the predefined answering order of the fill-in-the-blank standard in the document and will not be affected by the disorder of the transmitted data key positions.

[0075] The minimum and maximum extracted sequence numbers 0 and 3 are used to define a complete and continuous sequence number interval. All natural numbers 0, 1, 2, and 3 within the interval are traversed and dense padding is performed. Sequence number 1 does not have a corresponding answer key and is considered a missing sequence number. The corresponding position is filled with blank placeholder content. Dense padding is to actively add the empty position of sequence number 1 and fill it with blank content. After padding, an ordered and unbroken answer vector V is generated, namely ["Zhang San", "", "18", "Male"]. There is no longer a sparse state of skipped sequence numbers. This generates a continuous and complete answer vector, which will not cause the vector length to be missing or the order to be misplaced due to the user not filling in a certain empty position. It completely transforms the disordered discrete answer data into a fixed, ordered, and position-aligned standard vector format.

[0076] Finally, the number of blank spaces within the vector is counted, and the target response cardinality, i.e., the actual number of blank spaces in the document, p, is determined to be 4. In this embodiment, the entire processing flow establishes a unified ordered structure solely based on the numbers embedded in the keys, completely avoiding data corruption caused by unstable key order in the serialization channel.

[0077] For S600, the empty position metadata of candidate empty positions in the free text is dynamically corrected according to the target response base; based on the empty position metadata, the labeling relationship between the response vector and the candidate empty positions is generated, and the rendering of the corresponding fields is performed according to the labeling relationship to obtain the rendered document.

[0078] The vacancy information includes the number and location of candidate vacancy slots.

[0079] Specifically, when the candidate empty space is consistent with the target response base, the candidate empty space is taken as all the real empty spaces. Based on the empty space metadata, the response vector and the real empty space are directly marked, and the corresponding fields are rendered according to the marking relationship to obtain the rendered document.

[0080] When the number of candidate empty spaces exceeds the target number of response slots, it indicates that too many candidate empty spaces have been identified, meaning there are too many spaces that can be filled in the text, exceeding the standard number of response slots in the document. In this case, p candidates are retained based on a deterministic priority order of descending length and ascending position, while the rest are returned to the main text and the original text is retained. Here, p is the number of target response slots.

[0081] Specifically, all candidate spaces are first sorted uniformly, and core spaces with longer text lengths and earlier positions for the same length are retained first. The first p valid spaces are accurately selected and their original quantity and position metadata are fully preserved. The remaining qp candidate spaces are rolled back, the space markers are removed, the corresponding content is restored to ordinary text and the original content is fully preserved, and only the space attributes and metadata are updated. Finally, the number of valid spaces is simplified and aligned to the standard base number p.

[0082] When the number of candidate empty spaces exceeds the target number of responses, it indicates that too few candidate empty spaces have been identified, meaning that the number of effective empty spaces in the text is insufficient to match the document's standard response length. In this case, the longest outbound text run is selected and promoted to empty spaces, or the excessively long run is divided equally according to the response string length to p. The selection and division are uniquely determined by (candidate set, p), and the results are reproducible.

[0083] Specifically, the system actively fills in empty spaces in the main text until the number equals p. It first traverses the entire text to filter out all continuous runs of pure main text without empty spaces. The main text runs are then sorted according to the rules of descending length and ascending position, and the longest main text paragraph is selected as the segmentation material.

[0084] Based on the number of gaps pq, the ultra-long text run is uniformly divided using deterministic rules of fixed equal division or division according to the length ratio of the answer string. Some ordinary text paragraphs are upgraded to new candidate gaps. Each division precisely updates the number of gaps, start and end positions and other metadata, gradually filling the gaps, and finally ensuring that the total number of candidate gaps in the text strictly matches the answer base p.

[0085] Once the number of candidate vacancies is dynamically adjusted to match the target number of responses, a labeling relationship between the response vector and the candidate vacancies is generated based on the vacancies metadata. The corresponding fields are then rendered based on the labeling relationship to obtain the rendered document.

[0086] In this embodiment, by dynamically correcting candidate blanks based on the target response base, pseudo-blanks such as separator lines and URL underlines generated by regular expression recognition can be effectively filtered out, and fragmented placeholder areas can be merged to accurately identify the real blank positions within the text template, avoiding data filling misalignment caused by false blank recognition. At the same time, an effective blank sequence arranged sequentially along the text space is generated to build a stable filling benchmark, solving the problem of disordered content arrangement caused by the disorder of key-value type response data, and realizing accurate mapping between discrete response data and blank positions.

[0087] This method can also perform consistency checks between the number of empty spaces and the number of answer items before PDF rendering, promptly handle quantity mismatch anomalies, reduce defects such as document rendering failure, omissions, and duplicate filling, and isolate the fill-in placeholders from the logic of ordinary text, avoiding rendering errors and text anomalies caused by special characters such as percent signs in the template, and improving the stability of archived PDF generation.

[0088] This method does not rely on fixed regular expression rules and standardized placeholders. It can adapt to non-standardized free text templates written by humans, while simplifying the candidate empty space set, reducing the matching search space, reducing matching ambiguity and algorithm overhead, and ensuring that the output documents meet the business compliance requirements for review, signing and long-term archiving.

[0089] This application primarily addresses a specific type of free-text template. These templates rely solely on consecutive, repetitive symbols of varying lengths as markers for fill-in-the-blank positions, lacking explicit labels indicating the fill-in-the-blank areas. Such texts contain both blank placeholders for reserved content and similar consecutive, repetitive characters serving only a formatting and decorative purpose. Both types of characters appear identical, making them difficult to distinguish automatically using conventional methods. Furthermore, the business responses to be filled are independent, and their storage order does not correspond to the order in which the blanks appear within the template. Traditional fill-in methods often result in data mismatches and fill-in failures. The method provided in this application automatically identifies the purpose of repetitive characters within the text, accurately selecting the truly needed fill-in-the-blank positions. Unaffected by the original data arrangement order, it achieves a unique and stable match between each response and its corresponding fill-in-the-blank position. Finally, based on the matched correspondence, it automatically completes the content fill, outputting a well-formatted and complete structured formal document.

[0090] Reference Figure 5 Secondly, this application discloses a method for identifying blank spaces in free text filling, including: S10, obtain the field type of each free text field in the document to be rendered; S20, identify all free text fields whose field type is placeholder template, and denote them as target fields; S30, Identify symbolic contiguous segments from each target field; the length of the symbolic contiguous segment is less than the length of the target field; S40, obtain the continuous segments of symbols whose length is within the preset length range, and record them as candidate empty spaces; S50: Extract the answered key-value pair information corresponding to the document to be rendered from the answer repository, and reconstruct the answer cardinality based on the preset sorting of the serial numbers corresponding to the answered key-value pair information to obtain the target answer cardinality and answer vector. S60: Dynamically adjust the candidate blanks based on the target number of responses, and use the adjusted candidate blanks as blanks for free text filling.

[0091] Among them, the corrected candidate blanks in the free text are recorded as the blank information of the accurately identified blanks in the free text.

[0092] It should be noted that the specific implementation method of each step in this embodiment is consistent with the corresponding steps S100-S600 in the document automatic rendering method disclosed in the first aspect of this application, so they will not be described in detail here.

[0093] A computer device according to embodiments of the present disclosure includes a memory and a processor. The memory is used to store non-transitory computer-readable instructions. Specifically, the memory may include one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may, for example, include random access memory (RAM) and / or cache memory. The non-volatile memory may, for example, include read-only memory (ROM), hard disk, flash memory, etc.

[0094] The processor may be a central processing unit (CPU) or other form of processing unit with data processing capabilities and / or instruction execution capabilities, and may control other components in the computer device to perform desired functions. In one embodiment of this disclosure, the processor is used to execute computer-readable instructions stored in the memory, causing the computer device to perform all or part of the steps of the document automatic rendering method or the free text fill-in-the-blank and gap recognition method described in the foregoing embodiments of this disclosure.

[0095] Those skilled in the art will understand that, in order to solve the technical problem of how to achieve a good user experience, this embodiment may also include well-known structures such as communication buses and interfaces, and these well-known structures should also be included within the protection scope of this disclosure.

[0096] like Figure 6 This is a schematic diagram of a computer device provided for an embodiment of the present disclosure. It illustrates a structural schematic diagram suitable for implementing the computer device in the embodiments of the present disclosure. Figure 6 The computer device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.

[0097] like Figure 6 As shown, a computer device may include a processor (such as a central processing unit, graphics processing unit, etc.), which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) or programs loaded from storage devices into random access memory (RAM). The RAM also stores various programs and data required for the operation of the computer device. The processor, ROM, and RAM are interconnected via a bus. Input / output (I / O) interfaces are also connected to the bus.

[0098] Typically, the following devices can be connected to the I / O interface: input devices, such as sensors or visual information acquisition devices; output devices, such as displays; storage devices, such as magnetic tapes or hard drives; and communication devices. Communication devices allow the computer device to communicate wirelessly or wiredly with other devices (such as edge computing devices) to exchange data. Although Figure 6A computer apparatus with various devices is shown, but it should be understood that it is not required to implement or have all of the devices shown. More or fewer devices may be implemented or included alternatively.

[0099] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from a storage device, or installed from a ROM. When the computer program is executed by a processor, all or part of the steps of the document automatic rendering method or the free text fill-in-the-blank method of embodiments of this disclosure are performed.

[0100] For a detailed description of this embodiment, please refer to the corresponding descriptions in the foregoing embodiments, which will not be repeated here.

[0101] A computer-readable storage medium according to embodiments of the present disclosure stores non-transitory computer-readable instructions. When the non-transitory computer-readable instructions are executed by a processor, all or part of the steps of the document automatic rendering method or the free text fill-in-the-blank and blank recognition method described in the foregoing embodiments of the present disclosure are performed.

[0102] The aforementioned computer-readable storage media include, but are not limited to: optical storage media (e.g., CD-ROM and DVD), magneto-optical storage media (e.g., MO), magnetic storage media (e.g., magnetic tape or portable hard drive), media with built-in rewritable non-volatile memory (e.g., memory card), and media with built-in ROM (e.g., ROM cartridge).

[0103] For a detailed description of this embodiment, please refer to the corresponding descriptions in the foregoing embodiments, which will not be repeated here.

[0104] The basic principles of this disclosure have been described above with reference to specific embodiments. However, it should be noted that the advantages, benefits, and effects mentioned in this disclosure are merely examples and not limitations, and should not be considered as essential features of each embodiment of this disclosure. Furthermore, the specific details disclosed above are for illustrative and facilitative purposes only, and are not limitations. These details do not limit the scope of this disclosure to the necessity of employing the aforementioned specific details for implementation.

[0105] In this disclosure, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. The block diagrams of devices, apparatuses, devices, and systems involved in this disclosure are merely illustrative examples and are not intended to require or imply that they must be connected, arranged, or configured in the manner shown in the block diagrams. As those skilled in the art will recognize, these devices, apparatuses, devices, and systems can be connected, arranged, and configured in any manner. Words such as "comprising," "including," "having," etc., are open-ended terms meaning "including but not limited to," and are used interchangeably with them. The terms "or" and "and" as used herein refer to the terms "and / or," and are used interchangeably with them unless the context clearly indicates otherwise. The term "such as" as used herein refers to the phrase "such as but not limited to," and is used interchangeably with it.

[0106] Additionally, as used herein, the "or" used in a list of items beginning with "at least one" indicates a separate list, such that a list of, for example, "at least one of A, B, or C" means A or B or C, or AB or AC or BC, or ABC (i.e., A and B and C). Furthermore, the word "exemplary" does not imply that the described example is preferred or better than other examples.

[0107] It should also be noted that in the systems and methods of this disclosure, the components or steps can be decomposed and / or recombined. These decompositions and / or recombinations should be considered as equivalent solutions to this disclosure.

[0108] Various changes, substitutions, and modifications can be made to the technology described herein without departing from the teachings defined by the appended claims. Furthermore, the scope of the claims of this disclosure is not limited to the specific aspects of the processes, machines, manufactures, events, means, methods, and actions described above. Currently existing or later-developed processes, machines, manufactures, events, means, methods, or actions that perform substantially the same function or achieve substantially the same result as the corresponding aspects described herein can be utilized. Therefore, the appended claims include such processes, machines, manufactures, events, means, methods, or actions within their scope.

[0109] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use this disclosure. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein may be applied to other aspects without departing from the scope of this disclosure. Therefore, this disclosure is not intended to be limited to the aspects shown herein, but rather to be carried out within the widest scope consistent with the principles and novel features disclosed herein.

[0110] The above description has been given for purposes of illustration and description. Furthermore, this description is not intended to limit the embodiments of this disclosure to the forms disclosed herein. Although numerous exemplary aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, alterations, additions, and sub-combinations therein.

Claims

1. A method for automatically rendering documents, characterized in that, include: Get the field type of each free text field in the document to be rendered; Identify all free text fields whose field type is placeholder template, and denote them as target fields; Identify consecutive segments of symbols from each of the target fields; the length of each consecutive segment of symbols is less than the length of the target field. The continuous segments of symbols whose lengths are within a preset length range are identified as candidate empty segments; Extract the answered key-value pair information corresponding to the document to be rendered from the answer repository, and reconstruct the answer cardinality based on the preset sorting of the serial numbers corresponding to the answered key-value pair information to obtain the target answer cardinality and answer vector; The candidate empty spaces in the free text are dynamically corrected based on the target response base. Based on the empty space information, a labeling relationship between the answer vector and the candidate empty space is generated, and the corresponding field is rendered according to the labeling relationship to obtain a rendered document.

2. The document automatic rendering method according to claim 1, characterized in that, The process of obtaining the field type of each free text field in the document to be rendered includes: Based on the configured form template, construct a mapping relationship between field identifiers and control types; Preprocess the document to be rendered, and identify free text fields in the preprocessed document to be rendered; Wherein, the document to be rendered is free text containing variable-length repeating padded character placeholder runs without explicit markers; the free text segment is a free text segment containing variable-length repeating padded character placeholder runs without explicit markers. The field type of each of the free text fields is determined based on the mapping relationship.

3. The document automatic rendering method according to claim 1, characterized in that, The identification of all free text fields whose field type is placeholder template type is denoted as target fields, including: Determine the placeholder template type, wherein the placeholder template type is a type with several blank spaces to fill in; The free text field whose field type is identified as the placeholder template type is denoted as the target field.

4. The document automatic rendering method according to claim 1, characterized in that, The step of identifying consecutive segments of symbols from each of the target fields includes: Determine a target format, which includes at least two consecutive identical padding characters; Identify consecutive segments from each of the target fields that conform to the target format, and denote them as symbolic consecutive segments.

5. The document automatic rendering method according to claim 1, characterized in that, The segment of symbol continuity whose length is within a preset length range is denoted as a candidate empty space, including: Get the length of all consecutive segments containing the aforementioned symbols in the document to be rendered; Obtain the continuous segments of symbols whose lengths are within a preset range, and record them as initial empty spaces; Sort all the initial empty spaces in descending order of their own segment length, and then perform monotonically reduced constraint processing on the sorted initial empty spaces to obtain effective target empty spaces. Candidate empty spaces are obtained by reordering the starting character indices of the template intervals of each valid target empty space in ascending order.

6. The document automatic rendering method according to claim 1, characterized in that, The process of extracting answered key-value pairs from the answer repository, reconstructing the answer cardinality based on the preset sorting of the serial numbers corresponding to the answered key-value pairs, and obtaining the target answer cardinality and answer vector includes: Extract the answered key-value pairs corresponding to the document to be rendered from the answer repository; Extract the embedded sequence number from the answered key-value pair information, sort the sequence numbers in ascending order from smallest to largest, and obtain the answered sequence. The already answered sequence is densely padded according to the preset sorting of the serial numbers to obtain the target answer cardinality and answer vector.

7. A method for identifying blank spaces in free text filling, characterized in that, include: Get the field type of each free text field in the document to be rendered; Identify all free text fields whose field type is placeholder template, and denote them as target fields; Identify consecutive segments of symbols from each of the target fields; the length of each consecutive segment of symbols is less than the length of the target field. The continuous segments of symbols whose lengths are within a preset length range are identified as candidate empty segments; Extract the answered key-value pair information corresponding to the document to be rendered from the answer repository, and reconstruct the answer cardinality based on the preset sorting of the serial numbers corresponding to the answered key-value pair information to obtain the target answer cardinality and answer vector; The candidate blanks are dynamically corrected based on the target number of responses, and the corrected candidate blanks are used as blanks for free text filling.

8. A computer device, characterized in that, The computer device includes: At least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor; the instructions are executed by the at least one processor to enable the at least one processor to perform the document automatic rendering method according to any one of claims 1-6 or the free text fill-in-the-blank and blank recognition method according to claim 7.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions; the computer instructions are used to cause the computer to perform the document automatic rendering method according to any one of claims 1-6 or the free text fill-in-the-blank and blank recognition method according to claim 7.

10. A computer program product comprising computer instructions, characterized in that, When executed by a processor, the computer instructions implement the steps of the document automatic rendering method according to any one of claims 1-6 or the free text fill-in-the-blank and blank recognition method according to claim 7.