Text extraction method and device, electronic equipment and computer readable storage medium
Through a text extraction method suitable for text files and picture files, the problem of applying different word picking operations in the prior art is solved, and the text extraction effect that simplifies operations, improves efficiency and accuracy is achieved.
Patent Information
- Application Number
- CN202310952254.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-29
- Publication Date
- 2025-02-14
AI Technical Summary
The prior art requires different word picking operations according to different file types. If the operations do not match, it may lead to word picking failure, which is cumbersome and time-consuming.
It provides a text extraction method that can be applied to text files and picture files at the same time. It does not need to distinguish file types, and automatically performs applicable word picking operations through user selection operations, including text copying and picture screenshots + text recognition.
It simplifies text extraction operations, improves text extraction efficiency and accuracy, reduces user waiting time, and is suitable for multi-type files.
Smart Images

Figure CN119440318A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a text extraction method, device, electronic device and computer-readable storage medium. Background Art
[0002] Existing electronic devices provide a second application for acquiring text content in a file, and the operation process of the second application is usually different for different file types. For example, for text files, words are usually acquired by direct copying, and for picture files, words are acquired by screenshots and image recognition.
[0003] Users need to apply different word extraction operations to different file types. If the word extraction operation applied by the user does not correspond to the file type, word extraction may fail. Summary of the invention
[0004] The embodiments of the present application provide a text extraction method, device, electronic device and computer-readable storage medium, and provide a text extraction solution that is applicable to both text files and image files. Without distinguishing the file type, in response to the user's selection operation on the first content of the target file, a first word extraction operation that can copy the text and a second word extraction operation that can take a screenshot and recognize the text of the image can be respectively performed, and the text extraction result corresponding to the selected operation is obtained and displayed through the two word extraction operations that are respectively performed. The text extraction method that is common to multiple types of files saves the operation of distinguishing file types, simplifies the text extraction operation, and improves the text extraction efficiency.
[0005] To achieve the above objectives, the embodiments of the present application adopt the following technical solutions:
[0006] In a first aspect, a text extraction method is provided, and the text extraction method is applied to an electronic device, and the electronic device may be a device that can provide a file viewing function, such as a desktop computer, a laptop computer, or a mobile phone. Specifically, the electronic device first displays a first interface for a user to view a target file, and the file type of the target file is text or a picture, and the content of the picture includes characters. A first application that provides a file viewing function is usually running in the electronic device, and the first application may be a system application such as a browser, a document editor, or a third-party application. The text extraction method provided in this embodiment may be a second application independent of the first application, or may be a sub-application in the first application, without limitation.
[0007] After the electronic device displays the target file on the first interface, if the user selects the target file in the first interface, the selection operation is used for a partial area in the target file to indicate the extraction of the character text of the first content containing the partial area. In response to the selection operation, the electronic device executes the first word extraction operation applicable to the text file and the second word extraction operation applicable to the image file, respectively, so that no matter which file type the target file is, it can be applied. The first word extraction operation is a word extraction operation corresponding to the text file, which is mainly to copy the text in the area where the first content is located to obtain the first word extraction result. The second word extraction operation is a word extraction operation corresponding to the image file, which is mainly to copy the text in the area where the second content is located to obtain the second word extraction result. It should be noted that the first word extraction result may be empty, or the second word extraction result may be empty. The empty word extraction result can be considered that the file type corresponding to the word extraction operation is not applicable. For example, when the target file of the first word extraction operation is a picture file, the first word extraction result is empty, and when the target file of the second word extraction operation is a text file, the second word extraction result is empty. Of course, there may be other situations that may cause the word retrieval result to be empty. For example, the first content corresponding to the selection operation does not contain any characters. This may also result in the first word retrieval operation and the second word retrieval operation failing to retrieve words, and the first word retrieval result and the second word retrieval result will be empty.
[0008] The electronic device obtains a comprehensive text extraction result based on the first word extraction result obtained by the first word extraction operation and the second word extraction result obtained by the second word extraction operation. The text extraction result may contain only text characters, or may include a text file obtained by drawing text characters in a specific format. Afterwards, the electronic device switches from the first interface to displaying the second interface. Compared with the first interface, the second interface includes both the target file opened previously and the text extraction result of the first content corresponding to the user's selection operation, and the first content in the text extraction result is displayed in a preset manner in the second interface. In this way, a general text extraction method can be executed for multiple types of files without distinguishing between file types, and the efficiency and accuracy of text extraction are high.
[0009] In a specific implementation of the first aspect, after the electronic device obtains the text display result, the second interface displayed may also include a context menu, and the context menu includes at least one operation option of copy, paste, and translate. In this way, the user can perform a point-and-click operation on the operation option to perform an operation corresponding to the operation option on the extracted first content, such as copying the first content to another file, or translating the first content, etc. Of course, in order to make it easier for the user to view, the context menu may also display the first content at the same time.
[0010] In a specific implementation of the first aspect, the user applies the selection operation through an external device connected to the electronic device, and the external device may include a touchpad or a mouse. The selection operation received by the electronic device specifically includes: a movement operation after a single click of the external device. The user clicks the external device in the area where the first content to be extracted is located and moves it, so that the movement operation after the single click of the external device controls the movement area of the cursor to cover the area where the first content is located, so as to extract the text corresponding to the first content through the selection operation. This solution can be applicable to electronic devices such as desktop computers, laptops, or mobile phones connected to a mouse or touchpad.
[0011] In a specific implementation of the first aspect, the electronic device includes a touch screen, which can be used as a display device or as an input unit. The selection operation received by the electronic device may include: a sliding operation on the touch screen. The user applies a sliding operation in the area where the first content to be extracted is located, so that the sliding area of the sliding operation on the touch screen covers the area where the first content is located. This solution can be applied to electronic devices such as laptops and mobile phones with touch screens, and text can be easily extracted by sliding operations on text files or image files.
[0012] In a specific implementation of the first aspect, a first application for viewing a target file and a second application for executing a text extraction method provided by an embodiment of the present application are defined. The electronic device opens the first application based on the user's operation and displays the target file in the first application. In response to the user's selection operation, the electronic device injects a preset plug-in of the second application into the first application, and the preset plug-in may be a word extractor. The second application may call the preset plug-in to perform a first word extraction operation and obtain a first word extraction result. In addition, the optical character recognition module is called to perform a second word extraction operation and a second word extraction result. The second application injects a preset plug-in into the process of the first application currently viewing the target file, and copies the first content selected in the first application through the preset plug-in. In this way, it can be ensured that the text is extracted by calling the preset plug-in and the optical character recognition module respectively, without affecting the normal process of the first application currently viewing the target file.
[0013] In a specific implementation of the first aspect, the electronic device includes an application layer, an intermediate layer, and a system layer, the application layer runs a first application and a second application, and the intermediate layer runs an injector, a preset plug-in, an image recognition service, and a state machine associated with the second application. In a specific implementation, the second application calls the injector through the state machine to inject the preset plug-in into the first application, and the preset plug-in is used to copy the text in the area where the first content is located to obtain a first word extraction result. In addition, the second application calls the image recognition service through the state machine, and the image recognition service calls the optical character recognition module to screenshot the image of the area where the first content is located and performs text recognition to obtain a second word extraction result. The state machine runs the main program of the second application, and calls the preset plug-in and the optical character recognition module respectively to perform the word extraction operation, obtains the first word extraction result and the second word extraction result, and then obtains a comprehensive text extraction result based on the first word extraction result and the second word extraction result, and returns the text extraction result to the second application for display.
[0014] In a specific implementation of the first aspect, it is limited that during the process of executing the first word picking operation and the second word picking operation, the electronic device will choose to terminate one of the unnecessary operations. Specifically, the electronic device responds to the selected operation, and after starting to execute the first word picking operation and the second word picking operation, before the first word picking operation ends, it will obtain the real-time word picking result of the first word picking operation as the intermediate word picking result of the first word picking operation. If the intermediate word picking result of the first word picking operation indicates that a word has been picked up, it means that the file type of the target file is a text file, and the word can be picked up by the first word picking operation. Then, the electronic device can terminate the second word picking operation, and continue to execute the first word picking operation, obtain the first word picking result obtained when the first word picking operation ends, and obtain the text extraction result based on the first word picking result.
[0015] In a specific implementation of the first aspect, another processing scheme is provided after obtaining the intermediate word extraction result of the first word extraction operation. After the electronic device obtains the intermediate word extraction result of the first word extraction operation, it is determined that the first word extraction operation did not extract a word, which means that the file type of the target file is not a text file, and the first word extraction operation cannot extract a word. At this time, the first word extraction operation can be terminated, and the second word extraction operation can be continued to obtain a second word extraction result, and the final text extraction result is obtained according to the second word extraction result.
[0016] The solution of terminating one of the word retrieval operations according to the intermediate word retrieval result of the first word retrieval operation can not only ensure that words can be retrieved for target files of different file types, but also reduce unnecessary calculations as much as possible, thereby improving the resource utilization of electronic equipment.
[0017] In a specific implementation of the first aspect, the scheme for obtaining the intermediate word-picking result of the first word-picking operation is further limited. Specifically, when the first word-picking operation and the second word-picking operation are turned on, the electronic device will also turn on a timer to detect whether the first word-picking operation can get a word. The statistical duration of the timer can be set according to the total duration of the conventional word-picking operation, and the statistical duration of the timer is usually less than the total duration of the conventional word-picking operation. In this way, the intermediate word-picking result of the first word-picking operation is obtained before the timer times out. If the target file is a text file, the first word-picking operation should also be able to get at least part of the text before the timer times out. If the timer times out and still does not get the text, it is very likely that the target file is a picture file, and the first word-picking operation cannot effectively get the word. The timer can reduce unnecessary waiting time, reduce invalid calculations, and further improve the resource utilization of the electronic device.
[0018] In a specific implementation of the first aspect, a specific scheme for obtaining a text extraction result according to a first word extraction result and a second word extraction result is defined. In response to a selection operation, the electronic device executes a first word extraction operation to obtain a first word extraction result, and executes a second word extraction operation to obtain a second word extraction result. If the first word extraction result is not empty, it indicates that the file type of the target file should be a text file, and then the first word extraction result can be directly used as the text extraction result.
[0019] If the second word extraction result is not empty, the electronic device can directly use the first word extraction result as the text extraction result. Of course, the first word extraction result can also be adjusted according to the second word extraction result, for example, adjusting and correcting the text that may have errors in the first word extraction result. Alternatively, in the case where the file type of the possible target file may include both text files and image files, the first word extraction result and the second word extraction result are superimposed to obtain a text extraction result with higher accuracy.
[0020] If the second word extraction result is not empty, it means that the file type of the target file should be a picture file. At this time, the first word extraction result may be empty, so the second word extraction result can be directly used as the text extraction result.
[0021] In this embodiment, the method of obtaining the text extraction result is specifically limited according to the first word extraction result and the second word extraction result that may be obtained according to the first content of different file types, so as to ensure that each type of file can obtain a relatively applicable and highly accurate text extraction result.
[0022] In a second aspect, a text extraction device is provided, comprising a processor, wherein the processor is configured to execute any text extraction method as described in the first aspect.
[0023] In a third aspect, an electronic device is provided, which has the function of implementing the text extraction method of the first aspect. The function can be implemented by hardware, or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions.
[0024] In a fourth aspect, an electronic device is provided, comprising: a display screen, a processor and a memory, wherein the display screen and the memory are both coupled to the processor; the memory is used to store computer execution instructions, and when the electronic device is running, the processor executes the computer execution instructions stored in the memory, so that the electronic device performs a text extraction method as described in any one of the first aspects above.
[0025] In a specific implementation of the fourth aspect, the display screen is used to display a first interface; wherein the first interface includes a target file, the file type of the target file is text or a picture, and the content of the picture includes characters;
[0026] The processor is used to receive a user's selection operation on a first content in a target file in a first interface, where the first content includes characters;
[0027] The processor is further configured to, in response to the selection operation, execute a first word-picking operation to obtain a first word-picking result, and execute a second word-picking operation to obtain a second word-picking result; wherein the first word-picking operation includes copying text in the area where the first content is located, and the second word-picking operation includes taking a screenshot of an image of the area where the first content is located and performing text recognition;
[0028] The display screen is used to display a second interface; wherein the second interface includes a target file, and the first content is displayed in a preset manner in the second interface; the second interface also includes a text extraction result obtained based on the first word extraction result and the second word extraction result.
[0029] In a specific implementation of the fourth aspect, the second interface includes a context menu, and the context menu includes at least one operation option of copy, paste, and translate.
[0030] In a specific implementation of the fourth aspect, the electronic device is connected to an external device, and the external device includes a touch pad or a mouse;
[0031] The selection operation includes: a movement operation after a single click of an external device; wherein the movement operation after a single click of the external device controls a moving area of the cursor to cover an area where the first content is located.
[0032] In a specific implementation of the fourth aspect, the electronic device includes a touch screen; the selection operation includes: a sliding operation on the touch screen;
[0033] The sliding area of the sliding operation on the touch screen covers the area where the first content is located.
[0034] In a specific implementation of the fourth aspect, the first interface and the second interface are interfaces of a first application, and the first application provides a viewing function of the target file;
[0035] The processor is further configured to:
[0036] In response to the selection operation, injecting a preset plug-in of the second application into the first application; wherein the second application provides a text extraction function;
[0037] The preset plug-in is called to perform a first word picking operation to obtain a first word picking result, and the optical character recognition module is called to perform a second word picking operation to obtain a second word picking result.
[0038] In a specific implementation of the fourth aspect, the electronic device includes an application layer, an intermediate layer, and a system layer, the application layer runs a first application and a second application, and the intermediate layer runs an injector, a preset plug-in, an image recognition service, and a state machine associated with the second application;
[0039] The second application calls the injector through the state machine to inject the preset plug-in into the first application;
[0040] The preset plug-in copies the text in the area where the first content is located to obtain a first word extraction result;
[0041] The step of calling the optical character recognition module to perform a second word extraction operation to obtain a second word extraction result includes:
[0042] The second application calls the image recognition service through the state machine, and the image recognition service calls the optical character recognition module to capture the image of the area where the first content is located and perform text recognition to obtain a second word extraction result.
[0043] In a specific implementation of the fourth aspect, the processor is further configured to:
[0044] Obtaining the intermediate word extraction result of the first word extraction operation;
[0045] According to the intermediate word picking result of the first word picking operation, judging whether the first word picking operation has picked up a word;
[0046] If the first word-picking operation gets a word, the second word-picking operation is terminated;
[0047] A text extraction result is obtained according to the first word extraction result of the first word extraction operation.
[0048] In a specific implementation of the fourth aspect, the processor is further configured to:
[0049] If the first word-picking operation fails to get a word, the first word-picking operation is terminated;
[0050] A text extraction result is obtained according to the second word extraction result of the second word extraction operation.
[0051] In a specific implementation of the fourth aspect, the step of obtaining an intermediate word extraction result of the first word extraction operation includes:
[0052] Start the timer;
[0053] Before the timer times out, an intermediate word extraction result of the first word extraction operation is obtained.
[0054] In a specific implementation of the fourth aspect, the processor further includes:
[0055] If the first word extraction result is not empty, the first word extraction result is used as the text extraction result;
[0056] If the first word extraction result is empty and the second word extraction result is not empty, the second word extraction result is used as the text extraction result.
[0057] In a specific implementation of the fourth aspect, the processor further includes:
[0058] If both the first word extraction result and the second word extraction result are not empty, the first word extraction result is adjusted according to the second word extraction result, and the adjusted first word extraction result is used as the text extraction result.
[0059] In a fifth aspect, an electronic device is provided, comprising: a processor; the processor is used to couple with a memory, and after reading instructions in the memory, execute a text extraction method as described in any one of the first aspects above according to the instructions.
[0060] In a sixth aspect, a computer-readable storage medium is provided, wherein instructions are stored in the computer-readable storage medium, and when the computer-readable storage medium is run on a computer, the computer can execute any one of the text extraction methods in the first aspect.
[0061] In a seventh aspect, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to execute any text extraction method of the first aspect.
[0062] In an eighth aspect, a control device (for example, the control device may be a chip system) is provided, which includes a processor for supporting the control device to implement the functions involved in the above-mentioned first aspect, such as a text extraction method.
[0063] In a possible design, the device further includes a memory, which is used to store program instructions and data necessary for controlling the device. When the device is a chip system, it can be composed of a chip, or it can include a chip and other discrete devices.
[0064] Among them, the technical effects brought about by any design method in the second aspect to the eighth aspect can refer to the technical effects brought about by different design methods in the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] Figure 1 A schematic diagram of the operation and interface of an electronic device for extracting words from the first type of files;
[0066] Figure 2 A schematic diagram of the operation and interface of the electronic device for extracting words from the second type of files;
[0067] Figure 3 One of the application scenario schematic diagrams of the text extraction method provided in the embodiment of the present application;
[0068] Figure 4 A second schematic diagram of an application scenario of the text extraction method provided in an embodiment of the present application;
[0069] Figure 5 One of the flowcharts of the text extraction method provided in the embodiment of the present application;
[0070] Figure 6 A schematic diagram of an interface of a text extraction method provided in an embodiment of the present application;
[0071] Figure 7 The second flowchart of the text extraction method provided in the embodiment of the present application;
[0072] Figure 8 A schematic diagram of the internal framework of an electronic device provided in an embodiment of the present application;
[0073] Fig. 9 Flowchart 3 of the text extraction method provided in the embodiment of the present application
[0074] Fig.10 A fourth flowchart of the text extraction method provided in an embodiment of the present application;
[0075] Fig.11 A fifth flowchart of the text extraction method provided in the embodiment of the present application;
[0076] Fig.12 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0077] The following is a description of exemplary embodiments of the present application in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present application. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0078] To facilitate understanding, some technical common sense involved in the embodiments of the present application is first introduced.
[0079] The files processed by the electronic device can be mainly divided into the first type of files and the second type of files according to the file format and editable state. Among them, the first type of files are mainly document files, which can include Word documents, notepads, Excel tables, etc. The first type of files usually contain text, and the text is usually in a state that can be directly copied or edited. For the convenience of description, the first type of files can be referred to as text files. Text files can include various types of files in which the text is in a state that can be directly copied or edited. The second type of files are mainly picture files, which can include pictures in formats such as jpg, png, bmp, etc., PDF files that cannot be directly edited, etc. The second type of files can contain only image elements or text elements, and the text in the second type of files is usually in a state that cannot be directly copied or edited. For the convenience of description, the second type of files can be referred to as picture files. Picture files can include various types of files in which the characters in the pictures and other files are in a state that cannot be directly copied or edited. Users can browse files in applications such as browsers, Word document editors, picture editing software, and device desktops of electronic devices. For the convenience of description, applications that can view files such as browsers, Word document editors, picture editing software, and device desktops of electronic devices are defined as first applications. The first application may be a system application of the electronic device itself, or a third-party application running on the electronic device.
[0080] When a user views a file in the first application of an electronic device, he or she may need to extract text from the file (i.e., extract words from the text in the file), copy, translate, and perform other operations on the text content obtained by extracting words. The files involved in the extracting operation usually include the above-mentioned text files and image files. Most of the existing second applications are word extracting plug-ins that come with the device system or word extracting plug-ins that come with various files, and different types of files require different word extracting plug-ins.
[0081] like Figure 1 and Figure 2As shown, all of them are operation and interface schematic diagrams of an electronic device performing text extraction operations on a file. For ease of description, the source file for text extraction is defined as a target file, and the type of the target file can be a text file or a picture file. In addition, the text content targeted by the text extraction operation is defined as the first content, and the first content corresponds to some characters in the target file. It should be noted that the text extraction scheme provided in the embodiment of the present application can perform text extraction on a set including multiple characters and obtain a text extraction result, but if the first content does not include characters, the text extraction method provided in the embodiment of the present application can also be executed, but the obtained text extraction result may be empty.
[0082] like Figure 1 As shown, the electronic device is a laptop computer, and the file type of the target file for text extraction is a text file, taking a Word document as an example. The electronic device is connected to an external device, such as Figure 1 The mouse shown is used to receive the selection operation applied by the user. Of course, the external device can also be a touch pad, a stylus, or other device capable of applying the selection operation, without limitation.
[0083] like Figure 1 In the first interface shown in a, the electronic device opens the first application and displays the target file based on the operation on the first application. The user wants to select the first content in the target file as "mainly depends on the sea surface temperature". The user first moves the mouse so that the cursor moves to the starting position of the first content. The electronic device detects the selection operation of the user clicking the left mouse button and triggers the word retrieval operation. The user clicks the left button and moves the mouse to the right. The electronic device receives the selection operation of the user clicking the left button and moving the mouse, and controls the moving area of the cursor to cover the area where the first content is located. The moving area of the cursor is considered to be the focus area of the selection operation. The text content composed of characters in the focus area is the first content, which is the text extraction result indicated by the user's selection operation. As shown in Figure 1 In the second interface shown in b, the electronic device displays the target text and the text extraction result of the target text in the first application. After the electronic device obtains the first content in the Word document by extracting words, it can continue to receive operations such as copying, translating, and pasting the first content by the user through input and output units such as a mouse and keyboard. In other words, the text extraction operation of the electronic device for the text file is to perform text copying + character recognition operations on the focus area of the selected operation to obtain the text.
[0084] like Figure 2 As shown, the object of text extraction is an image file, such as a picture, and the user wants to select the first content of the image file, which is "transportation" in the picture. Figure 2In the first interface shown in a in the figure, the electronic device opens the first application based on the user's operation on the first application and displays the target file in the first application. The user first moves the mouse to the image and clicks the left mouse button to select the image. The electronic device receives the mouse movement to the first content in the image, clicks the left mouse button and moves the cursor so that the moving area of the cursor covers the area where the first content is located. In response to the user's selection operation of clicking the left mouse button and moving the mouse, the electronic device uses the screenshot frame to take a screenshot of the focus area corresponding to the selection operation, and obtains a screenshot covering the first content. Figure 2 In the second interface shown in b, the electronic device analyzes the image feature points of the screenshot to identify the text in the screenshot, and obtains the text recognition result. In the second interface, the electronic device displays the target file in the first application and the text recognition result selected for the target file. It can be seen that the word acquisition scheme of the electronic device for the image file is to perform a screenshot + image analysis operation on the focus area of the selected operation to obtain the text. Among them, the image analysis operation can be optical character recognition (OCR), which refers to the process in which the electronic device determines the shape of the element in the picture by detecting the dark and light patterns, and then translates the shape into computer text using a character recognition method. That is, the electronic device uses an optical method to convert the text in the paper document into a black and white dot matrix image file for printed characters, and converts the text in the image into a text format through recognition software. An optical character recognition module is provided in the electronic device, including a screenshot control and an optical character recognition device, and the electronic device can call the optical character recognition module to perform screenshot and image recognition operations on the target text.
[0085] The existing operation methods and recognition processes for extracting words for text files and image files are different. Users are required to first identify whether the file type to be extracted belongs to the first type of document that can be directly copied for word extraction, or to an image file that requires screenshot analysis for word extraction, and then apply corresponding word extraction operations to different types of files. The word extraction operation is relatively cumbersome. In addition, it is also possible that the user directly applies the copy word extraction operation applicable to text files to the image file, and then switches to the screenshot word extraction operation applicable to the image file after finding that the word extraction fails. The word extraction operation is cumbersome and time-consuming.
[0086] Based on this, a text extraction method provided in an embodiment of the present application can execute a relatively general word extraction process for different types of files, without the need for users to manually determine file types and distinguish word extraction methods, thereby simplifying the word extraction operation and reducing the waiting time for users to extract words.
[0087] The text extraction method provided in the embodiment of the present application is applied to an electronic device, in which a second application is running, and the text extraction method can be executed after the second application is turned on. The second application can be manually turned on by the user, by clicking the icon of the second application, and the icon lights up, indicating that the second application is turned on. The second application can also be turned on by system customization or manually by the user when the electronic device is used for the first time. Alternatively, the second application can also be pre-associated with a first application that may trigger word extraction, such as a system application or a third-party application. When these pre-associated first applications are turned on, the second application is synchronously turned on to perform the word extraction operation.
[0088] In the embodiments of the present application, the electronic device may be a personal computer (PC), a tablet computer, a laptop computer, a portable computer (such as a mobile phone), a wearable electronic device (such as a smart watch), an augmented reality (AR) device, a virtual reality (VR) device, a vehicle-mounted computer, etc. The following embodiments do not impose any special restrictions on the specific form of the electronic device.
[0089] like Figure 3 FIG. 1 is a schematic diagram of one of the application scenarios of the text extraction method provided in the embodiment of the present application. Figure 3 The electronic device to which the text extraction method is applied is a laptop computer. The laptop computer can respond to the user's operation to open the control center of the laptop computer; and respond to the user's operation of moving the mouse to move the cursor to the icon position of the second application (such as Figure 3 Before receiving the user's click on the icon of the second application by controlling the cursor with the mouse, as shown in a in FIG. Figure 4 As shown in a in FIG. 1 , the icon of the second application is not highlighted. Figure 3 As shown in b, in response to the user controlling the cursor with the mouse to click the icon of the second application, the icon of the second application will be highlighted. At this time, the second application is started, and the laptop computer can execute the method of the embodiment of the present application based on the second application. The format of highlighting can include bolding the edge of the icon, displaying the fill color, highlighting, etc., without limitation.
[0090] like Figure 4 FIG. 2 is a schematic diagram of a second application scenario of the text extraction method provided in an embodiment of the present application. Figure 4 The electronic device used in the Chinese text extraction method is a mobile phone. Figure 4 As shown in a in FIG. 1 , before or after opening the first application, the user can drag out the hidden control center page by applying a sliding operation from the top or bottom of the electronic device, as shown in FIG. Figure 4 As shown in b in FIG. 1 , the control center page of the electronic device displays the icon of the second application. Figure 4As shown in c, the user clicks the icon of the second application in the control center, and the icon of the second application switches to a lit state. At this time, the second application is started, and the mobile phone can support the method of the embodiment of the present application based on the second application.
[0091] Of course, in other cases, the user can also find the start button of the second application in the settings of the electronic device and open it, and can also open the second application. Of course, the type of start operation can also be set by the system or by the user. For example, the long press operation, double-click operation, single-click and drag operation in the text viewing application can be set as the start operation of the second application, without limitation. The second application in this embodiment can be in a variety of ways. For example, it can be a program plug-in attached to the first application, which runs as the first application is opened. The second application can also be a second application that runs independently of the first application, such as Magic Text, etc., without limitation. In some embodiments, the above-mentioned second application can also be a small program in an electronic device. After the electronic device is turned on, the small program can be automatically opened. Alternatively, in response to the user's startup operation (such as the startup operation described above), the small program starts.
[0092] In the text extraction method provided in the embodiment of the present application, a selection operation is predefined in the electronic device to trigger the second application to start executing the word extraction process. The selection operation can be set according to the word extraction habits of most users. For example, the operation of receiving a click on the left mouse button of the computer is defined as a selection operation, or the operation of receiving a long press and dragging on the left mouse button of the computer is defined as a selection operation. Of course, the operation of the user's finger acting on the touch screen and continuously sliding can also be defined as a selection operation, or the long press operation of the user acting on the file exceeding a certain pressing time or a certain pressing force value can be defined as a selection operation. The specific type of the selection operation can be pre-set by the system of the electronic device to meet the word extraction habits of most users. Of course, the specific type of the selection operation can also be manually set by the user, and the custom selection operation is more in line with the user's personal usage habits, with higher word extraction efficiency and better user experience.
[0093] After the electronic device detects the selection operation, the text in the focus area can be extracted. The focus area is the word extraction area selected by the selection operation. The focus area on which the selection operation is applied in real time is determined, and the focus area is the area where the second application extracts words. The second application can determine the word extraction result of this word extraction operation based on the word extraction result in the focus area.
[0094] In a specific implementation, the electronic device may first determine the starting position of the selection operation, and then determine the focus area for triggering the operation based on the starting position and the real-time moving area of the selection operation. If the selection operation is an operation in which the user clicks the left button of the mouse and drags, the starting position of the selection operation may be the position when the user clicks the left button of the mouse and starts dragging. Figure 1 The cursor position for a text file can also be Figure 2 The starting position of the screenshot frame for the image file, from the time the user clicks the left mouse button and drags to the end of the dragging, the moving area of the cursor or the covered area of the screenshot frame during this process is the focus area.
[0095] In another specific implementation, the electronic device may first determine the starting position of the selection operation, and use the starting position as a reference point to define an area as the focus area, so that the user does not need to directly drag to cover the entire word-picking area. Figure 1 As shown, if the selection operation is an operation in which the user clicks the left mouse button, the cursor position at this time is the starting position of the selection operation, and the corresponding area of the text line or text segment where the cursor is located can be directly used as the focus area. Of course, the range size of the demarcated area can also be set, for example, the text area of N characters after the starting position of the selection operation is used as the focus area, etc., without limitation.
[0096] After the electronic device detects the selection operation, it can perform a text extraction operation on the focus area of the selection operation. In order to omit the user from distinguishing the file type of the target file, the text extraction operation performed on the focus area of the selection operation includes at least two types of word extraction operations applicable to different file types, and at least two types of word extraction operations applicable to different file types are opened at the same time. In this way, even if one of the word extraction operations fails, the electronic device can quickly obtain the word extraction results of other word extraction operations and finally obtain a usable word extraction result. Compared with the existing solution of switching to another word extraction operation when one word extraction operation fails, this reduces the user's waiting time for word extraction to a certain extent.
[0097] like Figure 5As shown, in an embodiment of the present application, the electronic device simultaneously executes a first word-picking operation applicable to a text file and a second word-picking operation applicable to a picture file. The electronic device creates a first word-picking thread corresponding to the first word-picking operation and a second word-picking thread corresponding to the second word-picking operation in parallel, and obtains corresponding word-picking results through the two parallel word-picking threads. The first word-picking thread created by the electronic device can call a preset plug-in that can provide a text copy function to execute, and the second application interacts with the preset plug-in to execute the first word-picking operation. Specifically, the preset plug-in can be a word-picking device, or other plug-ins that can provide a text copy function. At the same time, the second word-picking thread created by the electronic device can call an optical character recognition module to execute, and the second word-picking operation is executed through the interaction between the optical character recognition module and the second application. It should be noted that the simultaneous start and parallel execution here are not limited to the absolute simultaneous situation, but can be understood as the processing of common concurrent threads by the electronic device in the execution of a computer program.
[0098] Continue to refer to Figure 5 , the electronic device opens the first application based on the user's operation and displays the target file currently viewed by the user. The target file can be a document-type, editable text file, or a picture-type, non-editable picture file. The electronic device receives the selection operation applied by the user to the target file in the first application, and the second application simultaneously generates two start word retrieval instructions, which are used to instruct the first word retrieval thread to start the first word retrieval operation and to instruct the second word retrieval thread to start the second word retrieval operation.
[0099] The first word extraction thread performs a first word extraction operation, obtains a first word extraction result, and feeds the first word extraction result back to the second application. The second word extraction thread performs a second word extraction operation, obtains a second word extraction result, and feeds the second word extraction result back to the second application.
[0100] The second application obtains a text extraction result based on the first word extraction result obtained by the first word extraction thread and the second word extraction result obtained by the second word extraction thread. The text extraction result can be considered as the word extraction content finally obtained by the preset plug-in this time. The electronic device can display a second interface, which displays the target text in the second application and the text extraction result of the target file. The displayed text extraction result can be a plain text or a text file drawn according to a preset format, so that the first content is displayed in a preset format.
[0101] like Figure 6 FIG. 1 is a schematic diagram of an interface of a text extraction method provided by an embodiment of the present application. For a scenario where the target text is a text file, after obtaining the text extraction result, the electronic device Figure 6As shown in a in FIG, the second application can display the text extraction result in the window where the first application is located, and can also synchronously display the associated menu of the text extraction result. For the scenario where the target file is a picture file, the electronic device can only capture the picture of the area where the first content is located (such as Figure 6 b), you can also intercept the entire picture of the first interface, and after obtaining the text extraction result, that is, "transportation", you can display the text extraction result obtained by identifying the partial picture or the entire picture in the second interface, as well as the operation menu associated with the text extraction result, that is, the associated menu. For easy distinction, Figure 6 As shown in b, the text extraction content can be highlighted relative to the image display effect in the first interface to feed back the screenshot area of the text extraction to the user.
[0102] The context menu may include subsequent operations that the user can perform on the text extraction result, such as copying to a clipboard, copying to a favorite file, translating, searching, etc.
[0103] In other implementations, the user may also pre-set a default operation that can be performed after the second application obtains the text extraction result, for example, storing the text extraction result in a favorite file or an excerpt document. Of course, the user may also pre-set the operable items of the associated menu, for example, adjusting the display order of the operable items, modifying the type of the operable items, etc., without limitation.
[0104] It should be noted that the first word-picking result obtained by the second application may be the text content actually obtained after the first word-picking thread executes the first word-picking operation. The text content may include only text characters, or may include text characters and text formats drawn according to the text characters and a preset drawing algorithm. Of course, the first word-picking operation may be interrupted actively or passively, then the corresponding first word-picking result may be information indicating the interruption of the first word-picking operation, or the word-picking content obtained before the interruption. In addition, the first word-picking operation may also fail to pick up words, that is, no words are picked up, then the corresponding first word-picking result may be empty or information indicating the failure of word-picking.
[0105] Correspondingly, the second word extraction result fed back by the second word extraction thread may have the above-mentioned multiple situations as the first word extraction result. To avoid repetition, they will not be described one by one here.
[0106] like Figure 7 As shown, it is the second flow chart of the text extraction method provided in the embodiment of the present application. Figure 8 The figure is a schematic diagram of the internal framework of the electronic device provided in the embodiment of the present application. Figure 7 and Figure 8 , the specific process of the first word extraction thread is explained in detail.
[0107] The electronic device may mainly include an application layer, an intermediate layer and a system layer, wherein the application layer interacts with the intermediate layer, and the intermediate layer interacts with the system layer. Among them, the application layer runs upper layer applications, such as the first application and the second application. The intermediate layer runs an injector, a preset plug-in, a state machine and an image recognition service, and the system layer runs a device system, including hardware structures such as a central processing unit (CPU), a window, and an image processing unit (GPU). The injector of the intermediate layer can interact with the application layer to inject the preset plug-in into the first application. The preset plug-in can be injected into the first application, and the system function of the device system can be called to intercept the data pasted to the clipboard of the device system to obtain the first word extraction result. The image recognition service can call the image processor in the device system to identify the characters in the picture to obtain the second word extraction result. The state machine runs the main program of the second application, and can determine the window process where the focus is located to the device system, and then determine the first application, the focus area and other information. In addition, the state machine running the main program can also obtain the first word extraction result and the second word extraction result respectively, and return the comprehensive result to the second application for display.
[0108] After the first word retrieval thread is created, word retrieval begins. The second application calls the injector to instruct the injection of the preset plug-in into the first application, and the preset plug-in is injected into the first application. Under the premise of not affecting the process of the first application itself, the preset plug-in is injected to obtain relevant information associated with word retrieval in the first application. The second application only interacts with the preset plug-in injected into the process of the first application and does not affect the original process of the first application, so as to enable the second application to perform the first word retrieval operation in the first application. Specifically, it includes the following steps:
[0109] 1. The second application injects the preset plug-in into the first application.
[0110] The main program of the second application can inject the preset plug-in into the current process of the first application in the form of a dynamic link library (DLL). DLL injection is to put the dynamic program code block of a preset plug-in into the address space of the process of the first application, so that the preset plug-in becomes part of that process, that is, part of the code is added to the first application. This injected preset plug-in will not affect the execution of the current process of the first application, and can obtain information in the process, such as text content copied in the first application.
[0111] 2. The second application simulates the copy command, ie, calls the Ctrl+C control of the electronic device.
[0112] The system and the first application can both trigger a copy command to copy the text content in the first application. The copy command calls the Ctrl+C control to copy the text. To copy the text, the text content is copied in the focus area, but it may not necessarily copy the text content, that is, the copied text content may be empty.
[0113] 3. The preset plug-in determines whether the copy command is triggered by the second application, and if it is triggered by the second application, obtains the copied text content.
[0114] If the copy command is triggered by the system or the first application, the copy command will save the text content to the clipboard after obtaining it. However, in the embodiment of the present application, the simulated copy command is triggered by the second application, and the second application will not save the text content directly to the clipboard after obtaining it. Therefore, the preset plug-in first determines whether the copy command is triggered by the second application.
[0115] If the preset plug-in determines that the copy command is triggered by the second application, the operation of pasting the copied text content into the clipboard is intercepted, and the copied text content is returned to the second application instead.
[0116] If the preset plug-in determines that the copy command is not triggered by the second application, but by the system or the first application, no processing is required to maintain the original logic of the system or the first application, which is usually to paste the copied text content into the clipboard.
[0117] The default plug-in intercepts the copied text content to the clipboard by modifying the function that calls the paste function to the clipboard. The relevant program segment may include the following content:
[0118] Change the system's paste-to-clipboard function Setdata to Setmydata, that is, change the original logic of Ctrl+C->Setdata()->clipboard to the preset plug-in's Ctrl+C->Setmydata() to achieve interception.
[0119] 4. Determine whether the preset plug-in has obtained the word.
[0120] If the copied text content is not empty, it means that the preset plug-in has obtained a word. The original text of the text content, or the text after certain formatting, can be returned to the second application as the first text. Then, the first word extraction result output by the first word extraction thread can include the first text.
[0121] If the copied text content is empty, it means that the preset plug-in has not obtained any words. You can repeat the word extraction operation, or directly determine that the first word extraction thread has not obtained any words.
[0122] In addition, in order to save unnecessary operations, a timer can also be set to limit the duration of the preset plug-in to perform the word retrieval operation. When word retrieval starts, the timer starts counting, and the preset plug-in repeatedly performs the word retrieval operation and continuously updates the acquired text content. If the text content is still not acquired when the timer ends, it means that the first word retrieval thread has not acquired a word.
[0123] If the first word retrieval thread fails to retrieve a word, the returned first word retrieval result may be empty or may be indication information that no word has been retrieved.
[0124] In the first word retrieval thread, words are retrieved by injecting a preset plug-in into the process of the first application. This can not only ensure that the second application obtains the text content copied in the first application, but also avoid the situation where the copied text content is directly pasted into the clipboard, which may cause information leakage, thereby improving information security.
[0125] like Fig. 9 As shown, it is the third flow chart of the text extraction method provided in the embodiment of the present application. Figure 8 and Fig. 9 , the specific process of the second word extraction thread is explained in detail.
[0126] The second word extraction operation for the image file usually adopts the optical character recognition method. Based on the start word extraction instruction, the second application requests the optical character recognition module to perform optical character recognition. The optical character recognition module first takes a screenshot of the focus area to obtain the screenshot image. Then, the text content in the screenshot image is subjected to character recognition to obtain the corresponding text, which is returned to the second application as the second text.
[0127] It should be noted that even if the optical character recognition module is used for character recognition, there may be a situation where no word can be obtained. In this case, the second text may not be returned, or the returned second text may be an empty text.
[0128] The electronic device adds a second word retrieval thread for the word retrieval operation, which can quickly retrieve words when the target file is a picture file, thereby improving the speed and efficiency of word retrieval.
[0129] On the basis of the above implementation, the embodiment of the present application also provides another text extraction method. After simultaneously starting the first word extraction thread and the second word extraction thread, the word extraction thread that cannot extract words successfully or is unnecessary is interrupted according to the intermediate word extraction result, and the threads of the electronic device are reduced and the memory usage is reduced while ensuring fast word extraction.
[0130] Considering that the first word extraction thread uses text copying to extract words, the accuracy of word extraction is relatively higher than the word extraction method of image recognition used by the second word extraction thread. Therefore, it can be considered to refer to the intermediate word extraction results of the first word extraction thread as the judgment basis for the subsequent terminal word extraction thread. Fig.10 and Fig.11 As shown, it is another flowchart diagram of the text extraction method provided in the embodiment of the present application, and a scheme for interrupting one of the word extraction threads is added.
[0131] After the electronic device starts the first word picking thread and the second word picking thread, it will first obtain the intermediate word picking result of the first word picking thread within a preset period after the start. The preset period can be a pre-set period, and the duration of the preset period is usually less than the total duration of the first word picking operation performed by the first word picking thread, or the duration of the preset period is set to be less than the total duration of the conventional word picking operation, and the duration of the preset period can be set to half of the total duration of the conventional word picking operation.
[0132] The intermediate word extraction result of the first word extraction thread may be the first text obtained within a preset period of time after the first word extraction operation is started. The first text may be empty or not empty. If the first text is empty, it can be considered that the first word extraction thread has not extracted any words; if the first text is not empty, it means that the first word extraction thread has extracted any words.
[0133] The second application determines whether the first word-picking thread can get a word based on the intermediate word-picking result, and then selects the subsequent interrupted or retained word-picking thread based on the intermediate word-picking result of the first word-picking thread. Usually, there is Fig.10 and Fig.11 These two situations.
[0134] like Fig.10 As shown, if the intermediate word-picking result is not empty, it means that the first word-picking thread can pick up words, then the first text updated and obtained by the first word-picking thread can be retained, and the second word-picking thread can be interrupted. The second application can send an end-word-picking instruction to the second word-picking thread to release the second word-picking thread. After the first word-picking thread finishes picking up words, the text content finally obtained is used as the first text to obtain the first word-picking result. The preset plug-in sends the first word-picking result to the second application. The second application can obtain the text extraction result only based on the first word-picking result, and display the text extraction result and the associated menu. Of course, when the target file is a text file, the second word-picking operation can also get words, that is, the second word-picking result is not empty. At this time, based on the high accuracy of the first word-picking operation directly copying the text, the first word-picking result can also be adjusted according to the second word-picking result, and the first word-picking result can be checked for omissions, etc., to obtain the final text extraction result, and the accuracy of the text extraction result is relatively higher.
[0135] like Fig.11 As shown, if the intermediate word extraction result is empty, it means that the first word extraction thread cannot extract words. At this time, the second application can send an end word extraction instruction to the first word extraction thread to release the first word extraction thread. The second word extraction thread continues to be reserved until the final second word extraction result is sent to the second application. The second application can obtain the text extraction result only based on the second word extraction result, and display the text extraction result and the associated menu.
[0136] The text extraction method provided by the embodiment of the present application is based on the premise that the accuracy of the text copying method is higher. When the intermediate word extraction result of the first word extraction thread is not empty, the second word extraction thread is directly interrupted, and the first word extraction thread that can obtain a higher accuracy is retained to continue to extract words, and the final word extraction result is obtained. When the intermediate word extraction result of the first word extraction thread is empty, the first word extraction thread is directly interrupted, and the second word extraction result that may be able to extract words is retained. In this way, unnecessary threads can be reduced and the operating efficiency of the electronic device can be improved.
[0137] In summary, the text extraction method provided in the embodiment of the present application does not need to distinguish whether it is a text word extraction or an image recognition word extraction scenario, and uses a text extraction method applicable to a variety of file types to quickly obtain available word extraction content. In addition, when performing text word extraction, the electronic device will request a test text process, which greatly simplifies the word extraction business process, and seamlessly connects to the OCR process word extraction when no word is obtained or the timeout occurs. Based on a fast and efficient text extraction method, users can be provided with more functions such as copying, translation, and reading aloud, and the information security in the word extraction process is improved.
[0138] In addition, an embodiment of the present application further provides an electronic device, comprising an input unit, a display screen, a memory, and a processor, wherein the input unit, the display screen, and the memory are all coupled to the processor;
[0139] The memory stores computer-executable instructions;
[0140] The processor executes the computer-executable instructions stored in the memory, so that the electronic device executes the text extraction method provided by the above embodiment.
[0141] Furthermore, the input unit includes an external device or a touch screen, and the external device includes a touch pad or a mouse. In addition to these main components, the electronic device also includes components for realizing basic functions. Fig.12 Provide specific instructions.
[0142] like Fig.12As shown, the control device for implementing the functions of the electronic device may include: a display screen 1201, a memory 1202, a processor 1203, a communication module 1204, and an input unit 1205. The above-mentioned components may be connected via one or more communication buses 1206. The display screen 1201 may include a display panel 12011 and a touch sensor 12012, wherein the display panel 12011 is used to display an image, and the touch sensor 12012 may transmit the detected touch operation to the application processor to determine the touch event type, and provide a visual output related to the touch operation through the display panel 12011.
[0143] The communication module 1204 can connect the electronic device to other terminals for communication and realize data interaction, such as transmitting the text content obtained by the text extraction method provided in the embodiment of the present application to other terminals, or obtaining the translation content of the corresponding text content returned by the server, etc., without limitation. The input unit 1205 can be a mouse, keyboard, etc., for receiving user input operations, such as the selection operation involved in the text extraction method of the embodiment of the present application. The communication bus 1206 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus 1206 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.12 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0144] The processor 1203 may include one or more processing units, for example: the processor 1203 may include an application processor, a modem processor, a graphics processor, an image signal processor, a controller, a video codec, a digital signal processor, a baseband processor, and / or a neural network processor, etc. Among them, different processing units can be independent devices or integrated into one or more processors. The memory 1202 is coupled to the processor 1203 and is used to store various software programs and / or computer instructions. The memory 1202 may include a volatile memory and / or a non-volatile memory. When the processor executes the computer instructions, the electronic device can perform the various functions or steps in the above method embodiments.
[0145] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored. When the computer-readable storage medium is run on a computer, the computer is enabled to execute the text extraction method provided in the above embodiment.
[0146] The embodiment of the present application also provides a computer program product including instructions, which, when executed on a computer, enables the computer to execute the text extraction method provided in the above embodiment.
[0147] The specific implementation methods of the electronic device, control device, computer-readable storage medium, and computer program product containing instructions provided in the embodiments of the present application and the technical effects brought about by them can be found in the specific implementation process of the text extraction method provided in the aforementioned embodiments and the technical effects brought about by them, which will not be repeated here.
[0148] In some embodiments, through the description of the above implementation methods, technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. The specific working process of the system, device and unit described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0149] Each functional unit in each embodiment of the present application can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above integrated unit can be implemented in the form of hardware or in the form of software functional units.
[0150] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as flash memory, mobile hard disk, read-only memory, random access memory, disk or optical disk.
[0151] The above is only a specific implementation of the embodiment of the present application, but the protection scope of the embodiment of the present application is not limited thereto, and any changes or replacements within the technical scope disclosed in the embodiment of the present application should be included in the protection scope of the embodiment of the present application. Therefore, the protection scope of the embodiment of the present application should be based on the protection scope of the claims.
Claims
1. A text extraction method, characterized in that: Applied to electronic equipment, the method comprises: Display a first interface; wherein the first interface includes a target file, the file type of the target file is text or picture, and the content of the picture includes characters; receiving a user selection operation on a first content in the target file in the first interface, where the first content includes characters; In response to the selection operation, a first word picking operation is performed to obtain a first word picking result, and a second word picking operation is performed to obtain a second word picking result; wherein the first word picking operation includes copying text in the area where the first content is located, and the second word picking operation includes taking a screenshot of an image of the area including the first content and performing text recognition; A second interface is displayed; wherein the second interface includes the target file, and the first content is displayed in a preset manner in the second interface; the second interface also includes a text extraction result obtained based on the first word extraction result and the second word extraction result.
2. The text extraction method according to claim 1, characterized in that: The second interface includes a context menu, and the context menu includes at least one operation option of copying, pasting, and translating.
3. The text extraction method according to claim 1 or 2, characterized in that: The electronic device is connected to an external device, and the external device includes a touch pad or a mouse; The selection operation includes: a movement operation after a single click of the external device; wherein the movement operation after a single click of the external device controls a moving area of a cursor to cover an area where the first content is located.
4. The text extraction method according to claim 1 or 2, characterized in that: The electronic device includes a touch screen; the selection operation includes: a sliding operation on the touch screen; The sliding area of the sliding operation on the touch screen covers the area where the first content is located.
5. The text extraction method according to any one of claims 1 to 4, characterized in that: The first interface and the second interface are interfaces of a first application, and the first application provides a viewing function of the target file; The method further comprises: In response to the selection operation, injecting a preset plug-in of a second application into the first application; wherein the second application provides a text extraction function; The step of performing the first word extraction operation to obtain the first word extraction result and performing the second word extraction operation to obtain the second word extraction result includes: The preset plug-in is called to perform the first word picking operation to obtain the first word picking result, and the optical character recognition module is called to perform the second word picking operation to obtain the second word picking result.
6. The text extraction method according to claim 5, characterized in that: The electronic device comprises an application layer, an intermediate layer and a system layer, the application layer runs the first application and the second application, the intermediate layer runs an injector, a preset plug-in, an image recognition service and a state machine associated with the second application; The step of calling the preset plug-in to perform the first word extraction operation to obtain the first word extraction result includes: The second application calls the injector through a state machine to inject the preset plug-in into the first application; The preset plug-in copies the text in the area where the first content is located to obtain the first word extraction result; The step of calling the optical character recognition module to perform the second word picking operation to obtain the second word picking result includes: The second application calls the image recognition service through the state machine, and the image recognition service calls the optical character recognition module to capture an image of the area where the first content is located and perform text recognition to obtain the second word extraction result.
7. The text extraction method according to any one of claims 1 to 6, characterized in that: The step of executing a first word extraction operation to obtain a first word extraction result and executing a second word extraction operation to obtain a second word extraction result in response to the selection operation includes: Obtaining an intermediate word extraction result of the first word extraction operation; According to the intermediate word picking result of the first word picking operation, determining whether the first word picking operation has picked up a word; If the first word picking operation picks a word, the second word picking operation is terminated; The text extraction result is obtained according to the first word extraction result of the first word extraction operation.
8. The text extraction method according to claim 7, characterized in that: After the step of judging whether the first word picking operation has picked up a word according to the intermediate word picking result of the first word picking operation, the method further comprises: If the first word picking operation fails to pick up a word, terminating the first word picking operation; The text extraction result is obtained according to the second word extraction result of the second word extraction operation.
9. The text extraction method according to claim 7 or 8, characterized in that: The step of obtaining the intermediate word extraction result of the first word extraction operation includes: Start the timer; Before the timer times out, an intermediate word extraction result of the first word extraction operation is obtained.
10. The text extraction method according to any one of claims 1 to 7, characterized in that: After the steps of executing the first word extraction operation to obtain the first word extraction result and executing the second word extraction operation to obtain the second word extraction result in response to the selection operation, the method further includes: If the first word extraction result is not empty, taking the first word extraction result as the text extraction result; If the first word extraction result is empty and the second word extraction result is not empty, the second word extraction result is used as the text extraction result.
11. The text extraction method according to claim 10, characterized in that: The step of using the first word extraction result as the text extraction result if the first word extraction result is not empty includes: If both the first word picking result and the second word picking result are not empty, the first word picking result is adjusted according to the second word picking result, and the adjusted first word picking result is used as the text extraction result.
12. The text extraction method according to any one of claims 1 to 11, characterized in that: The second word retrieval operation includes taking a screenshot of the first interface and performing text recognition, the first interface including the area where the first content is located; or The second word extraction operation includes taking a screenshot of an image of the area where the first content is located and performing text recognition.
13. A word retrieval device, characterized in that: The method comprises a processor, wherein the processor is used to execute the text extraction method according to any one of claims 1 to 12.
14. An electronic device, characterized in that: It includes a display screen, a memory and a processor, wherein the display screen and the memory are both coupled to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory, so that the electronic device performs the text extraction method according to any one of claims 1 to 12.
15. The electronic device according to claim 14, characterized in that: It also includes an input unit; the input unit includes an external device or a touch screen, and the external device includes a touch pad or a mouse.
16. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed on a computer, enables the computer to execute the text extraction method according to any one of claims 1 to 12.