Whole-process intelligent generation system and method for identification document
The intelligent generation system and methods have solved the problems of low efficiency and error-proneness in the generation of traditional judicial appraisal documents, and have achieved automated, standardized and complete evidence chain document generation, which can meet the personalized needs of different judicial units.
Patent Information
- Application Number
- CN202511715141.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-21
- Publication Date
- 2026-02-10
AI Technical Summary
The traditional process of generating forensic documents relies on manual operation, which is inefficient, prone to errors, has inconsistent formats, and incomplete chains of evidence, making it difficult to cope with the challenges of massive amounts of electronic evidence.
A fully intelligent system and method for generating appraisal documents is adopted, including technologies such as browser positioning, HTML file search, page rendering, region screenshotting, file filtering, data parsing and structuring, and automated filling of judicial documents. Large language models and regular expressions are used to ensure the automation, standardization and accuracy of data processing.
It has enabled the automated generation of expert reports, improved data processing efficiency, reduced human error, ensured uniform document format, established a complete chain of evidence, and adapted to the personalized needs of different judicial units.
Smart Images

Figure CN121501958A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of text generation and intelligent legal document technology, and in particular to an intelligent system and method for generating authentication documents throughout the entire process. Background Technology
[0002] In the field of forensic identification, document generation is a rigorous, complex, and highly standardized process. Traditionally, this process heavily relies on manual operation by forensic personnel, including: manually collecting and filtering raw data from various sources (such as local HTML reports, various data files, and authorization documents); performing tedious cleaning and structure conversion of non-standardized JSON data; extracting key parameters from lengthy device information; and finally, writing and arranging the report content item by item according to strict judicial document formats. This manual-driven model has significant drawbacks: First, it is inefficient, with data processing and document writing being extremely time-consuming and unable to cope with the challenges of massive amounts of electronic evidence; second, it is prone to errors, as human negligence during complex data extraction and conversion processes may lead to the omission or misinterpretation of key information, affecting the accuracy of the report; third, standardization is difficult to unify, as documents written by different forensic personnel may differ in format and terminology, undermining the seriousness and authority of judicial documents; finally, the integrity and traceability of the evidence chain are insufficiently guaranteed, as manual operation makes it difficult to systematically record metadata for each step of the processing, posing challenges to subsequent judicial review.
[0003] Therefore, the current judicial appraisal industry urgently needs a document generation technology that can achieve full-process automation and intelligence, and ensure that the output results are accurate, standardized and have a complete chain of evidence. Summary of the Invention
[0004] The purpose of this invention is to provide an intelligent system and method for generating authentication documents throughout the entire process in order to solve the above-mentioned problems.
[0005] To achieve the above objectives, the present invention adopts the following technical solution:
[0006] On the one hand, a method for intelligent generation of authentication documents throughout the entire process includes:
[0007] S1. Original Report Screenshot Sampling of Legal Documents: By locating the browser executable file, the target HTML document is recursively searched and verified. Then, a headless browser instance is launched to load the document and ensure its full rendering. Based on preset priority rules and geometric properties, the valid screenshot area in the page is verified and located. Finally, the image of the area is captured and an image file that meets the quality standards is output.
[0008] S2. Raw data collection of legal documents: After receiving the specified case report root directory path and verifying its accessibility, a depth-first search is used for recursive traversal, while setting the maximum recursion depth and excluding system directories and caches; the target file is located through a triple identification mechanism including filename prefix matching, extension verification and content feature detection, and the identified file content and case metadata are automatically extracted to establish an association mapping.
[0009] S3. Intelligent parsing and information extraction of various authorized documents: Automatically selects the corresponding document loader based on the file extension to extract the document text content, and automatically switches to a backup loader when the main loader fails. Based on a predefined key field dictionary, multi-channel character matching is used to identify target paragraphs and implement content filtering. The locally deployed Ollam platform is used as the large model processing engine, extracting specified key field content through preset prompt templates, adhering to the principles of extracting only explicit document content, omitting null fields, and limiting the output range. A multi-level JSON parsing mechanism is used to process the model response, and the parsing results are verified for content authenticity.
[0010] S4. Data Extraction and Structuring: Non-standard JSON formats in the source data are repaired and standardized, including cleaning the data environment using regular expressions, fixing JSON structure errors, and ensuring balanced brackets. If the repaired data still cannot be parsed, a backup parsing scheme is switched to extract JSON objects or array fragments through fragmentation and intelligently reorganizes them based on the relationships between key identifiers to construct a valid JSON structure. After obtaining a valid JSON structure, the data is recursively traversed, and a global mapping table from IDs to nodes is built, forming a complete tree structure skeleton. Based on a preset depth control dictionary, differentiated processing depths, priorities, and lists of fields that must be extracted are configured for different types of nodes. A depth-first recursive strategy is used to traverse nodes, performing different depths of processing according to the node branch type.
[0011] S5. Generating Forensic Document Content: A recursive traversal algorithm is used to extract the total number of data entries and the number of recovered data entries starting from the root node of the data tree, generating a standardized summary paragraph. Depth-first traversal is used to process the categorical data and application data branches separately, extracting statistical values for each node and recursively traversing child nodes to construct a complete enumeration list of categorical data. Differentiated depth control is applied to the application data branch; ordinary application data is processed to the second level, while social communication data is nested to the fifth level, generating account-level descriptions. During text generation, a simplified or complete output format is dynamically selected based on the number of recovered data entries, and all generated content conforms to forensic document standards.
[0012] S6 Automated Device Parameter Parsing Based on a Large Language Model: It employs a locally deployed large language model as the processing engine, configuring a specified context window size and maximum single-generation length. The raw device information text is encapsulated into a standard document object. The model is guided to extract information using a prompt template containing task requirements, output format examples, and raw text placeholders. An end-to-end inference process is implemented using document processing chain technology, with retry limits and an exponential backoff algorithm. Multi-level cleanup is performed on the model output, including removing thought process tags using regular expressions, and performing blank line compression and first-line indentation formatting.
[0013] Automated population of S7 legal document templates: Regular expressions are used to identify various placeholders in the document. Hierarchical document traversal is implemented to process the main text, headers and footers, tables, and all paragraphs within tables. First, placeholder integrity is checked, then simple field replacements are performed sequentially, and legal document format standards are uniformly applied. Dynamic copying of template rows is used to populate data row by row in circular table areas. Intelligent style inheritance and automatic numbering are implemented for numbered lists. For multi-paragraph content, the paragraph XML structure is cloned to enable flexible insertion of text and images, with image processing including adaptive scaling and alignment settings based on page size.
[0014] Preferably, S1 further includes:
[0015] S1.1 Browser Location: To locate the browser executable file, the system first searches for it in environment variables by executing system commands, and sets timeout controls and file verification rules. If the command execution fails, the system queries the registry in Windows, the App manifest in macOS, and the standard installation directory in Linux. If none of the above steps succeed, a fallback search is performed using a preset path library covering multiple operating systems to ensure reliable location.
[0016] S1.2 HTML File Search: After successfully obtaining the browser path, a recursive file search is initiated in the target directory. A depth-first search is adopted with a maximum search depth set. HTML files are filtered based on file extensions and directory exclusion rules. The file content is also verified for structural integrity and keywords to identify the target document.
[0017] S1.3 Page Rendering: Create a headless browser instance, configure rendering parameters including window size and security options, load the HTML file identified in S1.2, and ensure the page is fully loaded by monitoring DOM state, network idle time, and implementing multiple rounds of retry loading.
[0018] S1.4 Region Positioning: In the rendered page, candidate elements are identified based on the preset CSS selector priority, and each element is verified for geometric attributes including area, aspect ratio, visibility ratio and content density to intelligently determine the screenshot area that meets the requirements, and the final range is calculated by applying safety margin.
[0019] S1.5 Image Output: Capture the image of the area determined in S1.4, save the file with preset image format, quality parameters and naming rules, and store it in the same directory as the source HTML file.
[0020] Throughout steps S1.1 to S1.5, timeout control and resource monitoring are implemented for critical operation nodes. In case of failure, a multi-level recovery strategy is activated. This strategy includes automatically switching to a backup rendering engine when browser detection fails, enabling recursive search and extension fallback when file lookup fails, implementing multiple retries when page loading fails, and a fallback scheme that sequentially falls back to full-page capture or viewport capture when screenshotting fails. Simultaneously, the output image file's size, dimensions, and content quality are verified, and complete metadata, including hash values, timestamps, and system environment information, is recorded to form a tamper-proof chain of evidence.
[0021] Preferably, S2 further includes:
[0022] S2.1 Directory Traversal Initialization: Verify the accessibility of the received root directory path, use recursive traversal, set the maximum recursion depth to 10 levels, and automatically skip preset system directories and cache folders.
[0023] S2.2 File Identification and Filtering: Target files are located through a triple mechanism of filename prefix matching, extension verification, and content feature detection. Target files include raw data files, device information files, and authorization documents. The filename prefix matching uses a prefix tree structure, performing case-insensitive multi-pattern matching based on a predefined set of key prefixes. Extension verification validates file types based on a predefined set of file formats, setting independent size verification thresholds for different file types. Content feature detection is implemented through lightweight content preview verification, including reading specific bytes from the file header to verify the file signature and basic structural integrity. Specifically, for JSON files, it verifies their basic JSON syntax structure; for HTML files, it verifies whether they contain complete `html` and `body` tags; and for image files, it verifies their file header identifier.
[0024] S2.3 Content Processing and Metadata Extraction: By parsing the directory structure features and file naming conventions, key metadata such as case number, timestamp, and device identifier are automatically extracted from the standardized file naming pattern, and a mapping relationship between files and cases is established.
[0025] Furthermore, in steps S2.1-S2.3, the process further includes:
[0026] Asynchronous processing and resource control: Node.js asynchronous non-blocking file system operations are adopted, the maximum number of concurrent operations is set to 50, batch processing and file streaming are enabled for large directories, and memory monitoring and automatic garbage collection are implemented.
[0027] Exception Handling and State Persistence: This system categorizes and handles exceptions related to permissions, file corruption, system resources, and network issues. For permission exceptions, it automatically records failed paths and continues processing other accessible files. For text encoding exceptions, it attempts to read files using multiple encoding formats. For file corruption exceptions, it records corruption information and skips the file. For system resource exceptions, it triggers automatic degradation and reduces the number of concurrent operations. For network exceptions, it employs a maximum of 3 retries with an exponential backoff algorithm. An integrated state persistence mechanism periodically encrypts and saves processing progress, a list of discovered files, and exception records to a temporary state file, supporting recovery from interruptions. A performance monitoring component is included to collect and display key metrics such as directory traversal speed, file recognition accuracy, and memory usage efficiency in real time. A single directory processing timeout threshold is set to 30 seconds; if the timeout expires, the process is automatically skipped and the exception is recorded.
[0028] Quality verification and audit log synchronization: The selected files are verified for integrity, consistency and relevance, and the SHA-256 and MD5 dual hash values are calculated to generate structured audit logs containing timestamps, operation types, file paths and exception information.
[0029] Cross-platform compatibility: Automatically adapts path separators, file permission models, and file system characteristics for the three major operating systems: Windows, macOS, and Linux.
[0030] Preferably, S3 further includes:
[0031] S3.1 Document Loading and Parsing: The system automatically selects the appropriate document loader based on the file extension. For PDF files, PyPDFLoader is used for text parsing; for Word documents, Unstructured Word DocumentLoader is used for structured parsing; and for image files, Unstructured Image Loader, which integrates OCR technology, is used for text recognition. If the primary loader fails, it automatically switches to a backup loader. For PDF files, PyPDF2 is used for page-by-page parsing, and for Word documents, the python-docx library is used for content extraction.
[0032] S3.2 Intelligent Content Filtering: Based on a predefined key field dictionary, target paragraphs are identified, and multi-channel matching, partial matching, and synonym matching are used. Blank lines and placeholders are filtered for the identified paragraphs.
[0033] S3.3 Large Model Information Extraction: Using the locally deployed Ollam platform as the large model processing engine, the specified context window and generation length parameters are configured. Key field content is extracted through preset prompt templates, and the three principles of extracting only explicit content from the document, omitting null fields, and limiting the output range are followed.
[0034] S3.4 Response Processing and Verification: A multi-level JSON parsing mechanism is used to process the model response. When direct parsing fails, regular expressions are used for secondary parsing, and the parsing results are verified for content authenticity, and fields containing system-inferred content are deleted.
[0035] Preferably, S4 further specifically includes:
[0036] S4.1 JSON Format Repair: Intelligently repairs non-standard JSON data using regular expressions, including: identifying and removing predefined JS variable declarations and global object assignment statements; detecting and removing trailing commas in the JSON structure; and automatically adding missing parentheses to restore structural integrity when the imbalance exceeds 10%.
[0037] S4.2 Backup Parsing: When the data still cannot be parsed after repair, a backup parsing scheme is activated, including: extracting JSON objects or array fragments using nested regular expressions; constructing a fragment association graph based on key identifiers; and reorganizing the fragments into a syntactically valid JSON structure based on the association graph.
[0038] S4.3 Tree Structure Construction: Construct a global ID-node mapping table, generate a unique identifier for each node through recursive traversal, and establish a mapping relationship between node content and identifier.
[0039] S4.4 Differentiated Depth Processing: Differentiated depth processing is performed based on a pre-configured depth control dictionary. The dictionary sets the maximum processing depth, processing priority, and a list of fields that must be extracted for different types of nodes. During the processing, the recursion depth and extraction range are controlled according to the node type.
[0040] In the S4.1-S4.4 process, several performance optimization and fault tolerance mechanisms are also set, including: setting memory usage thresholds and node number limits, initiating block processing or memory cleanup when approaching the limit, and implementing retry steps and measures to retain and return successfully processed data during the parsing process to ensure the robustness of the processing flow.
[0041] Preferably, S5 further includes:
[0042] S5.1 Generate a summary of the data information: Starting from the root node of the data tree, a recursive traversal algorithm is used to extract the total number of data entries and recover the number of data entries, generating a standardized summary paragraph.
[0043] S5.2 Classification Data Processing: Prioritize the processing of classification data branches through depth-first traversal, extract the statistical value of the node, and recursively traverse all child nodes to construct a complete enumeration list of classification data.
[0044] S5.3 Application Data Processing: A differentiated depth control strategy is adopted for application data branches to construct an overall statistical description of the application data. Different depths of processing are implemented for different types of application data, with ordinary application data processed to the second-level sub-nodes and social communication data nested at the fifth-level structure. A detailed account-level description paragraph is generated for each social application account in the social communication data.
[0045] S5.4 Text Generation and Integration: During text generation, the output format is dynamically selected based on the existence of the recovered data entries. A simplified format is used when the number of recovered data entries is zero, and a full format is used when the number of recovered data entries is greater than zero. All generated text paragraphs uniformly adhere to the language norms and format requirements of forensic identification documents.
[0046] Preferably, S6 further includes:
[0047] S6.1 Model Configuration and Input Processing: Configure the locally deployed large language model as the processing engine, set the timeout setting, context window, and maximum generation length, encapsulate the raw device information text into standardized document objects, and establish a structured data representation.
[0048] S6.2 Prompt Engineering and Template Design: Construct a prompt template specifically for device information extraction. The template includes three core parts: task requirements, standard output format examples, and placeholders for raw text content.
[0049] S6.3 Reasoning and Result Processing: This section utilizes document processing chain technology to combine the initialized large language model with prompt templates, constructing an end-to-end analysis pipeline. The maximum number of retries is set to 3, with an exponential backoff algorithm used for the retry interval. Multi-level cleaning is performed on the model output, using regular expressions to remove tags and their content generated during the model's thought process. The cleaned text is then formatted, including compressing consecutive blank lines and sequences of whitespace characters into a single newline character, and adding a two-character first-line indent to non-blank lines.
[0050] Preferably, S7 further includes:
[0051] S7.1 Template Loading and Placeholder Recognition: Recognizes various placeholders in the document using predefined regular expression patterns, including simple fields, list loops, numbered lists, and mixed content with multiple paragraphs and images. Implements a hierarchical document traversal mechanism, processing all paragraphs in the document body, headers and footers, tables, and nested tables sequentially.
[0052] S7.2 Placeholder Integrity Check: Performs a placeholder integrity check, detects placeholders that are broken due to style splitting, and automatically merges them.
[0053] S7.3 Simple Field Replacement: The replacement operation is performed in a specific order. First, the direct replacement of simple fields is processed. Placeholder text is replaced while maintaining the original format, and the unified judicial document format specification is applied.
[0054] S7.4 Table Loop Processing: For looped areas in a table, identify loop markers and use dynamic template row copying technology to fill in the content row by row according to the data list.
[0055] S7.5 Numbered List Processing: Inherit paragraph attributes by cloning the XML structure of placeholder paragraphs and automatically detect and apply numbering styles.
[0056] S7.6 Multi-Paragraph Content Processing: Flexible insertion of text and images is achieved by cloning the paragraph XML structure, where image processing includes adaptive scaling and alignment settings based on page size.
[0057] On the other hand, a fully intelligent system for generating forensic documents includes an original report screenshot sampling module, a file filtering module, an authorized document intelligent parsing module, a data extraction and structuring module, a forensic report generation module, an equipment information analysis module, and a forensic document filling module. The system includes these modules to execute steps S1-S7 of a fully intelligent method for generating forensic documents.
[0058] in:
[0059] The original report screenshot sampling module is used to execute the original report screenshot sampling method for legal documents, including browser positioning, HTML file search, page rendering, region positioning, and image output.
[0060] The file filtering module is used to execute file filtering methods, including directory traversal initialization, file identification and filtering, content processing and metadata extraction.
[0061] The authorized document intelligent parsing module is used to execute the authorized document intelligent parsing and information extraction method, including document loading and parsing, intelligent content filtering, large model information extraction, and response processing and verification.
[0062] The data extraction and structuring module is used to execute data extraction and structuring methods, including JSON format repair, backup parsing, tree structure construction, and differential deep processing.
[0063] The forensic report generation module is used to execute methods for generating forensic documents, including generating a summary of data information, classifying data processing, applying data processing, and generating and integrating text.
[0064] The device information analysis module is used to execute an automated device parameter parsing method based on a large language model, including model configuration and input processing, prompting engineering and template design, reasoning and result processing.
[0065] The judicial document filling module is used to execute an automated filling method for judicial document templates, including template loading and placeholder recognition, placeholder integrity check, simple field replacement, table loop processing, numbered list processing, and processing of multi-paragraph content.
[0066] In summary, due to the adoption of the above technical solution, the beneficial effects of the present invention are:
[0067] 1. Simplify data processing workflow: Enable automatic uploading and key data extraction of information such as appraisal entrustment forms and evidence collection reports, replacing repetitive manual data entry operations and shortening the data processing cycle.
[0068] 2. Improve document editing quality: The automatic correction function standardizes document format, reduces font, line spacing, page number abnormalities and text description errors, and lowers the error rate of the appraisal report.
[0069] 3. Ensure data security and controllability: Relying on AI localization deployment technology, ensure that all identification data flows securely within the enterprise, eliminate the risk of leakage during external transmission, and meet industry data privacy protection requirements.
[0070] 4. Meet personalized needs: The data dictionary function supports the custom uploading of laws, regulations, and technical specifications, as well as the flexible design of report formats, to adapt to the usage scenarios of different appraisal units and industries.
[0071] 5. Assist professional decision-making: With the help of AI assistant functions, staff can quickly find answers to questions about relevant laws and regulations, opinions and requirements, and technical implementation, thereby improving work efficiency and the accuracy of professional judgment. Attached Figure Description
[0072] Figure 1 This is a flowchart illustrating the intelligent generation method for the entire process of authentication documents according to the present invention.
[0073] Figure 2 This is a schematic diagram of process S1 in the intelligent generation method for the entire process of identification documents of the present invention.
[0074] Figure 3 This is a schematic diagram of the S2 process in the intelligent generation method for the entire process of identification documents of the present invention.
[0075] Figure 4 This is a schematic diagram of the S3 process in the intelligent generation method for the entire process of identification documents of the present invention.
[0076] Figure 5 This is a schematic diagram of the S4 process in the intelligent generation method for the entire process of identification documents of the present invention.
[0077] Figure 6 This is a schematic diagram of the S5 process in the intelligent generation method for the entire process of identification documents of the present invention.
[0078] Figure 7 This is a schematic diagram of process S6 in the intelligent generation method for the entire process of identification documents of the present invention.
[0079] Figure 8 This is a schematic diagram of process S7 in the intelligent generation method for the entire process of identification documents of the present invention.
[0080] Figure 9 This is a schematic diagram illustrating the relationships within the intelligent generation system for the entire process of authentication documents according to the present invention. Detailed Implementation
[0081] The embodiments further illustrate the intelligent generation system and method for the entire process of authentication documents proposed in this invention.
[0082] On the one hand, this embodiment provides a method for intelligent generation of authentication documents throughout the entire process, including:
[0083] S1. Screenshot of the original report of the legal document.
[0084] Its schematic diagram is as follows Figure 2 As shown.
[0085] S1.1 Browser Location: First, it quickly locates the browser executable file in the environment variables by executing the standard path lookup command of the current operating system (e.g., the `where` command in Windows, and the `which` command in macOS and Linux). A 5-second timeout is set to prevent command blocking. Simultaneously, it verifies the file's existence and executable permissions, requiring the file size to be at least 1KB and that it is an executable file (e.g., a .exe file in Windows, or an executable file in macOS and Linux). When command-level probing fails, a platform-specific backup location mechanism is activated.
[0086] On Windows systems, a registry query mechanism is initiated, accessing browser installation information under HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER according to a preset registry path priority order. The standard reg query command template is used to obtain the precise installation path, and accessibility verification is performed on each path.
[0087] On macOS, the browser application is located by querying the Launch Services database and checking standard application directories (such as / Applications, ~ / Applications). On Linux, the browser executable file is located by querying the desktop file database and checking standard binary directories (such as / usr / bin, / usr / local / bin). If the first two levels of probing fail, a fallback search using a preset path library is employed. Detailed sets of default browser installation paths are configured for Windows, macOS, and Linux platforms to ensure reliable location of the browser executable file in various system environments.
[0088] S1.2 HTML File Search: After successfully obtaining the browser path, a recursive HTML file search engine is launched. A depth-first search algorithm is used to traverse the target directory, with a maximum search depth of 10 levels. Files with the .html and .htm extensions are prioritized, while system directories such as node_modules and .git, as well as temporary files, are excluded. Strict content verification is implemented during file recognition, requiring HTML files to be at least 100 bytes in size and contain a complete html and body tag structure. Simultaneously, unique keywords specific to case reports are detected, including Chinese and English words such as "case," "report," and "appraisal," to ensure the location of valid case report documents.
[0089] S1.3 Page Rendering: Upon entering the rendering phase, an Electron headless browser window is created, configured with a hidden window size of 1200x800, and the interface display and window borders are completely disabled. `webSecurity` is set to `false` to allow loading local files, while `nodeIntegration` is disabled and `contextIsolation` is enabled to ensure security. A precise control strategy is implemented during page loading, setting a 30-second timeout limit. After the DOM is ready, a 3-second wait is allowed to ensure rendering is complete. Simultaneously, the page is considered fully loaded after 2 seconds of network idle time. A multi-round retry mechanism is employed, with a maximum of 3 retries, each 1 second apart, to ensure successful loading even in unstable network environments.
[0090] S1.4 Region Positioning: For screenshot region positioning, an intelligent element recognition algorithm is implemented. CSS selectors are configured according to a four-level priority system: first, professional case navigation components like `div.pnfa-nav` are identified; second, tree structures such as `ul.ztree` are searched; third, standard navigation elements such as the `nav` tag are located; and finally, scrolling container elements are identified. Each candidate element undergoes rigorous geometric verification, requiring an element area of no less than 10,000 pixels, an aspect ratio between 0.2 and 5, a visible proportion within the viewport exceeding 30%, and a content density threshold set to 0.1 to avoid cropping blank areas. The region calculation engine employs a safe margin strategy, preserving a 10-pixel horizontal and 5-pixel vertical buffer area, while limiting the maximum screenshot size to 1200x800 pixels to ensure that the screenshot content is both complete and not too large.
[0091] S1.5 Image Output: This stage uses PNG format for saving, with compression quality set to 90, sRGB color space, and file naming following the "navigation_" prefix plus a timestamp to ensure unique and traceable filenames. Output files are stored in the same directory as the source HTML files, with file permissions set to 644. Quality verification involves multiple checks, requiring screenshot file sizes to be no less than 1KB, image dimensions to be at least 50x50 pixels, and verifying file header integrity. The image must show that solid color areas do not exceed 95%, text contrast is above 3.0, and the proportion of valid information areas is no less than 10%, fully meeting the quality requirements for judicial evidence.
[0092] To ensure normal operation during the above process, this embodiment establishes a multi-level recovery strategy in terms of fault tolerance: when the browser fails to find a file, it automatically switches to the Electron built-in rendering engine; when the HTML file fails to find a file, it enables recursive searching and supports extension fallback; when the page loads fail, it performs three retries and tries multiple loading protocols; and when the screenshot fails, it sequentially falls back to fallback solutions such as full-page capture, viewport capture, and selector element capture. Performance monitoring sets strict threshold limits: browser probing does not exceed 5 seconds, file searching does not exceed 10 seconds, page loading does not exceed 30 seconds, and screenshot operations do not exceed 10 seconds. Simultaneously, it monitors memory usage not exceeding 512MB and CPU usage not exceeding 80%, ensuring stable system operation.
[0093] Finally, to meet the requirements for the integrity of judicial evidence, a comprehensive evidence chain maintenance mechanism is implemented. SHA256 and MD5 hash values are calculated for the output files and recorded in the metadata. Simultaneously, complete metadata such as screenshot timestamps, source file information, system environment parameters, and rendering configurations are also recorded. Anti-tampering measures include a write-once-read-many storage strategy and a checksum verification mechanism to ensure the originality and integrity of the screenshot evidence, providing a reliable and credible original report sampling basis for subsequent legal document generation.
[0094] S2. Collection of original data for legal documents.
[0095] Its schematic diagram is as follows Figure 3 As shown.
[0096] S2.1 Directory Traversal Initialization: First, it receives the root directory path of the case report specified by the user as an input parameter. The path verification mechanism ensures that the directory exists and is accessible. The maximum recursion depth is set to 10 levels to prevent infinite loops. At the same time, an exclusion directory pattern library is established to automatically skip system directories such as node_modules, .git, temp, and cache folders to avoid interference from irrelevant files.
[0097] S2.2 File Recognition and Filtering: It incorporates a multi-level file recognition strategy, employing a triple mechanism of filename pattern matching, extension verification, and content feature detection to ensure accurate location of target files (including raw data files, device information files, and authorization documents). Core recognition rules include filename prefix matching, prioritizing key data files prefixed with "data_navigation", "data_package_profile", or "navigation". These files contain the core structured data of the case. The matching algorithm uses a prefix tree structure, supporting simultaneous matching of multiple target patterns. The matching process is case-insensitive to ensure cross-platform compatibility. It verifies the extensions of identified target files, supporting multiple formats such as JSON data files (.json), HTML report files (.html, .htm), image evidence files (.png, .jpg, .jpeg), and text record files (.txt). Each file type has an independent size verification threshold: JSON files are limited to a maximum of 10MB, and image files to a maximum of 20MB, preventing memory overflow when processing abnormally large files. For critical data files, a lightweight content preview verification is implemented. This involves reading specific bytes from the file header to detect the file signature and basic structural integrity. For JSON files, the verification checks whether they conform to the basic JSON syntax structure. For HTML files, the verification checks whether they contain complete html and body tags. For image files, the verification checks their file header identifiers to ensure that the files are not corrupted.
[0098] S2.3 Content Processing and Metadata Extraction: Integrates automatic case metadata extraction function, intelligently infers basic case information by parsing directory structure features and file naming conventions, and can extract key metadata such as case number, timestamp, and device identifier from standardized file naming patterns, establish the association mapping relationship between files and cases, and perform fast content scanning for JSON data files containing standardized prefixes to extract the case identifier field inside the file and construct a complete case file relationship graph.
[0099] During steps S2.1-S2.3, this embodiment implements the following strategy to control quality:
[0100] Asynchronous Processing and Resource Control: Leveraging the advantages of Node.js's event-driven architecture, a fully asynchronous, non-blocking file system operation is employed. During recursive traversal, each subdirectory read operation is encapsulated as an independent Promise object. The `async / await` syntax achieves synchronous code style while maintaining asynchronous execution characteristics. A maximum of 50 concurrent file operations is set to avoid file descriptor exhaustion while maintaining high performance. For large-scale case data directories, a batch processing mechanism is implemented, with a maximum of 1000 files processed at a time. When this limit is exceeded, pagination is automatically enabled. File content reading uses a streaming approach, and for large files exceeding 1MB, a block reading mechanism is automatically enabled to avoid memory spikes caused by loading large files at once. Memory usage is monitored in real time, and garbage collection is automatically triggered and new task processing is paused when memory usage exceeds a preset threshold.
[0101] Exception Handling and State Persistence: A comprehensive exception classification and handling system is established, categorizing potential exceptions into four main types: permission exceptions, file corruption exceptions, system resource exceptions, and network exceptions. For permission exceptions, the system automatically records the failed path and continues processing other accessible files. For text encoding exceptions, it attempts to read files using multiple encoding formats. For file corruption exceptions, it records the corruption information and skips the file. For resource exceptions, it triggers an automatic degradation strategy to reduce the number of concurrent operations. For network exceptions, a retry mechanism is designed for network storage scenarios, with a maximum of 3 retries and an exponential backoff algorithm for the retry interval. Simultaneously, a processing state persistence mechanism is integrated, periodically saving the current processing progress, the list of discovered files, and exception records to a temporary state file. When processing is restarted or unexpectedly interrupted, it can resume from the most recent state point, avoiding repeated scanning of processed directories. The state file is stored encrypted to ensure data security, and the temporary file is automatically cleaned up after processing is complete. The system has a built-in performance monitoring component that collects key indicators such as directory traversal speed, file recognition accuracy, and memory usage efficiency in real time. The monitoring data is displayed in real time through a visual console and recorded in the system log for subsequent performance analysis and optimization. A processing timeout threshold can be set, with a maximum processing time of 30 seconds for a single directory. If the timeout occurs, the system will automatically skip the process and record the exception.
[0102] Quality verification and audit log synchronization: For selected target files, multi-level quality verification is implemented. Integrity verification ensures that the files are not truncated or damaged; consistency verification checks whether the internal data structure of the files conforms to the expected format; and relevance verification ensures that the file content is substantially related to the current case. The quality score generated during the verification process serves as an important reference for subsequent processing priorities. A dual SHA-256 and MD5 hash value is calculated for each identified case file to establish a file digital fingerprint database. The hash calculation process is performed synchronously during file reading, ensuring efficiency while providing a basis for integrity verification. All file hash values are saved along with the case metadata, providing an immutable chain of evidence for subsequent judicial proceedings. The system generates detailed operation audit logs, fully recording the decision-making process for file selection, details of anomaly handling, and system status changes. The logs are stored in a structured format, including standard fields such as timestamps, operation types, file paths, processing results, and anomaly information, meeting the integrity and traceability requirements of judicial review.
[0103] Cross-platform adaptation: Deeply optimized for Windows, macOS, and Linux operating systems, it automatically adapts to different platform path separators, file permissions, and performance characteristics. On Windows, it specifically handles the characteristics of the NTFS file system, while on Linux and macOS, it optimizes the traversal performance of EXT4 and APFS file systems. It automatically detects the operating environment and enables corresponding optimization strategies to ensure stable performance and reliability across different operating systems. Through this refined technical design, the file filter achieves efficient, accurate, and reliable screening of case data files in complex forensic scenarios, providing a high-quality raw data foundation for subsequent intelligent analysis and report generation, while fully meeting the normative and security requirements of judicial evidence processing.
[0104] S3. Intelligent parsing and information extraction of various authorized documents.
[0105] Its schematic diagram is as follows Figure 4 As shown.
[0106] S3.1 Document Loading and Parsing: First, the corresponding document loader is automatically selected through a file extension recognition mechanism. For PDF files, PyPDFLoader is used for deep text content parsing. This loader can accurately extract text layout and formatting information from PDF documents, supports decryption of encrypted PDF files, and sets the text extraction encoding to UTF-8 to ensure complete recognition of Chinese characters. For Word documents, Unstructured Word Document Loader is used for structured parsing. This loader can recognize complex elements such as paragraphs, tables, headers, and footers in the document, extracting clean text content while maintaining the original hierarchical structure of the document. For image files, UnstructuredImageLoader, which integrates OCR technology, is used for text recognition. It supports multiple image formats such as PNG, JPG, JPEG, BMP, and TIFF. The OCR engine is configured with a Chinese language pack priority recognition strategy, and the text recognition accuracy threshold is set to 85%. Image areas below this threshold will trigger a secondary recognition process.
[0107] When the primary loader fails due to file corruption, formatting issues, or permission problems, it automatically switches to a backup loader system, establishing a complete fault tolerance mechanism. For PDF files, the backup parser uses the PyPDF2 library for re-parsing. This backup solution can handle partially corrupted PDF files, extracting text content through page-by-page scanning, with a maximum page processing limit of 500 pages; exceeding this limit automatically enables chunked processing. For Word documents, the backup parser uses the python-docx library for deep reading of document content, extracting not only paragraph text but also specifically parsing table structures, converting table content into structured text representations while maintaining the integrity of row and column relationships. The backup loader implements a strict exception handling mechanism, classifying and handling various parsing exceptions to ensure that the basic text content can still be returned even in extreme cases.
[0108] S3.2 Intelligent Content Filtering: After successfully extracting the document text content, the intelligent content filtering engine is activated to identify target paragraphs based on a predefined key field dictionary. This embodiment sets the key field dictionary to include six core judicial appraisal fields: "Case Name," "Case Number," "Client," "Handler," "Entrusted Appraisal Matters," and "Basic Case Facts Related to the Appraisal." Each field is configured with independent matching rules and contextual extraction ranges. The recognition algorithm employs a multi-channel matching strategy, supporting three modes: full-field matching, partial matching, and synonym matching, ensuring accurate capture of target information across different document formats. For identified key field paragraphs, a strict blank line and placeholder filtering mechanism is implemented, automatically removing paragraphs containing only invalid content such as underscores, spaces, and tabs. A content validity verification threshold is set, requiring the actual text length of the paragraph to be no less than 5 characters and to contain at least one Chinese character.
[0109] S3.3 Large Model Information Extraction: The information extraction phase utilizes a locally deployed Ollam platform as the large model processing engine, configured based on the Qwen3:8B architecture. The base connection address is set to the local large model, and the request timeout is set to 1000 seconds to handle large-scale document processing. The context window size is configured to 5120 tokens, and the maximum generated length is 2048 tokens, ensuring stable performance when processing long documents. The prompt template design employs strict field mapping rules, clearly defining the mapping relationship between six target fields and corresponding Chinese tags in the document. A three-tiered extraction principle is established: First, only explicitly stated content in the document is extracted, prohibiting any inferences or guesses. Second, a complete omission strategy is implemented for null fields, ensuring that no null or placeholder fields are included in the JSON output. Third, the range of output fields is strictly limited, including only the six predefined key fields to avoid extracting irrelevant information.
[0110] S3.4 Response Processing and Verification: Response processing employs a multi-level JSON parsing mechanism. It first attempts to directly parse the returned JSON content. If parsing fails, a regular expression backup solution is used to extract JSON-compliant fragments from the response text for secondary parsing. Post-parsing verification checks are performed on the parsing results, verifying the authenticity of fields. If a field is detected to contain system-inferred content instead of extracted original text, the field is automatically deleted to ensure the accuracy and reliability of the output data. A complete audit log system is established throughout the entire process, recording detailed information from document loading and content extraction to inference.
[0111] S4. Data extraction and structuring.
[0112] Its schematic diagram is as follows Figure 5 As shown.
[0113] S4.1 JSON Format Repair: This section performs deep repair and normalization of non-standard JSON formats commonly found in the source data. The process begins by activating a regular expression-based intelligent repair engine. This engine embeds a multi-level rule base to perform serialization processing for different types of formatting errors. Its primary task is to clean up the data environment by thoroughly stripping away non-data content through predefined JS variable declaration recognition patterns (e.g., precisely matching strings that begin with "var", "let", or "const", followed by a variable name and an equals sign, as well as global object assignment statements such as "window." and "exports."). Next, the engine handles JSON structure-level errors: it uses trailing comma detection patterns (such as recognizing commas before closing parentheses or curly braces) and removes them. Meanwhile, it has a built-in real-time bracket balance counter. By scanning the entire text string, it calculates the difference in the number of opening brackets '{', '[' and closing brackets '}', ']'. When a mismatch is detected and the balance threshold is reached (in this embodiment, the imbalance ratio is taken as exceeding 10%, i.e., |number of opening brackets - number of closing brackets| / total number of brackets > 10%), a stack-based bracket matching algorithm is used to locate and complete the structural error and intelligently complete the missing brackets at the end of the string to ensure structural integrity.
[0114] S4.2 Backup Parsing: When the initially repaired data still fails to pass standard JSON parsers (such as Python's json.loads), it seamlessly switches to its innovative backup parsing scheme. The core of this scheme lies in its fragmented extraction and intelligent reorganization capabilities. Instead of emphasizing the correctness of the overall structure, it uses a set of complex regular expressions capable of recognizing nested structures (e.g., matching content within pairs of curly braces or square brackets starting from the innermost layer and expanding outwards) to accurately extract all potential JSON objects or array fragments from the invalid text stream. Subsequently, a relational analyzer is launched to extract key identifiers from these fragments (common field names such as "id", "name", and "children") and constructs a fragment relationship graph based on the recurrence and nesting relationships of these identifiers. Finally, the reorganization algorithm uses this graph to re-embed fragments with parent-child or sibling relationships into the correct positions within the main structure, thereby constructing a syntactically valid and structurally sound JSON object.
[0115] S4.3 Tree Structure Construction: After obtaining a valid JSON structure, the tree structure construction phase begins. This phase creates a global mapping table of IDs to nodes for fast lookup. The original data is recursively traversed, generating a globally unique identifier for each node (regardless of its level), and mapping this identifier to all the node's content (including its parent node reference, list of child nodes, node type, and original data value). This mapping table forms the skeleton and navigation graph of the entire data tree, enabling any subsequent node access operations to be completed in constant time.
[0116] S4.4 Differentiated Depth Processing: Building upon the steps described above, this section implements its most distinctive differentiated depth processing strategy. This strategy is driven by a highly configurable "depth control dictionary," which predefines precise processing depths, priorities, and lists of fields that must be extracted for different types of nodes. For the "Phone Information" node, the dictionary specifies a maximum processing depth of 2 levels, a "high" priority, and requires the extraction of fields such as ["Brand", "Model", "Serial Number"]. This means that when traversing this type of node, only its direct child and grandchild nodes are processed. Once the depth limit is reached, further expansion of the branch stops, thus avoiding excessive computational resources spent on basic information. Conversely, for the "Social Communication" node, the dictionary specifies a maximum processing depth of 5 levels, a "critical" priority, and requires the extraction of fields such as ["Application Name", "Account Information", "Friend List", "Chat History", "Media Files"]. When dealing with such nodes, the recursive algorithm continues to explore downwards until it reaches the fifth level, thereby uncovering hidden dialogue details, attachment information, and even metadata—evidence chain information that is crucial for forensic identification.
[0117] Throughout this step's processing flow, this embodiment also incorporates multiple performance optimizations and fault tolerance mechanisms. This embodiment sets a memory usage threshold (100MB) and a maximum number of nodes processed per cycle (100,000). When these limits are approached, block processing or memory cleanup is initiated. During parsing and construction, any exception thrown at any step triggers a retry mechanism (3 retries by default, each with a 0.1-second interval), and a detailed error log is recorded. If the process ultimately fails, a degradation processing scheme is executed to preserve and return as much of the successfully processed data as possible. Through these meticulous technical logics, parameter adjustments, and rule designs, highly robust, efficient, and intelligent structured transformations of complex and chaotic raw data are achieved, laying a solid data foundation for subsequent cleaning, analysis, and report generation. Data Cleaning and Transformation: Data filtering and transformation based on recursive tree traversal. First, regular expressions are used to extract the JSON array portion from the original content, and then a complete node mapping relationship is constructed. During the transformation process, a depth-first recursive strategy is used to traverse each node, determining the processing depth based on the branch type of the node: ordinary data branches are processed up to level 2, and other branches are processed up to level 5. The algorithm automatically skips empty nodes with a value of 0 and converts the original data structure into a standardized tree format. During the conversion process, field remapping is also performed to make field names more consistent with business semantics.
[0118] S5. Generate the content of the forensic identification document.
[0119] Its schematic diagram is as follows Figure 6 As shown.
[0120] S5.1 Data Summary Generation: A recursive traversal algorithm is used to expand the data tree layer by layer from the root node, generating a natural language description that conforms to legal norms according to the standardized structure of judicial appraisal documents. First, overall statistical data at the device level (mobile phone, computer, hard drive) is extracted from the root node, including two core indicators: the total number of data entries and the number of recovered data entries. A standardized device summary paragraph is generated using an intelligent splicing algorithm, formatted as "Upon inspection, X data entries were extracted from the electronic device involved in the case, of which Y data entries were recovered." Simultaneously, blank line separators conforming to judicial document norms are automatically inserted to ensure the clarity of the document structure.
[0121] S5.2 Categorical Data Processing: When processing the data structure, a depth-first traversal strategy is implemented, handling the two main branches: categorical data and application data. For the categorical data branch, the total number of data entries and the number of recovered data entries are first extracted. Then, all child nodes are recursively traversed to construct a complete categorical data enumeration list. An intelligent format selection mechanism is used during enumeration. When the number of recovered data entries is greater than zero, the full format "Data Name X entries (Recovered Y entries)" is automatically enabled; otherwise, the simplified format "Data Name X entries" is used. Enumeration items are connected using Chinese commas, ultimately forming an enumeration string that conforms to Chinese grammar conventions. This string is then combined with the parent node's statistical information to form a complete categorical data description paragraph.
[0122] S5.3 Application Data Processing: The processing of application data branches adopts a differentiated depth control strategy. First, an overall statistical description of the application data is constructed, and then different depths of mining are implemented for different types of application data. For ordinary application data, only the second-level child nodes are processed to generate a brief application type enumeration. For social communication data, however, the mining goes deeper to the fifth-level structure, describing in detail the data composition of each social account. The processing of social communication data adopts account-level refined analysis, generating a separate descriptive paragraph for each account in each social application, in the format of "Application Name Account Nickname: Account Name contains X data entries (restores Y entries), with specific data type statistics."
[0123] S5.4 Text Generation and Integration: During text generation, an intelligent output format selection mechanism is implemented, dynamically adjusting the output template based on the existence of the recovered data entries. When the number of recovered data entries is zero, a simplified output format is used, omitting relevant descriptions of the recovered data. When the number of recovered data entries is greater than zero, the full output format is automatically enabled, clearly indicating the number of recovered data entries. All generated text paragraphs strictly adhere to the language norms of forensic identification documents, using professional and accurate legal terminology, avoiding colloquial expressions, while ensuring the completeness and accuracy of data descriptions. An anomaly handling mechanism is also integrated to gracefully handle anomalies such as data format errors and missing fields, ensuring that usable report content can still be generated even when some data is abnormal.
[0124] S6 is based on the automatic parsing of device parameters using a large language model.
[0125] Its schematic diagram is as follows Figure 7 As shown.
[0126] S6.1 Model Configuration and Input Processing: The locally deployed Ollam platform is used as the large model processing engine, configured based on the Qwen3:8B architecture. The base connection address is set to the local large model address, and the request timeout is set to 1000 seconds to handle large-scale text processing needs. The context window size is configured to 5120 tokens, and the maximum generated length is 2048 tokens, ensuring stable performance when processing complex device information. The raw device information text is encapsulated into LangChain Document objects, establishing a standardized text representation format to provide a structured data foundation for subsequent intelligent analysis.
[0127] S6.2 Prompt Engineering and Template Design: The prompt engineering adopts an example-driven design concept, meticulously constructing prompt templates specifically for equipment information extraction. The template structure comprises three core parts: clear task requirements, standard output format examples, and raw text content. The task requirements clearly instruct the model to extract data as needed and output it as natural language, implementing an ignore strategy for null values or non-existent content to ensure the standardization and consistency of the model's output. The raw text content is dynamically injected through {context} placeholders to ensure the relevance and accuracy of the analysis process.
[0128] S6.3 Inference and Result Processing: The inference process utilizes LangChain's document processing chain technology, organically combining the initialized large language model with carefully designed prompt templates to construct an end-to-end device information analysis pipeline. The processing chain automatically manages the entire process of document loading, segmentation, and inference, setting a maximum of 3 retries with an exponential backoff algorithm for the retry interval to ensure robustness during network fluctuations or temporary service unavailability. Post-processing of inference results employs a multi-level cleanup mechanism, first using regular expression pattern matching to remove errors that may have occurred during the model's processing. <think>The tag and its entire content, with the regular expression pattern set to r' <think> .*?< / think> The matching flag enables DOTALL to support cross-line matching, ensuring that all traces of intermediate thinking are completely eliminated.
[0129] The cleaned text undergoes formatting, employing a refined adjustment strategy and deep optimization to conform to Chinese document standards. Redundant blank lines are cleaned using regular expression replacement, compressing consecutive blank lines and whitespace sequences into a single newline character, eliminating unnecessary visual gaps. First-line indentation is handled using a line-by-line analysis algorithm, automatically adding two Chinese characters of indentation to non-blank lines to ensure the output text conforms to the formatting standards of Chinese legal documents. A comprehensive quality control system is established throughout the process, performing grammatical correctness and formatting verification on the output text to ensure the generated device description text accurately reflects the original information and meets the linguistic requirements of legal evidence.
[0130] Automatic filling of S7 legal document templates.
[0131] Its schematic diagram is as follows Figure 8 As shown.
[0132] S7.1 Template Loading and Placeholder Recognition: Employing a regular expression recognition mechanism, this system accurately locates various placeholders in the document using the predefined PLACEHOLDER_PATTERN pattern (r"{{([A-Za-z0-9_.]+)}}"), including four main types: simple fields, list loops, numbered lists, and multi-paragraph image content. This embodiment implements a hierarchical document traversal mechanism, using the iter_all_paragraphs function to sequentially process all paragraphs in the document body, chapter headers and footers, tables, and nested tables, ensuring comprehensive coverage of every text area. During the replacement process, it strictly maintains the consistency of the original style while forcibly applying fonts and paragraph formats conforming to legal document standards.
[0133] S7.2 Placeholder Integrity Check: First, load the Word template document and perform a placeholder integrity check. Use the find_split_placeholders function to detect if there are any placeholders that are broken due to style splitting. If a placeholder is found to be split into multiple runs, immediately throw a detailed error message and prompt the user to merge the styles in the Word template to ensure the integrity of the placeholders.
[0134] S7.3 Simple Field Replacement: Replacement operations are strictly executed in a specific order: First, direct replacement of simple fields is processed. The fill_simple_fields function iterates through all paragraphs, and the replace_in_run_text_preserve_format function replaces the placeholder text while maintaining the original format. A uniform font configuration is applied: Chinese font is set to Fangsong, Western font is set to Times New Roman, the font size is uniformly 14 points (size 4), the line spacing is set to 1.5, the spacing before and after paragraphs is 0 points, and the first-line indent is uniformly 1 cm.
[0135] S7.4 Table Loop Processing: For processing table loop regions, the find_repeat_regions function identifies table loop markers that start with "{{#list_name}}" and end with "{{ / list_name}}". It adopts a technique of dynamically copying template rows. The table_clone_row_after function copies the template rows while preserving the row format. Then, it fills in the content row by row according to the provided data list. After the filling is completed, the marked rows are automatically deleted, realizing the dynamic generation of table data.
[0136] S7.5 Numbered List Processing: Employs an intelligent style inheritance mechanism, cloning the XML structure of placeholder paragraphs through the fill_numbered_list function, inheriting paragraph attributes such as wordWrap from the template, and automatically detecting and applying numbering styles in the document. When no available numbering styles are detected, it automatically switches to manual numbering mode to ensure the standardization of list layout.
[0137] S7.6 Multi-Paragraph Content Handling: The `fill_multi_paragraph` function supports flexible insertion of plain text and mixed text / image paragraphs. First, the XML structure of the placeholder paragraph is cloned, inheriting all paragraph attributes from the template. Then, the content is dynamically generated based on the provided multi-paragraph data structure. For paragraphs containing images, intelligent image adaptation is implemented. The original image size is obtained through the PIL library, and the available space is calculated by combining the document page size and margins. A safe scaling factor of 0.98 is set to ensure the image does not exceed the boundaries, while also considering the image DPI information for precise size conversion. The image scaling algorithm employs a dual constraint mechanism: first, a scaling factor is calculated based on the width ratio, and then a secondary check is performed based on the height ratio. The smaller value is taken as the final scaling ratio, ensuring that the image fully adapts to the page space while maintaining its original proportions. For abnormally large images, a mandatory height limit is implemented, with a maximum height not exceeding 12 inches to prevent a single image from occupying too much page space. After image insertion, paragraph center alignment is automatically set, and appropriate pre- and post-paragraph spacing is configured to ensure the aesthetics and standardization of mixed text and images.
[0138] In summary, by tightly integrating a unified document traversal and XML manipulation mechanism, simple field replacements are replaced with more complex ones, eliminating basic placeholders. Table looping and numbered list processing rely on the same paragraph cloning and style inheritance techniques, while multi-paragraph filling utilizes text replacement and image insertion functions. Furthermore, a font enforcement mechanism is integrated, directly manipulating the numbering.xml component of the Word document through the `force_numbering_fonts_in_numbering_part` function to ensure that the font style of the numbered list conforms to judicial document standards. A complete quality control system is established throughout the filling process, using multi-level validation to ensure the formatting standardization and content accuracy of the output document, providing reliable technical support for the automated generation of judicial appraisal documents.
[0139] On the other hand, this embodiment provides an intelligent system for generating authentication documents throughout the entire process, as shown in the schematic diagram below. Figure 9 As shown. Its features include an original report screenshot sampling module, a file filtering module, an authorized document intelligent parsing module, a data extraction and structuring module, a forensic report generation module, an equipment information analysis module, and a forensic document filling module. The system includes the above modules to execute steps S1-S7 of a fully intelligent forensic document generation method.
[0140] in:
[0141] The original report screenshot sampling module is used to execute the original report screenshot sampling method for legal documents, including browser positioning, HTML file search, page rendering, region positioning, and image output.
[0142] The file filtering module is used to execute file filtering methods, including directory traversal initialization, file identification and filtering, content processing and metadata extraction.
[0143] The authorized document intelligent parsing module is used to execute the authorized document intelligent parsing and information extraction method, including document loading and parsing, intelligent content filtering, large model information extraction, and response processing and verification.
[0144] The data extraction and structuring module is used to execute data extraction and structuring methods, including JSON format repair, backup parsing, tree structure construction, and differential deep processing.
[0145] The forensic report generation module is used to execute methods for generating forensic documents, including generating a summary of data information, classifying data processing, applying data processing, and generating and integrating text.
[0146] The device information analysis module is used to execute an automated device parameter parsing method based on a large language model, including model configuration and input processing, prompting engineering and template design, reasoning and result processing.
[0147] The judicial document filling module is used to execute an automated filling method for judicial document templates, including template loading and placeholder recognition, placeholder integrity check, simple field replacement, table loop processing, numbered list processing, and processing of multi-paragraph content.
[0148] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to the embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.< / think>
Claims
1. A method for intelligent generation of authentication documents throughout the entire process, characterized in that, Includes the following steps: S1. Original report screenshot sampling of legal documents: By locating the browser executable file, the target HTML document is recursively searched and verified. Then, a headless browser instance is launched to load the document and ensure that it is fully rendered. Based on preset priority rules and geometric properties, the valid screenshot area in the page is verified and located. Then, the image of the area is captured and the image file that meets the quality standard is output. S2. Raw data collection of legal documents: After receiving the specified case report root directory path and verifying its accessibility, a depth-first search is used for recursive traversal, while setting the maximum recursion depth and excluding system directories and caches. The target file is located through a triple identification mechanism that includes filename prefix matching, extension verification and content feature detection, and the identified file content and case metadata are automatically extracted to establish an association mapping. S3. Intelligent parsing and information extraction of various authorized documents: Automatically selects the corresponding document loader based on the file extension to extract the document text content; automatically switches to a backup loader when the main loader fails; uses a predefined key field dictionary for multi-channel character matching and target paragraph identification, and implements content filtering; uses the locally deployed Ollam platform as the large model processing engine, extracts specified key field content through preset prompt templates, and adheres to the principles of extracting only explicit document content, omitting null fields, and limiting the output range; processes the model response using a multi-level JSON parsing mechanism and verifies the authenticity of the parsing results. S4. Data Extraction and Structuring: Repair and standardize non-standard JSON formats in the source data, including cleaning the data environment based on regular expressions, fixing JSON structure errors and ensuring balanced brackets; when the repaired data still cannot be parsed, switch to an alternative parsing scheme, extract JSON objects or array fragments through fragmentation, and intelligently reorganize them based on the association relationship of key identifiers to build an effective JSON structure; After obtaining a valid JSON structure, the data is recursively traversed and a global mapping table from ID to node is built to form a complete tree structure skeleton. Based on a preset depth control dictionary, different processing depths, priorities, and lists of fields that must be extracted are configured for different types of nodes. A depth-first recursive strategy is used to traverse the nodes and different depths of processing are performed according to the node branch type. S5. Generating Forensic Document Content: A recursive traversal algorithm is used to extract the total number of data entries and the number of recovered data entries starting from the root node of the data tree, generating a standardized summary paragraph; a depth-first traversal is used to process the categorical data and application data branches separately, extracting statistical values of each node and recursively traversing child nodes to construct a complete enumeration list of categorical data; differentiated depth control is adopted for the application data branch, processing ordinary application data to the second level, and deepening the nesting level of social communication data to the fifth level and generating account-level descriptions; in text generation, a simplified or complete output format is dynamically selected according to the number of recovered data entries, and all generated content follows the norms of forensic documents; S6 Automatic Parsing of Device Parameters Based on Large Language Model: It uses a locally deployed large language model as the processing engine and configures the specified context window size and maximum single generation length. The raw device information text is encapsulated into a standard document object; the model is guided to extract information through a prompt template containing task requirements, output format examples, and raw text placeholders; an end-to-end inference process is implemented using document processing chain technology, and retry limit and exponential backoff algorithm are set. The model output is cleaned in multiple stages, including using regular expressions to remove thought process tags, and performing blank line compression and first-line indentation formatting. Automatic population of S7 legal document templates: Identifying various placeholders in the document using regular expressions; Implement hierarchical document traversal processing for the main text, headers and footers, tables, and all paragraphs within tables; first, perform placeholder integrity checks, then perform simple field replacements sequentially and uniformly apply judicial document format standards; use dynamic template row copying technology to fill data row by row in the circular areas of tables; implement intelligent style inheritance and automatic numbering processing for numbered lists; The system enables flexible insertion of text and images by cloning the paragraph XML structure for multi-paragraph content. The image processing includes adaptive scaling and alignment settings based on page size.
2. The intelligent generation method for the entire process of authentication documents according to claim 1, characterized in that, S1 further specifically includes: S1.1 Browser Location: To locate the browser executable file, the system first searches for it in the environment variables by executing system commands and sets timeout control and file verification rules. If the command execution fails, the system queries the registry in Windows, the App manifest in macOS, and the standard installation directory in Linux. If none of the above steps are successful, a fallback search is performed using a preset path library that covers multiple operating systems to ensure reliable location. S1.2 HTML File Search: After successfully obtaining the browser path, a recursive file search is initiated in the target directory. A depth-first search is adopted and a maximum search depth is set. HTML files are filtered according to file extensions and directory exclusion rules. The file content is also verified for structural integrity and keywords to identify the target document. S1.3 Page Rendering: Create a headless browser instance, configure rendering parameters including window size and security options, load the HTML file identified in S1.2, and ensure that the page is fully loaded by monitoring DOM state, network idle time, and implementing multiple rounds of retry loading; S1.4 Region Positioning: In the rendered page, candidate elements are identified based on the preset CSS selector priority, and each element is verified for geometric attributes including area, aspect ratio, visibility ratio and content density to intelligently determine the screenshot area that meets the requirements, and the final range is calculated by applying safety margin. S1.5 Image Output: Capture the image of the area determined in S1.4, save the file with preset image format, quality parameters and naming rules, and store it in the same directory as the source HTML file; Throughout the process from S1.1 to S1.5, timeout control and resource monitoring are implemented for key operation nodes, and a multi-level recovery strategy is activated when failure occurs. The strategy includes automatically switching to a backup rendering engine when the browser probe fails, enabling recursive search and extension fallback when file search fails, implementing multiple rounds of retries when page loading fails, and a fallback scheme that sequentially falls back to full-page capture or viewport capture when screenshot fails. At the same time, the size, dimensions, and content quality of the output image file are verified, and complete metadata, including hash value, timestamp, and system environment, is recorded to form a tamper-proof evidence chain.
3. The intelligent generation method for the entire process of authentication documents according to claim 1, characterized in that, S2 further specifically includes: S2.1 Directory Traversal Initialization: Verify the accessibility of the received root directory path, use recursive traversal, set the maximum recursion depth to 10 levels, and automatically skip preset system directories and cache folders; S2.2 File Identification and Filtering: Target files are located through a triple mechanism of filename prefix matching, extension verification, and content feature detection. Target files include raw data files, device information files, and authorization documents. The filename prefix matching uses a prefix tree structure, performing case-insensitive multi-pattern matching based on a predefined set of key prefixes. Extension verification validates file types based on a predefined set of file formats, setting independent size verification thresholds for different file types. Content feature detection is implemented through lightweight content preview verification, including reading specific bytes from the file header to verify the file signature and basic structural integrity. Specifically, for JSON files, this verifies their basic JSON syntax structure; for HTML files, it verifies whether they contain complete html and body tags; and for image files, it verifies their file header identifier. S2.3 Content Processing and Metadata Extraction: By parsing the directory structure features and file naming conventions, key metadata such as case number, timestamp, and device identifier are automatically extracted from the standardized file naming pattern, and a mapping relationship between files and cases is established.
4. The intelligent generation method for the entire process of authentication documents according to claim 3, characterized in that, In steps S2.1-S2.3, the process further includes: Asynchronous processing and resource control: Node.js asynchronous non-blocking file system operations are adopted, the maximum number of concurrent operations is set to 50, batch processing and file streaming are enabled for large-scale directories, and memory monitoring and automatic garbage collection are implemented. Exception handling and state persistence: Classify and handle permission exceptions, file corruption exceptions, system resource exceptions, and network exceptions; for permission exceptions, automatically record the failed path and continue processing other accessible files; For text encoding anomalies, multiple encoding formats are attempted for file reading; for file corruption anomalies, corruption information is recorded and the file is skipped; for system resource anomalies, automatic degradation is triggered and the number of concurrent operations is reduced; for network anomalies, an exponential backoff algorithm with a maximum of 3 retries and a retry interval is adopted; an integrated state persistence mechanism is used to periodically encrypt and save processing progress, a list of discovered files, and anomaly records to a temporary state file, supporting recovery from interruption points; a performance monitoring component is set up to collect and display key indicators such as directory traversal speed, file recognition accuracy, and memory usage efficiency in real time; a single directory processing timeout threshold is set to 30 seconds, and the process is automatically skipped and the anomaly is recorded upon timeout. Quality verification and audit log synchronization: Perform integrity, consistency and relevance verification on the selected files, calculate SHA-256 and MD5 dual hash values, and generate structured audit logs containing timestamps, operation types, file paths and exception information; Cross-platform compatibility: Automatically adapts path separators, file permission models, and file system characteristics for the three major operating systems: Windows, macOS, and Linux.
5. The intelligent generation method for the entire process of authentication documents according to claim 1, characterized in that, S3 further specifically includes: S3.1 Document Loading and Parsing: The system automatically selects the appropriate document loader based on the file extension. For PDF files, PyPDFLoader is used for text parsing; for Word documents, Unstructured Word Document Loader is used for structured parsing; and for image files, Unstructured Image Loader, which integrates OCR technology, is used for text recognition. If the primary loader fails to parse the document, it automatically switches to a backup loader. For PDF files, PyPDF2 is used for page-by-page parsing, and for Word documents, the python-docx library is used for content extraction. S3.2 Intelligent Content Filtering: Based on a predefined key field dictionary, target paragraphs are identified, and multi-channel matching, partial matching, and synonym matching are used. Blank lines and placeholders are filtered for the identified paragraphs. S3.3 Large Model Information Extraction: Using the locally deployed Ollama platform as the large model processing engine, the specified context window and generation length parameters are configured. Key field content is extracted through preset prompt templates, and the three principles of extracting only explicit content from the document, omitting null fields, and limiting the output range are followed. S3.4 Response Processing and Verification: A multi-level JSON parsing mechanism is used to process the model response. When direct parsing fails, regular expressions are used for secondary parsing, and the parsing results are verified for content authenticity, and fields containing system-inferred content are deleted.
6. The intelligent generation method for the entire process of authentication documents according to claim 1, characterized in that, S4 further specifically includes: S4.1 JSON Format Repair: Intelligent repair of non-standard JSON data using regular expressions, including: identifying and removing predefined JS variable declarations and global object assignment statements; detecting and deleting trailing commas in the JSON structure; and automatically filling in missing parentheses to restore structural integrity when the imbalance ratio exceeds 10% in real time. S4.2 Backup Parsing: When the data still cannot be parsed after repair, a backup parsing scheme is activated, including: extracting JSON objects or array fragments using nested regular expressions; constructing a fragment association graph based on key identifiers; and reorganizing the fragments into a syntactically valid JSON structure based on the association graph. S4.3 Tree Structure Construction: Construct a global ID-node mapping table, generate a unique identifier for each node through recursive traversal, and establish a mapping relationship between node content and identifier; S4.4 Differentiated Depth Processing: Differentiated depth processing is performed based on a pre-configured depth control dictionary. The dictionary sets the maximum processing depth, processing priority, and a list of fields that must be extracted for different types of nodes. During the processing, the recursion depth and extraction range are controlled according to the node type. In the S4.1-S4.4 process, several performance optimization and fault tolerance mechanisms are also set, including: setting memory usage thresholds and node number limits, initiating block processing or memory cleanup when approaching the limit, and implementing retry steps and measures to retain and return successfully processed data during the parsing process to ensure the robustness of the processing flow.
7. The intelligent generation method for the entire process of authentication documents according to claim 1, characterized in that, S5 further specifically includes: S5.1 Generate a summary of data information: Starting from the root node of the data tree, a recursive traversal algorithm is used to extract the total number of data entries and recover the number of data entries, generating a standardized summary paragraph; S5.2 Classification Data Processing: Prioritize the processing of classification data branches through depth-first traversal, extract the statistical value of the node, and recursively traverse all child nodes to construct a complete enumeration list of classification data; S5.3 Application Data Processing: A differentiated depth control strategy is adopted for application data branches to construct an overall statistical description of application data; different depths of processing are implemented for different types of application data, with ordinary application data processed to the second-level sub-nodes and social communication data nested at the fifth-level structure; and a refined description paragraph at the account level is generated for each social application account in the social communication data. S5.4 Text Generation and Integration: During the text generation process, the output format is dynamically selected based on the existence of the number of recovered data entries. When the number of recovered data entries is zero, a simplified format is used, and when the number of recovered data entries is greater than zero, a full format is enabled. All generated text paragraphs uniformly follow the language norms and format requirements of judicial appraisal documents.
8. The intelligent generation method for the entire process of authentication documents according to claim 1, characterized in that, S6 further specifically includes: S6.1 Model Configuration and Input Processing: Configure the locally deployed large language model as the processing engine, set the timeout setting, context window, and maximum generation length, encapsulate the raw device information text into standardized document objects, and establish a structured data representation; S6.2 Prompt Engineering and Template Design: Construct a prompt template specifically for device information extraction. The template includes three core parts: task requirements, standard output format examples, and placeholders for raw text content. S6.3 Reasoning and Result Processing: The initial large language model is combined with the prompt template using document processing chain technology to build an end-to-end analysis pipeline; the maximum number of retries is set to 3, and the retry interval adopts the exponential backoff algorithm; multi-level cleaning is performed on the model output, and regular expressions are used to remove the tags and their content generated during the model's thinking process; the cleaned text is formatted, including compressing consecutive blank lines and whitespace character sequences into a single newline character, and adding a first-line indent of two Chinese characters to non-blank lines.
9. The intelligent generation method for the entire process of authentication documents according to claim 1, characterized in that, S7 further specifically includes: S7.1 Template Loading and Placeholder Recognition: Recognizes various placeholders in the document through predefined regular expression patterns, including simple fields, list loops, numbered lists, and mixed content with multiple paragraphs and images; implements a hierarchical document traversal mechanism to process all paragraphs in the document body, headers and footers, tables, and nested tables in sequence; S7.2 Placeholder Integrity Check: Performs a placeholder integrity check, detects placeholders that are broken due to style splitting, and automatically merges them; S7.3 Simple Field Replacement: The replacement operation is performed in a specific order. First, the direct replacement of simple fields is processed. Placeholder text is replaced while maintaining the original format, and the unified judicial document format specification is applied. S7.4 Table Loop Processing: For looped areas in a table, identify loop markers and use dynamic template row copying technology to fill in the content row by row according to the data list; S7.5 Numbered List Processing: Inherit paragraph attributes by cloning the XML structure of placeholder paragraphs and automatically detect and apply numbering styles; S7.6 Multi-Paragraph Content Processing: Flexible insertion of text and images is achieved by cloning the paragraph XML structure, where image processing includes adaptive scaling and alignment settings based on page size.
10. A fully intelligent system for generating authentication documents, characterized in that, The system includes a raw report screenshot sampling module, a file filtering module, an authorized document intelligent parsing module, a data extraction and structuring module, a forensic appraisal report generation module, a device information analysis module, and a judicial document filling module; the system includes the above modules and is used to perform the method described in any one of claims 1-9; in: The original report screenshot sampling module is used to execute the original report screenshot sampling method for legal documents, including browser positioning, HTML file search, page rendering, region positioning, and image output; The file filtering module is used to execute file filtering methods, including directory traversal initialization, file identification and filtering, content processing and metadata extraction; The authorized document intelligent parsing module is used to execute the authorized document intelligent parsing and information extraction method, including document loading and parsing, intelligent content filtering, large model information extraction, and response processing and verification; The data extraction and structuring module is used to execute data extraction and structuring methods, including JSON format repair, backup parsing, tree structure construction, and differential deep processing; The forensic report generation module is used to execute the method for generating forensic documents, including generating a summary of data information, classifying data processing, applying data processing, and generating and integrating text. The equipment information analysis module is used to execute an automated equipment parameter parsing method based on a large language model, including model configuration and input processing, prompting engineering and template design, reasoning and result processing; The judicial document filling module is used to execute an automated filling method for judicial document templates, including template loading and placeholder recognition, placeholder integrity check, simple field replacement, table loop processing, numbered list processing, and processing of multi-paragraph content.
Citation Information
Cited By
Dynamic Web application generation method and system based on multi-level declarative DSL
CN121742827A
Ecological environment access list prohibited item intelligent analysis method and device
CN122221855A