Text processing method, device and electronic device
By detecting the movement of the selector, obtaining the pending area corresponding to its stop position and performing text conversion, the problem of inconvenient text conversion in the prior art is solved, and the convenience and efficiency of text conversion are improved.
Patent Information
- Application Number
- CN202110220088.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-02-26
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2041-02-26
AI Technical Summary
The existing text conversion method is not convenient and flexible enough, especially for text that needs to be converted in electronic devices that need to be copied to a dedicated interface or screenshot to convert overall, resulting in unnecessary content being converted, affecting efficiency.
By detecting the movement of the selector, after the selector stops moving, it obtains its corresponding pending division area, and converts the text in the area, including language translation, font style and font size switching, and outputs the converted text.
It realizes the convenience and flexibility of text conversion, and only converts the required text areas, improves conversion efficiency and output efficiency, and reduces unnecessary conversion content.
Smart Images

Figure CN114970459B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and more specifically, to a text processing method, device, and electronic device. Background Art
[0002] As electronic devices display more and more information, some information needs to be converted before it can be easily recognized by users. For example, some text needs to be translated before it can be easily recognized by users. However, the relevant information conversion methods are still not convenient enough. Summary of the Invention
[0003] In view of the above problems, the present application proposes a text processing method, device and electronic device to improve the above problems.
[0004] In a first aspect, the present application provides a text processing method, characterized in that it is applied to an electronic device, the method comprising: when a selector stops moving, obtaining a to-be-processed partitioned area corresponding to the position where the selector stops moving; and using the text in the to-be-processed partitioned area as the to-be-processed text;
[0005] Convert the text to be processed to obtain a converted text; and output the converted text.
[0006] In the second aspect, the present application provides a text processing device that runs on an electronic device, and the device includes: an area acquisition unit, which is used to obtain the to-be-processed divided area corresponding to the position where the selector stops moving; a text acquisition unit, which is used to use the text in the to-be-processed divided area as the to-be-processed text; a text conversion unit, which is used to convert the to-be-processed text to obtain the converted text; and a text output unit, which is used to output the converted text.
[0007] In a third aspect, the present application provides an electronic device comprising a processor and a memory; one or more programs are stored in the memory and configured to be executed by the processor to implement the above method.
[0008] In a fourth aspect, the present application provides a computer-readable storage medium, in which program code is stored, wherein the above method is executed when the program code is executed by a processor.
[0009] The present application provides a text processing method, device, and electronic device. The method detects the movement of a selector, and then, when the selector stops moving, obtains a partitioned area to be processed corresponding to the position where the selector stops moving. The text in the partitioned area to be processed is then used as the text to be processed, and the text to be processed is converted to obtain converted text, which is then output. Thus, by detecting the movement of the selector and obtaining the partitioned area to be processed corresponding to the position where the selector stops moving, the text to be converted can be flexibly obtained, thereby improving the convenience of text conversion. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0011] Figure 1 A schematic diagram showing an application scenario of a text processing method proposed in an embodiment of the present application is shown;
[0012] Figure 2 A flowchart of a text processing method proposed in an embodiment of the present application is shown;
[0013] Figure 3 A schematic diagram showing movement of a selector in a text processing method proposed in an embodiment of the present application is shown;
[0014] Figure 4 A schematic diagram showing a suspended toolbar in a text processing method proposed in an embodiment of the present application is shown;
[0015] Figure 5 A schematic diagram showing another suspended toolbar in a text processing method proposed in an embodiment of the present application is shown;
[0016] Figure 6 A schematic diagram showing a reduced size of a floating toolbar in a text processing method proposed in an embodiment of the present application is shown;
[0017] Figure 7 A schematic diagram showing a method for processing text in an embodiment of the present application for calling out a floating toolbar is shown;
[0018] Figure 8 A schematic diagram showing a result display interface in a text processing method proposed in an embodiment of the present application is shown;
[0019] Figure 9A schematic diagram showing another result display interface in a text processing method proposed in an embodiment of the present application is shown;
[0020] Figure 10 A schematic diagram of a language selection interface in a text processing method proposed in an embodiment of the present application is shown;
[0021] Figure 11 A flowchart of another text processing method proposed in an embodiment of the present application is shown;
[0022] Figure 12 A schematic diagram showing the row spacing in an embodiment of the present application is shown;
[0023] Figure 13 A schematic diagram showing a plurality of divided areas determined in an embodiment of the present application is shown;
[0024] Figure 14 A schematic diagram showing another type of multiple divided areas determined in an embodiment of the present application is shown;
[0025] Figure 15 A schematic diagram showing how to change the text conversion mode according to the pressing parameters in an embodiment of the present application is shown;
[0026] Figure 16 A flowchart of another text processing method proposed in an embodiment of the present application is shown;
[0027] Figure 17 A schematic diagram of an exit conversion mode proposed in an embodiment of the present application is shown;
[0028] Figure 18 A structural block diagram of a text processing device proposed in another embodiment of the present application is shown;
[0029] Figure 19 A structural block diagram of a text processing device proposed in another embodiment of the present application is shown;
[0030] Figure 20 A structural block diagram of an electronic device for executing a text processing method according to an embodiment of the present application is shown;
[0031] Figure 21 It is a storage unit of an embodiment of the present application for storing or carrying program codes for implementing the text processing method according to an embodiment of the present application. DETAILED DESCRIPTION
[0032] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0033] As electronic devices become increasingly capable of performing more functions, they also store more information. Some of this information may require conversion to facilitate user recognition. For example, an electronic device may contain text written in a foreign language. To facilitate semantic understanding of the text, the user may need to convert the text into their native language.
[0034] However, after researching related conversion methods, the inventors discovered that they were still inconvenient and inflexible. For example, in one related method, the text to be converted must be copied into a dedicated conversion interface for conversion within that interface. Alternatively, in another related method, a screenshot of the current interface can be taken and the contents of the screenshot converted. However, this method directly converts all the content in the screenshot, which can result in the conversion of unwanted content, making the conversion process inflexible.
[0035] Therefore, the inventors have proposed a text processing method, device and electronic device in this application that can improve the above-mentioned problems. In the solution provided in this application, the movement of the selector is detected, and then when the selector stops moving, the to-be-processed divided area corresponding to the position after the selector stops moving is obtained, and then the text in the to-be-processed divided area is used as the to-be-processed text, and the to-be-processed text is converted to obtain the converted text, and then the converted text is output. Therefore, through the above-mentioned method, the text to be converted can be flexibly obtained by detecting the movement of the selector and obtaining the to-be-processed divided area corresponding to the position after the selector stops, thereby improving the convenience and flexibility of text conversion. Moreover, in an embodiment, only the text in the to-be-processed divided area corresponding to the selector can be converted, without converting all the text in the interface, thereby improving the efficiency of outputting the conversion results.
[0036] It should be noted that the text processing method provided in the embodiments of the present application can be run on electronic devices such as mobile phones and tablets, or can be run collaboratively by electronic devices and servers. The server can be a single physical server, a server cluster or distributed system consisting of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud computing, cloud storage, CDN (Content Delivery Network), and artificial intelligence platforms.
[0037] Among them, in the case where the text processing method provided in the embodiment of the present application is completed by the electronic device and the server in collaboration, such as Figure 1 As shown, when the selector stops moving, obtaining the to-be-processed divided area corresponding to the position where the selector stops moving and using the text in the to-be-processed divided area as the to-be-processed text can be completed by the client 110 in the electronic device, and the subsequent conversion of the to-be-processed text to obtain the converted text can be executed by the server 120, and the subsequent output of the converted text can be executed by the client 110 in the electronic device, or by the server 120.
[0038] The embodiments of the present application will be described in detail below with reference to the accompanying drawings.
[0039] See also Figure 2 , an embodiment of the present application provides a text processing method, applied to an electronic device, the method comprising:
[0040] S110: When the selector stops moving, the to-be-processed divided area corresponding to the position where the selector stops moving is obtained.
[0041] Among them, in the embodiment of the present application, the partitioned area to be processed can be understood as the area where the included text will be converted, and in the embodiment of the present application, the partitioned area to be processed is determined according to the layout format of the text in the interface. Optionally, the text in the interface can be determined as a plurality of partitioned areas in advance according to the layout format of the text in the interface, and then a partitioned area is selected from the plurality of partitioned areas according to the position of the selector after it stops moving as the partitioned area to be processed. Furthermore, the position of the selector after it stops moving can be used as the starting point, and the partitioned area to be processed can be determined in a specified direction based on the layout format of the text. Among them, the layout format can include line spacing or the location of specified punctuation marks. The specified punctuation marks can be a period or a dot.
[0042] The selector is used to select the partition area to be processed. Optionally, the selector is a movable control. In one embodiment, the selector can move in response to the user's drag operation. For example, Figure 3 As shown, the selector 10 can be located at Figure 3 In the position shown in the left image, if there is a drag operation on the selector 10, and the drag operation is along Figure 3 If the selector 10 moves in the direction indicated by the dotted arrow, the selector 10 can be dragged and moved in the direction indicated by the dotted arrow. Figure 3 Position as shown in the image on the right.
[0043] In the embodiment of the present application, there are multiple ways to call out the selector. After calling out the selector, a prompt message can be displayed next to the selector to prompt the user to select an area for text conversion processing by dragging the selector.
[0044] As a method, the selector can be called out by floating the toolbar. In this method, the floating toolbar can be configured with at least one field, and a first trigger identifier can be set in the field, and the first trigger identifier is used to trigger the calling out or canceling the display of the selector. Optionally, before the selector is called out, if a touch operation acting on the first trigger identifier is detected, the selector is displayed. Optionally, after the selector is called out, the toolbar can remain in the display state, and then it can be achieved that if a touch operation acting on the first trigger identifier is detected when the selector is in the display state, the display of the selector is canceled.
[0045] For example, Figure 4 As shown, in Figure 4 The toolbar 11 shown in the floating display has a first trigger mark 12. Figure 4 In the state shown, if a touch operation is detected on the first trigger mark 12, the Figure 3 As shown, a selector 10 is displayed in the interface. Moreover, after the selector is called out, the display of the toolbar 11 can be synchronously cancelled to avoid interfering with the user's subsequent reading.
[0046] It should be noted that for Figure 4 The toolbar shown in the Figure 4In addition to the first trigger indicator shown in the figure, further trigger indicators may be included. Optionally, a second trigger indicator and a third trigger indicator may be included, where the second trigger indicator is an indicator for marking the current interface. Marking the current interface can be understood as storing the current interface separately, so that the current interface can be directly called for display without first triggering the application to which it belongs to launch. For example, the current interface may be the friend details interface corresponding to application A. The typical process for launching the friend details interface is to click the icon of application A on the desktop to trigger application A to launch. After application A launches, the friend list interface is displayed. Then, a selection is made in the friend list interface to trigger the friend details interface. If the current friend details interface is marked with the second trigger indicator in the toolbar, the friend details interface can be directly called for display from outside application A without first having to trigger the display of the friend list interface, thereby shortening the operation path to call the specified interface. The third trigger indicator may be an indicator for launching the corresponding application. If the third trigger indicator is set in the floating toolbar, it is no longer necessary to exit from the current interface to the desktop before launching another application. Instead, the third trigger indicator can be directly used to trigger the launch of another application.
[0047] For example, Figure 5 As shown, the "New Note" mark 13 is a second trigger mark. By triggering the "New Note" mark 13, the current interface can be stored separately to achieve the aforementioned quick access effect. The "Navigation" mark 14 is a third trigger mark. If a touch operation is detected on the "Navigation" mark 14, the navigation application can be directly launched.
[0048] Optionally, if no touch operation on the toolbar is detected within a specified time period, the toolbar may be hidden or reduced in size. Figure 6 As shown, if no touch operation is detected on the toolbar within a specified time period, the toolbar can be reduced to Figure 6 The state shown in the figure, the reduced toolbar can be displayed as Figure 6 After the toolbar is reduced to the bar 15, the user can Figure 7 After dragging the bar 15 in the direction indicated by the dotted arrow for a specified distance, the suspended toolbar can be called out again, and after the toolbar is called out, the bar 15 will be undisplayed.
[0049] Optionally, if a touch operation is detected that affects an area outside the toolbar, the toolbar can be reduced to Figure 6 The state of the strip 15 is shown in FIG.
[0050] As another way, the display and cancellation of the selector can also be controlled through the electronic device's own shortcut tool interface. Optionally, the shortcut tool interface can be triggered by sliding from the top of the display screen to the bottom of the screen, and the management control of the selector can be displayed in the shortcut tool interface. Then, if a touch operation acting on the management control is detected when the selector is not yet displayed, the selector can be triggered to be called up. Correspondingly, if a touch operation acting on the management control is detected when the selector has been called up, the selector can be canceled.
[0051] Furthermore, as another way, the display selector can be triggered by voice control. In this way, after starting the voice assistant of the electronic device, if the specified voice content is obtained, the selector can be triggered to be called up. Optionally, the specified voice content can be text conversion, or it can be text translation, etc. Optionally, the specified voice content can be set by the user according to his or her own habits. In this way, the selector can be controlled to cancel the display in the aforementioned way, or the voice assistant can continue to cancel the display of the selector.
[0052] S120: The text in the divided area to be processed is used as the text to be processed.
[0053] The text to be processed can be understood as the text that will be converted later.
[0054] S130: Convert the text to be processed to obtain a converted text.
[0055] Among them, in the embodiment of the present application, there can be multiple ways to convert the text to be processed. As one way, the conversion includes at least one of the following processing methods: translating the text into different languages; switching the font style of the text; and switching the font size of the text. Among them, performing language translation can include translating a text in any language into a text in another language. For example, English text can be translated into Chinese text, and Chinese text can be translated into English text. Switching the font style of the text can be understood as switching the font of the text itself. For example, Song-style text can be switched to Kai-style text, and for another example, Traditional-style text can be switched to Simplified-style text.
[0056] S140: Output the converted text.
[0057] In the embodiment of the present application, after obtaining the converted text, the converted text can be outputted. In the embodiment of the present application, there are multiple ways to output the converted text.
[0058] As an output method, the converted text can be displayed. It should be noted that the purpose of the user triggering the conversion of the text in the interface may be to enable himself to better recognize the content of the text. For example, if the text in the interface is in English, but the user may not be very familiar with English, then the user may want to convert the text in the interface into familiar Chinese. After obtaining the converted text, the converted text can be displayed. For example, Figure 7 As shown, after determining the area to be processed, you can cancel the display selector and display Figure 8 The border 16 shown in the figure marks the divided area to be processed. The area enclosed by the border 16 is the divided area to be processed. Moreover, the border 16 can change size in response to the user's drag operation, so that the user can further adjust the actual text to be processed according to their needs.
[0059] The converted text can be displayed through the result display interface 17. Among them, the display position of the result display interface can be determined according to the actual situation. For example, if the to-be-processed divided area itself is at an upper position in the interface, then the result display interface can be displayed at a relatively lower position in the interface. Correspondingly, if the to-be-processed divided area itself is at a lower position in the interface, then the result display interface can be displayed at a relatively upper position in the interface, thereby avoiding the result display interface and the to-be-processed divided area from crowding out each other's display positions. Furthermore, if the to-be-processed area itself occupies most of the display screen area, the result display interface can be suspended and displayed in the middle of the display screen.
[0060] Optionally, in order to facilitate the user to operate the converted text or switch the current text conversion mode, more controls can be configured in the result display interface. Figure 9 As shown, in Figure 9 The result display interface 17 shown may include a copy control 18 and a translation conversion control 19. If an operation is detected on the copy control 18, the converted text displayed in the result display interface 17 may be copied so that the user can quickly paste the converted text into another area. If an operation is detected on the translation conversion control 19, the result display interface 17 may be displayed. Figure 10 The language selection interface 20 shown in FIG. 1 is used to select a language into which a text is to be translated (a target language).
[0061] It should be noted that after the translation target language is switched through the language selection interface 20 , the electronic device can automatically and synchronously update the converted text displayed in the result display interface 17 .
[0062] As another output method, the converted text can be output to a designated information communication interface so that the converted text can be sent through the information communication interface. It should be noted that in some cases, the user expects to be able to directly send the text in the current interface to other users after converting it. In this case, after obtaining the converted text, the electronic device can trigger the display of a designated information communication interface according to the user's selection and output the converted text to the information to be sent area in the designated information communication interface.
[0063] It should be noted that, when multiple output methods are available, the electronic device can determine the specific output method to be used based on the runtime of the application to which the designated information communication interface belongs. As one example, if it is detected that an application is launched after the selector is called out, and the launched application includes the designated information communication interface, then the converted text is output to the information to be sent area of the designated information communication interface in the application launched after the selector was called out. Conversely, if it is detected that no application including the designated information communication interface is launched between the time the selector is called out and the time the converted text is obtained, then the converted text is output by displaying it.
[0064] Exemplarily, the application program including the designated information communication interface may be a text message sending program, and the designated information communication interface included in the text message sending program may be a text message sending interface.
[0065] The present application provides a text processing method, which detects the movement of a selector, and then obtains the to-be-processed partitioned area corresponding to the position after the selector stops moving, and then uses the text in the to-be-processed partitioned area as the to-be-processed text, converts the to-be-processed text to obtain the converted text, and then outputs the converted text. Thus, by detecting the movement of the selector and obtaining the to-be-processed partitioned area corresponding to the position after the selector stops moving, the text to be converted can be flexibly obtained, which improves the convenience of text conversion. Moreover, in an embodiment, only the text in the to-be-processed partitioned area corresponding to the selector can be converted, without converting all the text in the interface, which improves the efficiency of outputting the conversion result. Furthermore, in an embodiment of the present application, the to-be-processed partitioned area corresponding to the selector after it stops moving is determined by the electronic device itself, without the user having to make a manual selection, which improves the intelligence of the entire process.
[0066] See also Figure 11 , an embodiment of the present application provides a text processing method, applied to an electronic device, the method comprising:
[0067] S210: When the selector stops moving, the position of the selector after the selector stops moving is matched with at least one divided area.
[0068] It should be noted that, in the embodiment, the text in the interface may be divided into regions in advance, thereby obtaining at least one divided region.
[0069] As a method, the method provided in an embodiment of the present application further includes: obtaining text in the interface and a layout format of the text; dividing the text in the interface based on the layout format to obtain at least one divided area.
[0070] Optionally, the layout format includes line spacing. The electronic device can determine the line spacing based on the color transformation between the text in the current interface. It should be noted that the colors between the text and the background in the interface can usually be different, and then color detection can be used to determine which areas in the interface are text and which areas are blank spaces between texts. Correspondingly, after obtaining the blank spaces between the texts, the height of the blank spaces can be further used as the line spacing between adjacent lines of text.
[0071] The text in the interface is divided based on the layout format to obtain at least one divided area, including: in the current division process, starting from the starting point of the current division, the line spacing between the texts in adjacent rows is compared with a first specified threshold in sequence; if the first reference adjacent row is obtained, the previous row in the first reference adjacent row, the starting point and the area between the previous row in the first reference adjacent row and the starting point are used as the divided area obtained in the current division process, and the next row in the first reference adjacent row is used as the starting point of the next division until the detection of the line spacing between the texts in the last adjacent rows in the interface is completed; if the first reference adjacent row is not obtained, the starting point of the current division and the area after the starting point of the current division are determined as a divided area; wherein the line spacing between the texts in the first reference adjacent rows is greater than the first specified threshold.
[0072] For example, Figure 12 As shown, the first line can be used as the starting point in the process of dividing the area. The text of the first line includes "Chengdu, or "Rong" for short," and the text of the second line includes "also known as Rongcheng and", then the line spacing of the first adjacent lines is Figure 12 If the line spacing h2 between the seventh and eighth lines obtained in the above method is greater than the first specified threshold, the seventh and eighth lines will be determined as the first reference adjacent lines. The text included in the seventh line is "city economic circle.", and the text included in the eighth line is "It is an important central". The seventh line is the previous line in the first reference adjacent line, and the text between the first and seventh lines will be divided into a region, and the text between the first and seventh lines can be divided into a region. Figure 12 The text shown in Figure 13 The divided area 21 and the divided area 22 are shown in FIG.
[0073] It should be noted that, in the process of determining the divided areas, the electronic device can take a screenshot of the current interface and then obtain the text and the arrangement format of the text in the current interface through OCR (Optical Character Recognition), so that even if there is a picture in the current interface, the text included in the picture can still be obtained, so that in the process of determining the divided areas, the text included in the picture in the current interface can also be divided. Figure 14 In the case where there is text in the picture included in the current interface, it can still be determined into the divided area and determined as divided area 23.
[0074] Optionally, the layout format includes punctuation marks. In this way, the electronic device can identify punctuation marks starting from the first character in the current interface, and determine the division area based on the identified specified punctuation marks. In this way, in the current area division process, starting from the starting point of the current area division, if the specified punctuation mark is identified, the text between the identified specified punctuation mark and the starting point of the current area division is used as a division area. And the text after the specified punctuation mark obtained in the current area division process is used as the starting point of the next area division process. For example, if the specified punctuation mark is a period, then Figure 13 Taking the interface shown in as an example, it can still be determined that Figure 13 The divided area 21 and the divided area 22 are shown in FIG.
[0075] S220: The divided area whose corresponding position matches the position after the selector stops moving is used as the divided area to be processed.
[0076] Each determined partitioned area has a corresponding position, and the position of each partitioned area represents the range covered by each partitioned area. When the selector stops moving, the position of the selector after stopping can be matched with the position of each partitioned area, and the partitioned area whose corresponding position matches the selector position is then used as the partitioned area to be processed.
[0077] As a method, a selector occupies a plane rather than a point due to interface reasons. To easily determine the selector's position, the center of the selector can be used as the selector's position. When matching the selector's position with the positions of the partitioned regions, the partitioned region where the selector's center is located can be used as the partitioned region to be processed.
[0078] S230: The text in the divided area to be processed is used as the text to be processed.
[0079] S240: Convert the text to be processed to obtain a converted text.
[0080] As described above, in the embodiment of the present application, text conversion may include language translation, text font style switching, text font size switching, etc. In this embodiment, the electronic device may determine the specific conversion method to be used based on the user's touch operation.
[0081] As a way, after the selector stops moving, the electronic device can further detect the operating parameters acting on the selector, and then determine the specific conversion method according to the operating parameters.
[0082] Optionally, the operation parameter may be a pressing force. In this manner, after the user completes dragging the selector, the user may continue to apply a pressing force to the selector, and the electronic device may detect the current pressing force in real time and display the conversion mode corresponding to the current pressing force in real time.
[0083] Optionally, the operation parameter may be a press duration. In this manner, after the user completes dragging the selector, the user may continue to press the selector, and the electronic device may detect the current press duration in real time and display the conversion mode corresponding to the current press duration in real time.
[0084] For example, Figure 15 As shown, when the selector is dragged to Figure 15 After the position shown in , if the pressing operation on the selector is detected, the force of the pressing operation can be further detected. When the pressing force meets the force required for translation, Figure 15 The leftmost image shows a prompt for translation. If the pressure on the selector is detected to be gone while the translation is displayed, the text to be processed will be translated. If the user continues to press harder and the pressure is detected to be sufficient for font size conversion, the prompt content will be changed to Figure 15 The font size conversion shown in the middle image corresponds to the following: if the pressing action on the selector is detected to be gone during the font size conversion process, the font size conversion will be performed on the text to be processed. If the user continues to press harder and the force is detected to be sufficient for the font size conversion, the prompt content will be changed to Figure 15 The font style transition shown in the image on the right corresponds to the following: if the user detects that the selector's pressure is no longer applied during the font style transition, the font style transition will be applied to the text being processed. Optionally, if the user reduces the pressure, the transition will switch to the transition that corresponded to the previous, lighter pressure.
[0085] Similarly, when the selector is dragged to Figure 15 After the position shown in , if the pressing operation on the selector is detected, the pressing duration of the pressing operation can be further detected. When the pressing duration meets the force required for translation, Figure 15 The leftmost image shows a prompt for translation. If the user detects that the press on the selector disappears while the translation is displayed, the text to be processed will be translated. If the user continues to press the selector and the press time is long enough to convert the font size, the prompt content will be changed to Figure 15The font size conversion shown in the middle image corresponds to the following: if the pressing operation on the selector is detected to be gone during the display font size conversion, the font size conversion will be performed on the processed text. If the user continues to press the selector and the pressing time is detected to be sufficient for the font size conversion, the prompt content will be changed to Figure 15 The font style conversion shown in the right image corresponds to that if the pressing operation on the selector is detected to be gone during the display of the font style conversion, the font style conversion will be performed on the processed text.
[0086] S250: Output the converted text.
[0087] The present application provides a text processing method, which makes it possible to flexibly obtain the text to be converted by detecting the movement of the selector and obtaining the partitioned area to be processed corresponding to the position after the selector stops in the above manner, thereby improving the convenience of text conversion. Moreover, in an embodiment, only the text in the partitioned area to be processed corresponding to the selector can be converted, without converting all the text in the interface, thereby improving the efficiency of outputting the conversion results. Furthermore, in this embodiment, the text in the current interface can be divided into at least one partitioned area, and then the position of the selector can be compared with the position of at least one partitioned area to determine the partitioned area to be processed.
[0088] See also Figure 16 , an embodiment of the present application provides a text processing method, applied to an electronic device, the method comprising:
[0089] S310: When the selector stops moving, a first text is obtained, where the first text is the text in the row where the position after the selector stops moving is located.
[0090] It should be noted that, in this embodiment, the determination of the partitioned area to be processed may be started after it is detected that the selector stops moving, and in this embodiment, it is not necessary to determine the partitioned area for all texts in the interface.
[0091] S320: Acquire a second text along a specified direction based on the arrangement format of the text, starting from the first text.
[0092] Optionally, the designated direction may be a text reading direction recognized by the electronic device. The text reading direction may be understood as the sequential direction in which the user reads the text.
[0093] S330: The first text, the second text, and the area where the text between the first text and the second text is located are divided as areas to be processed.
[0094] As a method, the layout format includes line spacing, and the method of obtaining the second text along the specified direction and based on the text layout format with the first text as the starting point includes: taking the first text as the starting point, sequentially comparing the line spacing between texts in adjacent lines with a second specified threshold; obtaining a second reference adjacent line, where the second reference adjacent line is an adjacent line whose line spacing obtained for the first time is greater than the second specified threshold; and taking the text of the previous line in the second reference adjacent line as the second text.
[0095] S340: The text in the divided area to be processed is used as the text to be processed.
[0096] S350: Convert the text to be processed to obtain a converted text.
[0097] S360: Output the converted text.
[0098] It should be noted that after calling the selector, it can be understood that the current state has entered the conversion mode. Figure 17 As shown, if a click operation is detected on the selector 10, the display Figure 17 If a click operation on the close control 24 is detected, the current conversion mode will be exited and the selector 10 will be canceled. Optionally, the close control 24 can be gradually moved from behind the selector 10 to the back of the selector 10 during the display process. Figure 17 The location shown in .
[0099] It should be noted that the click operation that triggers the display of the close control 24 differs from the press operation that triggers the switching of the conversion mode in the aforementioned embodiment in that the press operation that triggers the switching of the conversion mode in the aforementioned embodiment must be continuous with the drag operation of the selector. Alternatively, it can be understood that in the aforementioned embodiment, the aforementioned switching of the conversion mode is triggered only if the drag operation of the selector is detected and the selector is maintained in contact with the selector after the drag is completed and the press operation is continued.
[0100] The present application provides a text processing method, which makes it possible to flexibly obtain the text to be converted by detecting the movement of the selector and obtaining the partitioned area to be processed corresponding to the position after the selector stops in the above manner, thereby improving the convenience of text conversion. Moreover, in an embodiment, only the text in the partitioned area to be processed corresponding to the selector can be converted, without converting all the text in the interface, thereby improving the efficiency of outputting the conversion results. Furthermore, in this embodiment, the position after the selector stops moving can be used as the starting point, and the partitioned area to be processed can be obtained along a specified direction and based on the arrangement format of the text, thereby further improving the flexibility of determining the partitioned area to be processed.
[0101] See also Figure 18 , an embodiment of the present application provides a text processing device, which runs on an electronic device, and the device 400 includes:
[0102] The region acquisition unit 410 is configured to acquire the partitioned region to be processed corresponding to the position where the selector stops moving when the selector stops moving.
[0103] As one approach, the region acquisition unit 410 is specifically configured to match the position of the selector after it stops moving with at least one divided region; and use the divided region whose corresponding position matches the position of the selector after it stops moving as the divided region to be processed.
[0104] Optionally, the area acquisition unit 410 is further used to acquire the text in the interface and the layout format of the text; the text in the interface is divided based on the layout format to obtain at least one divided area. The area acquisition unit 410 is specifically used to compare the line spacing between texts in adjacent rows with a first specified threshold in sequence starting from the starting point of the current division during the current division process; if the first reference adjacent row is obtained, the previous row in the first reference adjacent row, the starting point, and the area between the previous row in the first reference adjacent row and the starting point are used as the divided area obtained in the current division process, and the next row in the first reference adjacent row is used as the starting point of the next division, until the detection of the line spacing between texts in the last adjacent rows in the interface is completed; if the first reference adjacent row is not obtained, the starting point of the current division and the area after the starting point of the current division are determined as a divided area; wherein the line spacing between texts in the first reference adjacent rows is greater than the first specified threshold.
[0105] As another method, the area acquisition unit 410 is specifically used to acquire a first text, where the first text is the text in the row where the selector stops moving; acquire a second text starting from the first text along a specified direction and based on the text layout format; and use the first text, the second text, and the area where the text between the first text and the second text is located as the area to be processed.
[0106] Optionally, the area acquisition unit 410 is specifically used to compare the line spacing between texts in adjacent lines with a second specified threshold in sequence, starting from the first text; obtain a second reference adjacent line, where the second reference adjacent line is an adjacent line whose line spacing obtained for the first time is greater than the second specified threshold; and use the text of the previous line in the second reference adjacent line as the second text.
[0107] The text acquisition unit 420 is configured to take the text in the to-be-processed divided area as the to-be-processed text.
[0108] The text conversion unit 430 is configured to convert the text to be processed to obtain a converted text.
[0109] As an approach, the conversion includes at least one of the following processing approaches: translating the text into different languages; switching the font style of the text; and switching the font size of the text.
[0110] The text output unit 440 is configured to output the converted text.
[0111] like Figure 19 As shown, the device also includes:
[0112] The selector management unit 450 is configured to display a toolbar in a suspended manner at a designated location, wherein the toolbar includes a first trigger mark; and display the selector if a touch operation acting on the first trigger mark is detected.
[0113] The present application provides a text processing device that detects the movement of a selector, and then when the selector stops moving, obtains the to-be-processed partitioned area corresponding to the position where the selector stops moving, and then uses the text in the to-be-processed partitioned area as the to-be-processed text, converts the to-be-processed text to obtain the converted text, and then outputs the converted text. Thus, by detecting the movement of the selector and obtaining the to-be-processed partitioned area corresponding to the position where the selector stops, the text to be converted can be flexibly obtained, thereby improving the convenience of text conversion. Moreover, in an embodiment, only the text in the to-be-processed partitioned area corresponding to the selector can be converted, without converting all the text in the interface, thereby improving the efficiency of outputting the conversion results.
[0114] It should be noted that the device embodiment in this application corresponds to the aforementioned method embodiment. The specific principles in the device embodiment can be found in the contents of the aforementioned method embodiment and will not be repeated here.
[0115] The following will be combined Figure 20 An electronic device provided by this application is described.
[0116] See also Figure 20 Based on the above-mentioned text processing method and apparatus, the present application also provides another electronic device 200 that can execute the above-mentioned text processing method. The electronic device 200 includes one or more (only one is shown in the figure) processors 102, a memory 104, and a network module 106 that are coupled to each other. The memory 104 stores a program that can execute the content of the above-mentioned embodiment, and the processor 102 can execute the program stored in the memory 104.
[0117] The processor 102 may include one or more cores for processing data. The processor 102 utilizes various interfaces and circuits to connect various components within the electronic device 200. It executes instructions, programs, code sets, or instruction sets stored in the memory 104, and accesses data stored in the memory 104 to perform various functions and process data within the electronic device 200. Optionally, the processor 102 may be implemented using at least one of the following hardware forms: a digital signal processing (DSP), a field-programmable gate array (FPGA), or a programmable logic array (PLA). The processor 102 may integrate one or a combination of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. The CPU primarily processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing display content; and the modem handles wireless communications. It is understood that the modem may not be integrated into the processor 102 and may be implemented separately via a communication chip.
[0118] The memory 104 may include a random access memory (RAM) or a read-only memory (ROM). The memory 104 may be used to store instructions, programs, codes, code sets, or instruction sets. The memory 104 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the following various method embodiments, etc. The data storage area may also store data created by the terminal 100 during use (such as a phone book, audio and video data, chat history data), etc.
[0119] The network module 106 is used to receive and transmit electromagnetic waves, realize the mutual conversion between electromagnetic waves and electrical signals, and thus communicate with a communication network or other devices, such as communicating with an audio playback device. The network module 106 may include various existing circuit components for performing these functions, such as an antenna, a radio frequency transceiver, a digital signal processor, an encryption / decryption chip, a subscriber identity module (SIM) card, a memory, etc. The network module 106 can communicate with various networks such as the Internet, an enterprise intranet, a wireless network, or communicate with other devices via a wireless network. The above-mentioned wireless network may include a cellular telephone network, a wireless local area network, or a metropolitan area network. For example, the network module 106 can exchange information with a base station.
[0120] Please refer to Figure 21 , which shows a block diagram of a computer-readable storage medium provided in an embodiment of the present application. The computer-readable medium 1100 stores program code, which can be called by a processor to execute the method described in the above method embodiment.
[0121] Computer-readable storage medium 1100 may be an electronic memory such as flash memory, EEPROM (Electrically Erasable Programmable Read-Only Memory), EPROM, hard disk, or ROM. Alternatively, computer-readable storage medium 1100 may include a non-transitory computer-readable storage medium. Computer-readable storage medium 1100 may have storage space for program code 1110 for executing any of the method steps described above. These program codes may be read from or written to one or more computer program products. Program code 1110 may be compressed, for example, in a suitable form.
[0122] In summary, the present application provides a text processing method, device and electronic device, which detects the movement of the selector, and then obtains the to-be-processed partitioned area corresponding to the position after the selector stops moving, and then uses the text in the to-be-processed partitioned area as the to-be-processed text, converts the to-be-processed text to obtain the converted text, and then outputs the converted text. Thus, by detecting the movement of the selector and obtaining the to-be-processed partitioned area corresponding to the position after the selector stops moving, the text to be converted can be flexibly obtained, which improves the convenience of text conversion. Moreover, in an embodiment, only the text in the to-be-processed partitioned area corresponding to the selector can be converted, without converting all the text in the interface, which improves the efficiency of outputting the conversion result. Furthermore, in an embodiment of the present application, the to-be-processed partitioned area corresponding to the selector after it stops moving is determined by the electronic device itself, without the user having to make a manual selection, which improves the intelligence of the entire process.
[0123] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical feature diagrams therein. These modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A text processing method, characterized in that: Applied to electronic equipment, the method includes: When the selector stops moving, obtaining a partitioned area to be processed corresponding to the position of the selector after it stops moving, wherein the partitioned area to be processed is determined based on the position of the selector after it stops moving and is oriented in a specified direction based on the layout format of the text, wherein the specified direction includes a text reading direction, the selector is used to select the partitioned area to be processed, the selector moves in response to a user's dragging operation, the layout format includes the position of a specified punctuation mark, wherein the position of the specified punctuation mark is the end position of the partitioned area to be processed; Using the text in the to-be-processed divided area as the to-be-processed text; Converting the text to be processed to obtain a converted text; The converted text is output.
2. The method according to claim 1, characterized in that After the selector stops moving, the method further includes: obtaining the to-be-processed partition area corresponding to the position after the selector stops moving; Floating and displaying a toolbar at a designated location, wherein the toolbar includes a first trigger mark; If a touch operation acting on the first trigger mark is detected, the selector is displayed.
3. The method according to claim 1, characterized in that The conversion includes at least one of the following processing methods: Translate the text into different languages; Toggle the font style of text; and Toggle the font size of the text.
4. A text processing device, characterized in that: Running on an electronic device, the device includes: an area acquisition unit, configured to, when the selector stops moving, acquire the to-be-processed divided area corresponding to the position of the selector after the selector stops moving, wherein the to-be-processed divided area is determined based on the position of the selector after the selector stops moving and is oriented in a specified direction based on the arrangement format of the text, wherein the specified direction includes a text reading direction, the selector is used to select the to-be-processed divided area, the selector moves in response to a user's dragging operation, the arrangement format includes the position of a specified punctuation mark, wherein the position of the specified punctuation mark is the end position of the to-be-processed divided area; A text acquisition unit, configured to take the text in the to-be-processed divided area as the to-be-processed text; A text conversion unit, configured to convert the text to be processed to obtain a converted text; A text output unit is used to output the converted text.
5. An electronic device, characterized in that: including a processor and a memory; One or more programs are stored in the memory and configured to be executed by the processor to implement the method according to any one of claims 1 to 3.
6. A computer-readable storage medium, characterized in that The computer-readable storage medium stores program code, wherein when the program code is executed by a processor, the method according to any one of claims 1 to 3 is executed.
Citation Information
Patent Citations
Translation method and device, terminal and storage medium
CN107656922A
Method and device for testing user interface
CN110008110A
Translation processing method and device and device for translation processing
CN111680521A