Full-angle and half-angle distinguishing searching method for PDF and CAJ documents

By integrating full-width and half-width character conversion and mode switching controls into PDF and CAJ readers, the problem of mismatch between full-width and half-width character searches has been solved, enabling accurate and efficient document retrieval, reducing operational complexity, and improving compatibility.

CN121683705APending Publication Date: 2026-03-17TONGFANG KNOWLEDGE DIGITAL PUBLISHING TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511886090.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-15
Publication Date
2026-03-17

AI Technical Summary

Technical Problem

Existing PDF and CAJ readers cannot effectively distinguish between full-width and half-width characters in their search functions, resulting in mismatched searches, cumbersome operations, and a high barrier to entry, failing to meet users' needs for accurate and efficient information location.

Method used

The front-end interface provides a mode switching control, and the search mode is passed to the document search controller through an event communication mechanism. The document search controller has a built-in full-width and half-width character conversion function, which automatically processes the search keywords and document text to achieve string matching that distinguishes between full-width and half-width modes.

Benefits of technology

Significantly improves search accuracy, simplifies operation process, lowers the threshold for use, adapts to most readers, eliminates the need to manually switch input methods or rely on external tools, and ensures search efficiency and compatibility.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121683705A_ABST
    Figure CN121683705A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of document processing, discloses a full-corner and half-corner distinguishing searching method for PDF and CAJ documents, and solves the problems that full-corner and half-corner character searching of an existing reader is not matched, operation is tedious, and the use threshold is high. According to the method, distinguishing / non-distinguishing full-angle and half-angle mode selection and keyword input are provided through a front-end interface, and a search object containing mode parameters is generated and transmitted to a document search controller through an event bus; the document search controller analyzes the parameters and updates the internal state, when the mode is judged not to be distinguished, a full-angle and half-angle conversion function is called, full-angle numbers, letters and spaces are standardized into half angles and then matched, and if the mode is distinguished, literal matching is directly executed; and a matching search result is notified to the front end and is highlighted. According to the method, manual intervention of a user or external tools are not needed, and the searching precision and efficiency are improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the technical field of document processing, and particularly relates to a PDF and CAJ document full and half angle distinguishing search method, device and storage medium. BACKGROUND

[0002] With the continuous development of information technology, electronic documents have become the core carrier of information storage and transmission. Among them, PDF and CAJ formats are widely used in office collaboration, academic research, literature management and other fields due to their strong format stability and wide cross-platform adaptation scene. As a core function of quickly positioning information, "document search" has become a basic and essential ability of such format readers.

[0003] In actual use scenarios, due to factors such as input device differences (such as different input rules of external keyboards and virtual keyboards), format conversion setting deviations (such as non-uniform character encoding when converting Word to PDF), and multi-source content splicing (such as integrating different document fragments), full and half angle characters often appear in the same PDF or CAJ document. Among them, half angle characters (such as "1", "A", ",") are mainly adapted to English input scenarios, and the character width is relatively narrow; full angle characters (such as "1", "A", ",") are more consistent with Chinese typesetting logic, and the character width is consistent with Chinese characters. This phenomenon of mixed full and half angle characters directly puts forward higher requirements on the "matching accuracy" and "search efficiency" of the reader search function.

[0004] However, the search functions of most PDF and CAJ readers on the market still remain at the basic level of direct literal matching of keywords, and do not design special processing logic for the characteristics of full and half angle characters: neither support mode switching of "distinguishing full and half angle" and "not distinguishing full and half angle", nor lack built-in automatic conversion mechanism of full and half angle characters. In contrast, common office tools such as Word and Excel have already realized the full and half angle distinguishing search function, and users can flexibly select the matching rules according to their needs; if PDF and CAJ reader users need to cover the full and half angle search requirements, they can only manually operate in the following ways:

[0005] 1. Repeatedly switching the full and half angle state of the input method (such as switching through the "Shift + Space" shortcut key), and inputting full / half angle keywords for search one by one;

[0006] 2. With the help of third-party full and half angle conversion tools (such as online character converters), first preprocess the keywords or document content, and then import the reader for search.

[0007] This operating mode not only requires users to possess "input method operation knowledge", "patience for repeated execution", and "ability to use external tools", significantly raising the barrier to entry; it also leads to omissions or deviations in search results due to manual operation errors (such as forgetting to switch states or conversion tool format compatibility issues), ultimately resulting in low search efficiency and failing to meet users' core needs for "accurate and efficient information location", becoming a key pain point restricting the optimization of PDF and CAJ reader functions. Summary of the Invention

[0008] To address the aforementioned problems in existing technologies, namely the mismatch between full-width and half-width characters in the search functions of existing PDF and CAJ readers, cumbersome operations, and high barriers to entry, the first aspect of this invention proposes a method for distinguishing between full-width and half-width characters in PDF and CAJ documents. This method includes the following steps:

[0009] Step S1: The front-end interface receives the search keywords and the selected search mode input by the user. The search mode includes distinguishing between full-width and half-width characters and not distinguishing between full-width and half-width characters. Based on the search mode, a search parameter object is generated and the search parameter object is passed to the document search controller through an event communication mechanism.

[0010] Step S2: The document search controller parses the search parameter object and updates the search mode therein to its internal state;

[0011] Step S3: The document search controller determines whether the search mode is a mode that does not distinguish between full-width and half-width characters based on its internal state.

[0012] If the full-width and half-width modes are not distinguished, the full-width and half-width character conversion function is called to standardize the character form of the search keywords and the current page text content to be searched obtained from the document. The standardized keywords are then used to perform string matching search with the page text to locate the matching items and add a highlight class to obtain the search results.

[0013] If full-width and half-width modes are distinguished, the search keywords are used to perform string matching search with the current page text content to be searched, the matching items are located and highlighted with a class, and the search results are obtained.

[0014] The search results are stored in the internal data of the PDFFindController class and notified to the front-end interface through an event communication mechanism;

[0015] Step S4: The front-end interface reads and renders the search results, and the document search controller highlights the matching items.

[0016] The beneficial effects of this invention are:

[0017] 1) Significantly improved search accuracy: Through the built-in full-width / half-width character conversion mechanism and the "distinguish between full-width and half-width" mode switching function, the system effectively solves the problem of mismatch in full-width / half-width character searches in existing technologies. In the non-distinguish between full-width and half-width mode, the system can automatically perform full-width / half-width standardization processing on keywords and document text to cover full-width / half-width character search needs (e.g., entering half-width "PDF" can match full-width "PDF" in the document), avoiding omissions in search results due to differences in character forms. In the distinguish between full-width and half-width mode, it can accurately match content with completely identical character forms, meeting the needs of refined search scenarios, without requiring manual intervention from the user.

[0018] 2) The operation process is greatly simplified: Users do not need to manually switch between full-width and half-width input methods or repeatedly enter keywords. They also do not need to rely on third-party full-width and half-width conversion tools. The operation selection can be completed simply by switching modes through the front-end interface. This significantly reduces the threshold for using the function, reduces manual operation steps and the probability of errors, greatly improves search efficiency, and adapts to the usage habits of various user groups.

[0019] 3) Strong compatibility and adaptability: Based on existing mainstream open-source document processing libraries (such as pdfjs-dist), the core functional modules responsible for document searching in these libraries (such as the PDFFindController class) are modified locally to directly adapt to most PDF and CAJ readers (including custom readers, enterprise-level document management systems, etc.) developed based on these open-source libraries. The adaptation range is wide, and there is no need to carry out large-scale transformation of the existing reader architecture. It has strong practicality and promotion value.

[0020] Furthermore, full-width / half-width character conversion and string matching are both executed synchronously within the document search controller. Combined with character encoding normalization preprocessing, this effectively eliminates matching delays caused by encoding differences, ensuring that the search response speed is consistent with the native search function, balancing accuracy and speed. At the same time, the core logic adopts a modular design, and functions such as "full-width punctuation conversion" and "multi-language character adaptation" can be expanded according to needs in the future, demonstrating good scalability. Attached Figure Description

[0021] Other features, objects, and advantages of this application will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings:

[0022] Figure 1 This is a flowchart illustrating the steps of a method for distinguishing between full-width and half-width characters in PDF and CAJ documents according to the present invention.

[0023] Figure 2This is a schematic diagram illustrating the effect of a full-width / half-width character search method for PDF and CAJ documents according to the present invention.

[0024] Figure 3 This is a schematic diagram illustrating the effect of the full-width and half-width character search method for PDF and CAJ documents according to the present invention.

[0025] Figure 4 This is a flowchart illustrating the document search execution process of a method for distinguishing between full-width and half-width characters in PDF and CAJ documents according to the present invention.

[0026] Figure 5 This is a flowchart of the document search execution process in existing technologies. Detailed Implementation

[0027] The present application will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the invention. Furthermore, it should be noted that, for ease of description, only the parts relevant to the invention are shown in the accompanying drawings.

[0028] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.

[0029] To more clearly explain the method for distinguishing between full-width and half-width characters in PDF and CAJ documents according to the present invention, the following is combined with... Figures 1 to 4 The steps in the embodiments of the present invention will be described in detail below.

[0030] This invention proposes a method for distinguishing between full-width and half-width characters in PDF and CAJ documents. See [link to relevant documentation]. Figure 1 The method includes the following steps:

[0031] Step S1: The front-end interface receives the search keywords and the selected search mode input by the user. The search mode includes distinguishing between full-width and half-width characters and not distinguishing between full-width and half-width characters. Based on the search mode, a search parameter object is generated and the search parameter object is passed to the document search controller through an event communication mechanism.

[0032] In this embodiment, the front-end interface is equipped with a "keyword input box" and a "search mode switching control" (providing two options: "distinguish between full-width and half-width characters" and "do not distinguish between full-width and half-width characters"). After the user selects the search mode and enters the search keyword, a search event is triggered.

[0033] The front-end generates a structured search parameter object findParam based on the user's selected search mode (e.g., identified by the boolean value isDistinguishSBC, where true distinguishes between full-width and half-width characters, and false does not distinguish between them) and search keywords (query).

[0034] Data transfer is achieved through a front-end global event bus (such as Vue EventBus or React EventEmitter). The dispatch('find', findParam) method is called to notify the event carrying the search parameter object or the search result. The front-end interface listens for the event through the pre-defined on('find', (param) => { ...}) method and responds to the event, thereby completing the transfer of data between the front-end interface and the document search controller.

[0035] Step S2: The document search controller parses the search parameter object and updates the search mode therein to its internal state;

[0036] In this embodiment, the document search controller is implemented by modifying the PDFFindController class of an open-source document rendering library (such as pdfjs-dist), and its workflow is as follows:

[0037] The document search controller listens for events through the predefined on('find', (param) => { ...}) method. That is, after receiving findParam, it parses the search pattern (isDistinguishSBC) and search keywords (query), and stores the search pattern in the internal state object of the PDFFindController class (such as this.#state) as the basis for subsequent search judgments.

[0038] Meanwhile, the constant variable declarations (const query, const pageContent) for "storing search keywords" and "storing page text content" in the original PDFFindController class have been changed to variable variable declarations (let query, let pageContent) to support subsequent character conversion operations;

[0039] Step S3: The document search controller determines whether the search mode is a mode that does not distinguish between full-width and half-width characters based on its internal state.

[0040] If the full-width and half-width modes are not distinguished, the full-width and half-width character conversion function is called to standardize the character form of the search keywords and the current page text content to be searched obtained from the document, and then the standardized keywords are used to perform string matching search with the page text to obtain the search results;

[0041] If full-width and half-width modes are distinguished, then the search keywords are used to perform a string matching search with the current page text content to be searched, and the search results are obtained;

[0042] In this embodiment, the document search controller further includes a character encoding normalization function, regardless of whether the search mode is a full-width / half-width mode, to preprocess the search keywords and the current page text content to be searched (e.g., normalize('NFKC')), thereby eliminating differences in character encoding formats.

[0043] The search pattern is stored in the internal state object of the PDFFindController class;

[0044] In the search execution of the PDFFindController class, a conditional judgment branch based on the search pattern is inserted to determine whether to call the full-width / half-width character conversion function to synchronously convert the keywords and page text content based on the internal state;

[0045] To ensure the custom full-width / half-width character conversion logic works, additional modifications are needed to the open-source library: Modify the text normalization function in the open-source library (such as getNormalizeWithNFKC() in pdfjs), removing the "specific character range used for full-width / half-width character conversion (such as "!")" from the NormalizeWithNFKC parameter string. ", to avoid conflicts between the default conversion logic of open source libraries and custom logic;

[0046] The judgment based on its internal state specifically involves: determining whether to perform full-width / half-width character conversion by accessing the lookup pattern attribute stored in the internal state object;

[0047] Specifically: The document search controller accesses its internal state (this.#state.isDistinguishSBC, which is a predefined "search mode identifier," where isDistinguishSBC = false corresponds to the functional requirement of "full-width / half-width conversion needs to be performed," and isDistinguishSBC = true corresponds to the functional requirement of "full-width / half-width conversion not needed"), determines the search mode, and specifically, if it is a mode that does not distinguish between full-width and half-width (isDistinguishSBC = false, i.e., the state corresponds to the full-width / half-width conversion function), it calls the full-width / half-width character conversion function convertSBCToDBC() to standardize the search keyword query and the current page text pageContent extracted from the document. The character standardization process includes converting full-width letters, full-width numbers, and full-width spaces into their corresponding half-width forms.

[0048] The full-width / half-width character conversion function is called to standardize the character format of the search keywords and the current page text content to be searched obtained from the document. The method is as follows:

[0049] Iterate through each character of the input string and obtain the Unicode encoding value of the character;

[0050] If the character encoding value is in the range of full-width numbers (U+FF10~U+FF19), full-width uppercase letters (U+FF21~U+FF3A), or full-width lowercase letters (U+FF41~U+FF5A), then it is converted to the corresponding half-width character by bitwise operation (charCode & 0xFF) + 0x20;

[0051] If the character is a full-width space (U+3000), then convert it to a half-width space (U+0020).

[0052] If it does not fall within the above target range (such as full-width punctuation marks "," or "."), then the character remains unchanged;

[0053] The system employs string matching algorithms (such as KMP algorithm and regular expression matching) to perform matching searches using standardized keywords and page text.

[0054] If the system is set to distinguish between full-width and half-width characters (isDistinguishSBC = true, meaning the status does not correspond to the full-width / half-width character conversion function): no full-width / half-width character conversion is performed. The original query and pageContent are used directly for string matching (ensuring that only content with completely identical character forms is matched, achieving the "distinguish between full-width and half-width characters" matching effect).

[0055] Then, a string matching algorithm (such as KMP algorithm or regular expression matching) is used to perform a matching search, obtain the search results, and add a highlight class to each position according to the search results;

[0056] During the search process, the relevant matching data, including the "matching position (page number, line number, character starting index)", "matching content", and the highlighted class, will be stored in the internal data of the PDFFindController class.

[0057] The document search controller notifies the front end via dispatch. After listening to the above event, the front end reads the matching result data from PDFFindController and obtains the search results.

[0058] Step S4: After obtaining the search results, notify the front-end interface through the event communication mechanism. The front-end interface then reads the results from the document search controller and renders them to achieve highlighting.

[0059] In this embodiment, after the document search controller completes the matching search and obtains the search results, it publishes a status notification through the front-end global event bus. Specifically, it informs the front-end of the current search status information through dispatch('updatefindmatchescount', total number of matches) and dispatch('updatefindcontrolstate', search status).

[0060] After the front-end listens for the above events, it reads the matching result data (including matching position, matching content, etc.) from PDFFindController. At the same time, PDFFindController actively performs highlight rendering in the document's 'textLayer' DOM. The document search controller locates all matching items based on the matching position information and adds preset highlight classes (such as yellow background color and underline style) to the corresponding text nodes, without requiring the front-end to perform additional DOM operations.

[0061] The front-end interface synchronously parses status information and matching data, and displays auxiliary content such as "total number of matches" and "current match number" in the "search results area" at the top of the interface, while also providing "previous" and "next" operation buttons; when the user clicks the switch button, the front-end updates the "current match number", and PDFFindController synchronously focuses on and highlights the corresponding match item, making it convenient for users to quickly locate and browse all matching results;

[0062] Figure 4 , Figure 5The flowcharts for document retrieval in this invention and prior art are presented respectively. It can be seen that the prior art search process requires users to manually switch between full-width and half-width input methods and repeatedly enter keywords for multiple searches. This is not only cumbersome and inefficient, but also prone to search failures and omissions due to switching errors or input deviations. In contrast, this invention, by adding a full-width / half-width mode switching control to the front end and incorporating full-width / half-width conversion logic into the document search controller, allows users to automatically complete the matching and search of full-width and half-width characters simply by entering keywords and selecting the corresponding mode once. No additional manual operation or external tools are required, significantly simplifying the operation process and avoiding search deviations caused by differences in full-width and half-width characters. This achieves accurate and efficient document retrieval, fully demonstrating the core advantages of this invention in improving retrieval efficiency and search accuracy.

[0063] The following example, using a PDF reader developed based on the pdfjs-dist open-source library, details the complete workflow in "not distinguishing between full and half-width characters" mode, taking the example of a user searching for PDF documents containing a mixture of "ABC" (half-width) and "ABC" (full-width) characters:

[0064] I. User Operations: Front-end Interface Interaction and Command Triggering

[0065] The user opens the PDF document to be searched. Figure 2 As shown, the document is one page long, containing both half-width "ABC" text and full-width "ABC" text. Complete the following operations in the reader's front-end interface:

[0066] Keyword input: Click the "Search Box" at the top of the interface and enter the target keyword "ABC" - By using the normal keyboard, half-width characters will be generated by default (their Unicode encodings are U+0041, U+0042, and U+0043 respectively).

[0067] Mode selection: In the full-width / half-width mode below the search box, do not check the "Distinguish between full-width and half-width" option. This option is pre-bound to the "Full-width / half-width conversion function" of the document search controller. Selecting it will trigger the subsequent character conversion logic.

[0068] Trigger the search: Click the "Search" button on the right side of the search box (or press the "Enter" key on the keyboard) to officially trigger the search operation. At this time, the front-end interface will automatically focus on the first page of the document and wait for the matching results.

[0069] II. Parameter Passing: Front-end Construction Parameters and Event Bus Transmission

[0070] After receiving the user's search command, the front-end (developed based on the Vue 3 framework) completes parameter processing and transmission according to the following steps, corresponding to the core logic of "Front-end implementation step 2 - event communication and data processing" in the embodiment:

[0071] Parameter object construction: The front-end script automatically generates a structured search parameter object, which contains two core pieces of information: one is the original keyword "ABC" (half-width characters) entered by the user, and the other is the status value that identifies the search mode - the status value corresponding to the "do not distinguish between full and half width" mode is "false", which clearly tells the document search controller that full and half width conversion needs to be performed;

[0072] Event bus transmission: The constructed search parameter object is transmitted through the front-end global event bus (a communication mechanism for data transfer between the front-end and the document search controller) to trigger the "search request event".

[0073] The controller receives parameters: The document search controller (instantiated based on the modified PDFFindController class) receives the search parameter object in real time through a pre-set listening mechanism, completing the parameter transmission from the front end to the controller without delay;

[0074] III. Document Search Controller: Search Logic Execution and Full / Half Character Conversion

[0075] After receiving the search parameter object, the document search controller executes the search according to the process of "parameter parsing - status update - full-width / half-width character conversion - string matching", which corresponds to the core operations of "open source library modification step 1" and "technical solution - document search controller logic processing" in the embodiment:

[0076] Step 1: Parameter parsing and internal state update

[0077] The document search controller extracts the keyword "ABC" and the pattern status value "false" from the received parameter object, and stores the pattern status value in the document search controller's internal status object as the basis for subsequent determination of whether to perform full-width / half-width character conversion;

[0078] Since the variables storing keywords and page text content in the original PDFFindController class were unmodifiable constants, they have been modified to be modifiable variables in previous implementations. At this time, the document search controller can perform subsequent assignment operations on these two variables to avoid the failure of full-width / half-width conversion due to the unmodifiable variables.

[0079] Step 2: Full-width / Half-width character conversion judgment and execution (core step)

[0080] The document lookup controller accesses the mode state value in the internal state object, determines that the current mode is "not distinguishing between full and half characters", and determines that a full and half character conversion needs to be performed;

[0081] Keyword conversion: Call the custom full-width / half-width conversion function to process the keyword "ABC" - since "ABC" itself is a half-width character (its encoding is within the range of half-width uppercase letters, and does not belong to the full-width target conversion range), the function directly returns the original keyword "ABC";

[0082] Page Text Extraction and Conversion: The document search controller extracts the text content of the single-page PDF document using the native interface of the open-source library.

[0083] When extracting text from the page, both half-width "ABC" and full-width "ABC" are obtained (their Unicode encodings are U+FF21, U+FF22, and U+FF23, respectively). For half-width "ABC": the conversion function determines that it is a non-full-width character and keeps the text content unchanged. For full-width "ABC": the conversion function processes it according to preset rules—first, it iterates through each character in "ABC" and obtains its respective Unicode encoding; since these encodings are within the range of full-width uppercase letters (U+FF21~U+FF3A), they are converted to the corresponding half-width characters through bitwise operations—taking "A" as an example, it is converted to half-width "A" after calculation, similarly "B" is converted to "B", "C" is converted to "C", and finally full-width "ABC" is converted to half-width "ABC". For non-target full-width characters in other positions on the page (such as full-width punctuation marks "," and "."), since their encodings are not within the target conversion range of "full-width numbers / letters / spaces", they are kept unchanged after conversion and do not affect subsequent matching logic.

[0084] Step 3: Unified preprocessing and string matching

[0085] The document search controller calls a character encoding normalization function to preprocess the converted keyword "ABC" and the page text content (including the original half-width "ABC" and the converted "ABC") to eliminate implicit differences that may be caused by different encoding formats and avoid the problem of "matching failure due to identical character content but different encodings". A string matching algorithm is then used to perform a matching operation on the preprocessed keyword and the page text: the original half-width "ABC" on the page matches the keyword perfectly, resulting in a successful match; the converted "ABC" (original full-width "ABC") also matches the keyword perfectly, resulting in a successful match. The document search controller's search results contain two matching records. Each record details key information such as the starting index of the matching content on the page (e.g., half-width "ABC" starts at the 100th character, and the converted "ABC" starts at the 200th character), the length of the matched characters (match length = 3), and the matched content ("ABC"), etc. The ending index can be indirectly calculated from the starting index and the length of the matched characters.

[0086] The search results are used to add a highlight class to each location based on the search results and store it in the internal data of the PDFFindController class;

[0087] The document search controller sends a notification via dispatch, triggering the front end to call the matching data stored internally in findController to retrieve the search results;

[0088] IV. Results Feedback: Front-end Display and Highlighting

[0089] After the document search controller completes the matching search, it notifies the front-end interface through an event communication mechanism. The front-end then reads the results and, in conjunction with the document search controller, completes the rendering and display. The specific process is as follows:

[0090] Status notification publishing: The document search controller publishes status notifications through the front-end global event bus, using the dispatch('updatefindmatchescount', total number of matches) and dispatch('updatefindcontrolstate', search status) events to synchronize the core status information of the current search to the front end;

[0091] Front-end result reading: After listening to the above events, the front-end directly reads the complete matching result data from PDFFindController, including key information such as the matching position (character start / end index) and matching content, without the controller directly transmitting the result set;

[0092] Controller highlight rendering: The highlight effect is actively implemented by PDFFindController. The controller locates all matching items in the document's 'textLayer' DOM based on the matching position information and adds preset highlight classes (such as yellow background color and underline style) to the corresponding text nodes, without requiring the front end to perform additional DOM operations.

[0093] Front-end auxiliary display: The front-end interface synchronously parses status information and matching data, and displays auxiliary content such as "total number of matches" and "current match number" in the "search results area" at the top of the interface, while providing "previous" and "next" operation buttons; when the user clicks the switch button, the front-end updates the "current match number", and PDFFindController synchronously focuses on and highlights the corresponding match item, making it convenient for users to quickly locate and browse all matching results.

[0094] Through the complete process described above, users only need to perform one operation to simultaneously match "ABC" (half-width) and "ABC" (full-width) in a document, without having to manually switch input methods or repeat the search. This fully demonstrates the core advantages of this invention: "improving matching accuracy and reducing the barrier to entry for users." See Figure 3 for an example of the search effect without distinguishing between full-width and half-width characters.

[0095] In terms of principle and structure, the "distinguishing between full-width and half-width characters" and "not distinguishing between full-width and half-width characters" modes share the same basic process framework: both start with user operation (entering the keyword "ABC", selecting the corresponding mode and triggering the search), construct a parameter object containing the keyword and mode status values ​​through the front end, and pass it to the document search controller via the event bus; the document search controller first parses the parameters and updates its internal state, then performs string matching after character encoding normalization preprocessing, and finally feeds back the matching results to the front end through the event bus, where the front end displays the matching information and the controller completes the highlighting. The core difference between the two lies in the "full-width and half-width character conversion execution" stage: in the "not distinguishing between full-width and half-width characters" mode, the document search controller calls the full-width and half-width character conversion function after reading the status value, converting full-width characters in the document (such as "ABC" on the page) to half-width characters, matching them with the keyword in the same form, and finally generating matching results that cover both full-width and half-width characters; while the "distinguishing between full-width and half-width characters" mode does not perform this conversion, directly matching in the original form of the characters, only retaining the results that are completely consistent with the keyword form, and appending... Figure 5 The image shown demonstrates the difference between full-width and half-width characters for searching, so it will not be described in detail.

[0096] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working process and related explanations of the methods described above can be found in the corresponding processes in the foregoing system embodiments, and will not be repeated here.

[0097] A second embodiment of the present invention provides a method for distinguishing between full-width and half-width characters in PDF and CAJ documents. Based on the method, the system includes a front-end interaction module, a document search control module, and a communication interaction module.

[0098] The front-end interaction module is configured to: receive search keywords and selected search modes input by the user, the search modes including distinguishing between full-width and half-width modes and not distinguishing between full-width and half-width modes, and generate a search parameter object based on the search mode; the communication interaction module is used to pass the search parameter object from the front-end interaction module to the document search control module through an event communication mechanism, and to return the matching result set from the document search control module to the front-end interaction module.

[0099] The document search control module is configured to: parse the search parameter object and update the search mode therein to its internal state; it is also configured to: determine the search mode based on its internal state: if it is a mode that does not distinguish between full-width and half-width characters, then call the full-width and half-width character conversion function to standardize the character form of the search keywords and the current page text content to be searched obtained from the document, and use the standardized keywords and page text to perform string matching search, locate the matching items and add a highlight class to obtain the search result;

[0100] If full-width and half-width modes are distinguished, the search keywords are used to perform string matching search with the current page text content to be searched, the matching items are located and highlighted with a class, and the search results are obtained.

[0101] The search results are stored in the internal data of the PDFFindController class and notified to the front-end interface through an event communication mechanism;

[0102] The front-end interaction module is further configured to: read and render the search results on the front-end interface, and highlight the matching items in the document search controller.

[0103] It should be noted that the PDF and CAJ document full-width and half-width character recognition search system provided in the above embodiments is only an example of the division of the above functional modules. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the modules or steps in the embodiments of the present invention can be further decomposed or combined. For example, the modules in the above embodiments can be merged into one module, or further split into multiple sub-modules to complete all or part of the functions described above. The names of the modules and steps involved in the embodiments of the present invention are only for distinguishing the various modules or steps and are not considered as an improper limitation of the present invention.

[0104] A device according to a third embodiment of the present invention includes:

[0105] At least one processor;

[0106] and a memory communicatively connected to at least one of the processors;

[0107] The memory stores instructions that can be executed by the processor to implement the above-described method for distinguishing between full-width and half-width characters in PDF and CAJ documents.

[0108] A fourth embodiment of the present invention provides a computer-readable storage medium storing computer instructions, which are executed by the computer to implement the above-described method for distinguishing between full-width and half-width characters in PDF and CAJ documents.

[0109] Those skilled in the art will recognize that the modules and method steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. The programs corresponding to the software modules and method steps can be placed in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disks, removable disks, CD-ROMs, or any other form of storage medium known in the art. To clearly illustrate the interchangeability of electronic hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in electronic hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the invention.

[0110] The terms “first”, “second”, etc., are used to distinguish similar objects, not to describe or indicate a specific order or sequence.

[0111] The term "comprising" or any other similar term is intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus / device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent in such process, method, article, or apparatus / device.

[0112] The technical solution of the present invention has been described above with reference to the preferred embodiments shown in the accompanying drawings. However, it will be readily understood by those skilled in the art that the scope of protection of the present invention is obviously not limited to these specific embodiments. Without departing from the principles of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after such changes or substitutions will all fall within the scope of protection of the present invention.

Claims

1. A method for full and half difference search of PDF and CAJ documents, characterized by, The method comprises the following steps: Step S1, the front-end interface receives the user input search keyword and the selected search mode, the search mode includes the full and half angle mode and the full and half angle mode, and generates a search parameter object based on the search mode, and transmits the search parameter object to the document search controller through an event communication mechanism; Step S2, the document search controller parses the search parameter object, and updates the search mode in it to its internal state; Step S3, the document search controller determines whether the search mode is the full and half angle mode according to its internal state; If the full and half angle mode is not distinguished, the full and half angle character conversion function is called to standardize the character form of the search keyword and the current page text content obtained from the document, and the standardized keyword and page text are used to perform string matching search, locate the matching item and add highlight class, and obtain the search result; If the full and half angle mode is distinguished, the search keyword and the current page text content are used to perform string matching search, locate the matching item and add highlight class, and obtain the search result; The search result is stored in the internal data of the PDFFindController class, and the front-end interface is notified through the event communication mechanism; Step S4, the front-end interface reads the search result and renders, and the document search controller realizes the highlight display of the matching item.

2. The method according to claim 1, wherein, The character form standardization processing includes converting full angle letters, full angle numbers and full angle spaces into corresponding half angle forms.

3. The method according to claim 2, wherein, The full and half angle character conversion function is called to standardize the character form of the search keyword and the current page text content obtained from the document, and the method is: Traverse each character of the input string, and get the Unicode code value of the character; If the character code value is in the full angle number range, the full angle uppercase letter range or the full angle lowercase letter range, it is converted into the corresponding half angle character through bit operation; If the character is full angle space, it is converted into half angle space; If it does not belong to the above target range, the character remains unchanged.

4. The method according to claim 1, wherein, The document search controller for realizing steps S2 and S3 is obtained by modifying the PDFFindController class of the open source document rendering library; the modified PDFFindController class of the open source document rendering library comprises: The variable used to store the search keyword and the page text content in the PDFFindController class is modified from constant declaration to variable variable declaration; In the search execution of the PDFFindController class, a conditional judgment branch based on the search mode is inserted to determine whether to call the full and half angle character conversion function to convert the keyword and page text content synchronously according to the internal state.

5. The method according to claim 4, wherein, The modified PDFFindController class of the open source document rendering library further comprises modifying a text normalization function in the open source document rendering library, specifically, removing a specific character range for full and half character conversion in a NormalizeWithNFKC parameter string used by the text normalization function.

6. The method of claim 1, wherein the method further comprises: determining whether the PDF document is in the full-width or half-width mode; and determining whether the CAJ document is in the full-width or half-width mode. The updating of the search mode into its internal state comprises storing the search mode in an internal state object of the PDFFindController class, and the judging according to its internal state comprises judging whether to perform full and half character conversion by accessing the search mode attribute stored in the internal state object.

7. The method of claim 1, wherein the method further comprises: determining whether the PDF document is in the full-width or half-width mode; and determining whether the CAJ document is in the full-width or half-width mode. The document search controller further comprises using a character encoding normalization function to respectively preprocess the search keyword and the current page text content to be searched regardless of whether the search mode is the full and half character distinguishing mode.

8. The method of claim 1, wherein the method further comprises: determining whether the PDF document is in the full-width or half-width mode; and determining whether the CAJ document is in the full-width or half-width mode. The implementation through the event communication mechanism through a front-end global event bus comprises notifying an event carrying the search parameter object or the search result through a dispatch method, and listening to and responding to the event through a preset on method, thereby completing the transmission of data between the front-end interface and the document search controller.

9. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor executes the program to implement the full and half character distinguishing search method for PDF and CAJ documents according to any one of claims 1 to 8.

10. A computer-readable storage medium having stored thereon a computer program, characterized in that, The program is executed by the processor to implement the full and half character distinguishing search method for PDF and CAJ documents according to any one of claims 1 to 8.