Text translation method, device, electronic device and storage medium
By obtaining the keywords of the text to be translated in an electronic device and searching for the text to be translated containing the original text for translation, the problems of cumbersome user operations and low translation efficiency in the prior art are solved, and text translation is simplified and efficient.
Patent Information
- Application Number
- CN202111546414.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-16
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2041-12-16
AI Technical Summary
Existing electronic devices have cumbersome operations during text translation, especially when long text translation is numerous and inefficient, which can easily lead to missing or incorrect translation content.
By obtaining the keywords in the text to be translated, searching to obtain the text to be translated containing the original text, and translating it, simplifying the operation steps and improving the translation efficiency.
The operation steps of long text translation are simplified, the translation efficiency is improved, and the completeness and accuracy of the translated content is ensured.
Smart Images

Figure CN114282553B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of electronic devices, and more specifically, to a text translation method, device, electronic device and storage medium. Background Art
[0002] With the development of science and technology, electronic devices are used more and more widely and have more and more functions, becoming one of the necessities in people's daily life. At present, electronic devices can be used to translate texts, but the translation process requires users to operate cumbersome steps, resulting in poor user experience. Summary of the invention
[0003] In view of the above problems, the present application proposes a text translation method, device, electronic device and storage medium to solve the above problems.
[0004] In a first aspect, an embodiment of the present application provides a text translation method, which is applied to an electronic device, and the method includes: obtaining a first text to be translated; extracting keywords from the first text to be translated to obtain target keywords in the first text to be translated; searching according to the target keywords to obtain a second text to be translated, wherein the second text to be translated includes at least the first text to be translated; and translating the second text to be translated to obtain a translated text.
[0005] In a second aspect, an embodiment of the present application provides a text translation device, which is applied to an electronic device, and the device includes: a first text to be translated acquisition module, which is used to acquire a first text to be translated; a target keyword acquisition module, which is used to extract keywords from the first text to be translated and obtain the target keywords in the first text to be translated; a second text to be translated acquisition module, which is used to search according to the target keywords and obtain a second text to be translated, wherein the second text to be translated at least includes the first text to be translated; and a translation text acquisition module, which is used to translate the second text to be translated and obtain a translated text.
[0006] In a third aspect, an embodiment of the present application provides an electronic device, comprising a memory and a processor, wherein the memory is coupled to the processor, the memory stores instructions, and when the instructions are executed by the processor, the processor executes the above method.
[0007] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which a program code is stored, and the program code can be called by a processor to execute the above method.
[0008] The text translation method, device, electronic device and storage medium provided in the embodiments of the present application obtain a first text to be translated, extract keywords from the first text to be translated, obtain target keywords in the first text to be translated, search based on the target keywords to obtain a second text to be translated, wherein the second text to be translated includes at least the first text to be translated, and translate the second text to be translated to obtain a translated text. The present application simplifies the operation steps for translating long texts and improves translation efficiency by obtaining keywords from the first text to be translated, searching for the keywords to obtain a second text to be translated including the first text to be translated, and translating the second text to be translated to obtain a translated text. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. 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 paying any creative work.
[0010] Figure 1 A flowchart of a text translation method provided by an embodiment of the present application is shown;
[0011] Figure 2 A flowchart of a text translation method provided by an embodiment of the present application is shown;
[0012] Figure 3 This application shows Figure 2 The flowchart of step S240 of the text translation method shown is as follows;
[0013] Figure 4 This application shows Figure 3 The flowchart of step S242 of the text translation method shown is as follows;
[0014] Figure 5 A flowchart of a text translation method provided by an embodiment of the present application is shown;
[0015] Figure 6 A flowchart of a text translation method provided by an embodiment of the present application is shown;
[0016] Figure 7 A flowchart of a text translation method provided by an embodiment of the present application is shown;
[0017] Figure 8 This application shows Figure 7 The flowchart of step S520 of the text translation method shown is as follows;
[0018] Fig. 9A module block diagram of a text translation device provided in an embodiment of the present application is shown;
[0019] Fig.10 A block diagram of an electronic device for executing a text translation method according to an embodiment of the present application is shown;
[0020] Fig.11 A storage unit for storing or carrying program codes for implementing the text translation method according to an embodiment of the present application is shown. DETAILED DESCRIPTION
[0021] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.
[0022] Currently, texts can be translated through electronic devices. However, during the translation process, users need to scan the text content to be translated one by one to obtain the complete translation content, which is not a good experience for users. In addition, when the text to be translated is long (too much content), the scanning process is extremely long. If the scanning process does not cover all the content of the text, the final translation text will also have corresponding omissions, resulting in text translation errors.
[0023] In view of the above problems, the inventor has discovered after long-term research and proposed the text translation method, device, electronic device and storage medium provided in the embodiments of the present application, which can simplify the operation steps for translating long texts and improve translation efficiency by obtaining keywords in the first text to be translated, searching for the keywords to obtain a second text to be translated including the first text to be translated, and translating the second text to be translated to obtain a translated text. The specific text translation method is described in detail in the subsequent embodiments.
[0024] See also Figure 1 , Figure 1 The flowchart of the text translation method provided by an embodiment of the present application is shown. The method is used to obtain keywords in a first text to be translated, search for the keywords to obtain a second text to be translated including the first text to be translated, and translate the second text to be translated to obtain a translated text, thereby simplifying the operation steps for translating long texts and improving translation efficiency. In a specific embodiment, the text translation method is applied to Fig.10 The text translation device 200 and the electronic device 100 equipped with the text translation device 200 are shown in FIG. Fig.11). The following will take an electronic device as an example to illustrate the specific process of this embodiment. Of course, it can be understood that the electronic device used in this embodiment may include a smart phone, a tablet computer, a wearable electronic device, etc., which is not limited here. Figure 1 The process shown is described in detail, and the text translation method may specifically include the following steps:
[0025] Step S110: Obtain a first text to be translated.
[0026] In this embodiment, the electronic device can obtain the text to be translated as the first text to be translated. The first text to be translated can be a text corresponding to the original language, for example, the first text to be translated can be a text in Chinese, English, Japanese, Korean, etc., which is not limited here.
[0027] As a way, the electronic device may include a camera, and the electronic device may control the camera to collect images, and obtain the image to be translated collected by the camera, and perform an image-to-text operation on the image to be translated to obtain the first text to be translated. As another way, the electronic device may include a pickup (such as a microphone), and the electronic device may control the pickup to collect voices, and obtain the voice to be translated collected by the pickup, and perform a voice-to-text operation on the voice to be translated to obtain the first text to be translated. As another way, the electronic device may include a communication module, and the electronic device may obtain the text to be translated from a server or from other devices through the communication module as the first text to be translated.
[0028] In some implementations, the electronic device may obtain the first text to be translated in response to an input start instruction. For example, the electronic device may obtain the first text to be translated in response to an input voice start instruction, or the electronic device may obtain the first text to be translated in response to an input touch start instruction, etc., which is not limited here.
[0029] Step S120: extracting keywords from the first text to be translated to obtain target keywords in the first text to be translated.
[0030] In this embodiment, after obtaining the first text to be translated, the electronic device may extract keywords from the first text to be translated to obtain target keywords in the first text to be translated.
[0031] In some implementations, after obtaining the first text to be translated, the electronic device can extract the target keywords in the first text to be translated by using a keyword extraction algorithm in natural language processing technology. As an implementable method, the keyword extraction algorithm can include supervised, unsupervised or semi-supervised, wherein the unsupervised method can be applied to various keyword extraction scenarios; supervised and semi-supervised methods can extract more accurate keywords than unsupervised methods.
[0032] Step S130: searching according to the target keyword to obtain a second text to be translated, wherein the second text to be translated at least includes the first text to be translated.
[0033] In this embodiment, after obtaining the target keyword, the electronic device can search according to the target keyword to obtain the second text to be translated, wherein the second text to be translated at least includes the first text to be translated. As one way, the second text to be translated can be exactly the same as the first text to be translated. As another way, the second text to be translated can include the first text to be translated and other texts different from the first text to be translated.
[0034] In some embodiments, after obtaining the target keyword, the electronic device can use the server to search for the target keyword and search the entire network for the second text to be translated that includes the target keyword (the first text to be translated). For example, the first text to be translated can be the text corresponding to the homepage of a certain document, the target keyword can be an identifying phrase in the homepage, such as the title, author, date, etc., and the second text to be translated can be the certain document.
[0035] Step S140: translating the second text to be translated to obtain a translated text.
[0036] In this embodiment, after obtaining the second text to be translated, the electronic device can translate the second text to be translated to obtain a translated text. Thus, the content of the obtained translated text exceeds the content of the translated text corresponding to the collected text to be translated, and a simplified operation translation of a long text can be achieved.
[0037] In some embodiments, the electronic device may be provided with a language, wherein the language provided by the electronic device may represent the language used by the user, that is, the language provided by the electronic device may be obtained. For example, if the language provided by the electronic device is Chinese, it may be considered that the language provided by the user is Chinese. For another example, if the language provided by the electronic device is English, it may be considered that the language provided by the user is English. In this embodiment, when the electronic device obtains the second text to be translated, it may translate the second text to be translated from the initial language into the language provided by the electronic device to obtain the translated text.
[0038] In some implementations, when the electronic device obtains the second text to be translated, it can display a language selection control, wherein the language selection control can select the language to be translated. In this embodiment, when the target language selected based on the language selection control is detected, the second text to be translated can be translated from the initial language to the target language to obtain a translated text.
[0039] The text translation method provided by an embodiment of the present application obtains a first text to be translated, extracts keywords from the first text to be translated, obtains target keywords from the first text to be translated, searches based on the target keywords to obtain a second text to be translated, wherein the second text to be translated at least includes the first text to be translated, and translates the second text to be translated to obtain a translated text. The present application simplifies the operation steps for translating long texts and improves translation efficiency by obtaining keywords from the first text to be translated, searching for the keywords to obtain a second text to be translated including the first text to be translated, and translating the second text to be translated to obtain a translated text.
[0040] See also Figure 2 , Figure 2 The flowchart of the text translation method provided by an embodiment of the present application is shown in FIG. Figure 2 The process shown is described in detail, and the text translation method may specifically include the following steps:
[0041] Step S210: Obtain a first text to be translated.
[0042] Step S220: extracting keywords from the first text to be translated to obtain target keywords in the first text to be translated.
[0043] For the detailed description of step S210 to step S220, please refer to step S110 to step S120, which will not be repeated here.
[0044] Step S230: Search according to the target keyword to obtain multiple texts to be confirmed.
[0045] In some implementations, after obtaining the target keyword, the electronic device may search according to the target keyword to obtain a plurality of texts to be confirmed, wherein the plurality of texts to be confirmed may all include the target keyword.
[0046] As an implementable manner, when searching according to a target keyword, an electronic device can obtain multiple search results, and the multiple search results can be determined as multiple texts to be determined. As another implementable manner, when searching according to a target keyword, an electronic device can obtain multiple search results, and some search results can be selected from the multiple search results to be determined as multiple texts to be confirmed. For example, the electronic device can select the search results ranked in the top N positions from multiple search results to be determined as texts to be confirmed, wherein the multiple search results can be sorted in order from high to low accuracy, or can be sorted in order from high to low relevance, etc., which is not limited here.
[0047] Step S240: Based on the first text to be translated, a target text to be confirmed is selected from the plurality of texts to be confirmed as the second text to be translated.
[0048] In some implementations, after obtaining a plurality of texts to be confirmed, the electronic device may select a target text to be confirmed as a second text to be translated from the plurality of texts to be confirmed based on the first text to be translated.
[0049] As an implementable manner, after obtaining multiple texts to be confirmed, the electronic device can compare the multiple texts to be confirmed with the first text to be translated respectively, so as to select the target text to be confirmed that is most relevant to the first text to be translated from the multiple texts to be confirmed as the second text to be translated.
[0050] As another feasible manner, after obtaining multiple texts to be confirmed, the electronic device may compare the multiple texts to be confirmed with the first text to be translated respectively, so as to select a target text to be confirmed that completely contains the first text to be translated from the multiple texts to be confirmed as the second text to be translated.
[0051] As another practicable manner, after obtaining multiple texts to be confirmed, the electronic device may display the multiple texts to be confirmed on the electronic device for the user to select from the multiple texts to be confirmed. When a selection operation input by the user for a target text to be confirmed among the multiple texts to be confirmed is detected, the target text to be confirmed may be used as the second text to be translated.
[0052] See also Figure 3 , Figure 3 This application shows Figure 2 The flowchart of step S240 of the text translation method shown in FIG. Figure 3 The process shown is described in detail, and the method may specifically include the following steps:
[0053] Step S241: Compare the first text to be translated with the multiple texts to be confirmed respectively to obtain comparison results.
[0054] In some implementations, after obtaining multiple texts to be confirmed, the electronic device may compare the first text to be translated with the multiple texts to be confirmed respectively to obtain a comparison result.
[0055] As a method, the content of the first text to be translated can be compared with the information of the content of multiple texts to be confirmed to obtain a comparison result, and the comparison result can represent the inclusion relationship between the first text to be translated and each text to be confirmed.
[0056] As another way, the content of the first text to be translated may be compared with the content of multiple texts to be confirmed for similarity to obtain a comparison result, and the comparison result may represent the content similarity between the first text to be translated and each text to be confirmed.
[0057] As another way, the length of the content included in the first text to be translated can be compared with the length of the content included in multiple texts to be confirmed to obtain a comparison result, and the comparison result can represent the relationship between the content length of the first text to be translated and each text to be confirmed.
[0058] Step S242: when the comparison result indicates that the target text to be confirmed among the plurality of texts to be confirmed includes the first text to be translated, the target text to be confirmed is used as the second text to be translated.
[0059] In some embodiments, when the comparison result represents that the target text to be confirmed among the multiple texts to be confirmed includes the first text to be translated, the target text to be confirmed can be considered to be the original text of the first text to be translated, that is, the target text to be confirmed is the text that the user expects to translate, and the target text to be confirmed can be used as the second text to be translated.
[0060] See also Figure 4 , Figure 4 This application shows Figure 3 The flowchart of step S242 of the text translation method shown in FIG. Figure 4 The process shown is described in detail, and the method may specifically include the following steps:
[0061] Step S2421: when the comparison result indicates that at least two of the multiple texts to be confirmed include the first text to be translated, obtaining browsing parameters corresponding to each of the at least two texts to be confirmed.
[0062] In some embodiments, when the comparison result represents that at least two of the multiple texts to be confirmed include the first text to be translated, it can be considered that the at least two texts to be confirmed may include both the original text and the pirated text of the first text to be translated. Therefore, the at least two texts to be confirmed can be screened to select the original text of the first text to be translated from the at least two texts to be confirmed as the second text to be translated, and filter out the pirated texts in the at least two texts to be confirmed.
[0063] As an implementable manner, when the comparison result indicates that at least two of the multiple texts to be confirmed include the first text to be translated, the browsing parameters corresponding to the at least two texts to be confirmed can be obtained. The browsing parameters can include a combination of one or more of the number of browsing times, browsing frequency, and rating.
[0064] Step S2422: Based on the browsing parameters corresponding to the at least two texts to be confirmed, determine a target text to be confirmed from the at least two texts to be confirmed as the second text to be translated.
[0065] In this embodiment, after obtaining the browsing parameters corresponding to the at least two texts to be confirmed, the target text to be confirmed (the original text corresponding to the first text to be translated) can be determined from the at least two texts to be confirmed based on the browsing parameters corresponding to the at least two texts to be confirmed as the second text to be translated.
[0066] As a method, assuming that the browsing parameter includes the browsing number, after obtaining the browsing number corresponding to each of the at least two texts to be confirmed, the text to be confirmed with the largest number of browsings among the at least two texts to be confirmed can be determined as the target text to be confirmed (the original text corresponding to the first text to be translated) based on the browsing number corresponding to each of the at least two texts to be translated, and as the second text to be translated.
[0067] As a method, assuming that the browsing parameter includes browsing frequency, after obtaining the browsing frequencies corresponding to the at least two texts to be confirmed, the text to be confirmed with the highest browsing frequency among the at least two texts to be confirmed can be determined as the target text to be confirmed (the original text corresponding to the first text to be translated) based on the browsing frequencies corresponding to the at least two texts to be translated, and as the second text to be translated.
[0068] As a method, assuming that the browsing parameter includes a score, after obtaining the scores corresponding to the at least two texts to be confirmed, the text to be confirmed with the highest score among the at least two texts to be confirmed can be determined as the target text to be confirmed (the original text corresponding to the first text to be translated) based on the scores corresponding to the at least two texts to be confirmed, and as the second text to be translated.
[0069] Step S250: Translate the second text to be translated to obtain a translated text.
[0070] For the detailed description of step S250, please refer to step S140, which will not be repeated here.
[0071] The text translation method provided in an embodiment of the present application obtains a first text to be translated, extracts keywords from the first text to be translated, obtains a target keyword in the first text to be translated, searches based on the target keyword to obtain multiple texts to be confirmed, selects a target text to be confirmed from the multiple texts to be confirmed based on the first text to be translated as the second text to be translated, and translates the second text to be translated to obtain a translated text. Figure 1 The text translation method shown in this embodiment also selects one text to be confirmed from the multiple texts to be confirmed as the second text to be translated for translation when there are multiple texts to be confirmed, thereby improving the accuracy of the determined second text to be translated and improving the accuracy of the translation.
[0072] See also Figure 5 , Figure 5 The flowchart of the text translation method provided by an embodiment of the present application is shown in FIG. Figure 5 The process shown is described in detail, and the text translation method may specifically include the following steps:
[0073] Step S310: Obtain a first text to be translated.
[0074] Step S320: extracting keywords from the first text to be translated to obtain target keywords in the first text to be translated.
[0075] Step S330: searching according to the target keyword to obtain a second text to be translated, wherein the second text to be translated at least includes the first text to be translated.
[0076] Step S340: Translate the second text to be translated to obtain a translated text.
[0077] For the detailed description of step S310 to step S340 , please refer to step S110 to step S340 , which will not be repeated here.
[0078] Step S350: storing the second text to be translated locally on the electronic device.
[0079] In some embodiments, after obtaining the second text to be translated, the electronic device can store the second text to be translated locally in the electronic device. Based on this, the electronic device can store the original text corresponding to the first text to be translated locally, and the electronic device can directly obtain the second text to be translated locally when the original text of the first text to be translated needs to be translated next time, so as to improve the accuracy of the second text to be translated and the efficiency of obtaining the second text to be translated.
[0080] In some embodiments, after obtaining the second text to be translated, the electronic device can detect the text size of the second text to be translated. Among them, when the text size of the second text to be translated is larger than the preset size, it indicates that the storage space required for the second text to be translated is larger, which will occupy more storage space of the electronic device, thereby causing insufficient storage space of the electronic device. Therefore, the second text to be translated may not be stored locally in the electronic device. Among them, when the text size of the second text to be translated is not larger than the preset size, it indicates that the storage space required for the second text to be translated is smaller, which will not occupy more storage space of the electronic device, thereby causing insufficient storage space of the electronic device. Therefore, the second text to be translated may be stored locally in the electronic device.
[0081] In some embodiments, after obtaining the second text to be translated, the electronic device can detect the remaining storage space of the electronic device. When the remaining storage space of the electronic device is less than the preset storage space, it indicates that the remaining storage space of the electronic device is small, and the storage of the second text to be translated will cause insufficient storage space of the electronic device. Therefore, the second text to be translated may not be stored locally in the electronic device. When the remaining storage space of the electronic device is not less than the preset storage space, it indicates that the remaining storage space of the electronic device is large, and the storage of the second text to be translated will not cause insufficient storage space of the electronic device. Therefore, the second text to be translated may be stored locally in the electronic device.
[0082] The text translation method provided in an embodiment of the present application obtains a first text to be translated, extracts keywords from the first text to be translated, obtains a target keyword from the first text to be translated, searches based on the target keyword to obtain a second text to be translated, wherein the second text to be translated at least includes the first text to be translated, translates the second text to be translated, obtains a translated text, and stores the second translated text locally in the electronic device. Figure 1 The text translation method shown in this embodiment also stores the second text to be translated locally in the electronic device after obtaining the second text to be translated, so that when the same text to be translated is needed next time, the second text to be translated can be directly searched locally, thereby improving the efficiency of text search.
[0083] See also Figure 6 , Figure 6 The flowchart of the text translation method provided by an embodiment of the present application is shown in FIG. Figure 6 The process shown is described in detail, and the text translation method may specifically include the following steps:
[0084] Step S410: Obtain a first text to be translated.
[0085] Step S420: extracting keywords from the first text to be translated to obtain target keywords in the first text to be translated.
[0086] For the detailed description of step S410 to step S420, please refer to step S110 to step S120, which will not be repeated here.
[0087] Step S430: Searching locally on the electronic device according to the target keyword.
[0088] In this embodiment, the electronic device may pre-download and store a portion of the text to be translated locally, so as to establish a database of the text to be translated locally on the electronic device.
[0089] In some implementations, after obtaining the target keyword, the electronic device can search the local area of the electronic device based on the target keyword to try to search and determine the text to be translated based on the target keyword from the local area of the electronic device. For example, after obtaining the target keyword, the electronic device can search the database of the electronic device based on the target keyword to try to search and determine the text to be translated based on the target keyword from the local area of the electronic device.
[0090] Step S440: When the second text to be translated is not found locally in the electronic device, searching is performed on a server in communication with the electronic device according to the target keyword to obtain the second text to be translated.
[0091] In some embodiments, during the process of searching the electronic device locally according to the target keyword, the electronic device can detect whether the second text to be translated is searched locally in the electronic device. When it is determined that the second text to be translated is not searched locally in the electronic device, it can be represented that the electronic device does not store the text to be translated corresponding to the target keyword locally, and the target keyword can be searched on the server communicating with the electronic device to obtain the second text to be translated. When it is determined that the second text to be translated is searched locally in the electronic device, the second text to be translated can be translated to obtain the translated text.
[0092] As an implementation mode, when no document to be translated is searched locally on the electronic device according to the target keyword, it can be considered that the second text to be translated is not searched locally on the electronic device. As another implementation mode, when a document to be translated is searched locally on the electronic device according to the target keyword, it can be determined whether the document to be translated includes the first document to be translated, wherein when it is determined that the document to be translated does not include the first document to be translated, it can be considered that the second text to be translated is not searched locally on the electronic device.
[0093] Step S450: Translate the second text to be translated to obtain a translated text.
[0094] For the detailed description of step S450, please refer to step S140, which will not be repeated here.
[0095] The text translation method provided by an embodiment of the present application obtains a first text to be translated, extracts keywords from the first text to be translated, obtains a target keyword from the first text to be translated, searches the local electronic device based on the target keyword, and when the second text to be translated is not found in the local electronic device, searches the server that communicates with the electronic device based on the target keyword to obtain a second text to be translated, and translates the second text to be translated to obtain a translated text. Figure 1 The text translation method shown in this embodiment also first searches for the second text to be translated locally on the electronic device, and then searches for the second text to be translated from the server if the text is not found locally, so as to improve the efficiency and success rate of the text search.
[0096] See also Figure 7 , Figure 7 The flowchart of the text translation method provided by an embodiment of the present application is shown in FIG. Figure 7 The process shown is described in detail, and the text translation method may specifically include the following steps:
[0097] Step S510: Control the camera to scan.
[0098] In this embodiment, the electronic device includes a camera, which may include a front camera, a rear camera, a telescopic camera, a rotating camera, etc., which are not limited here.
[0099] In some implementations, the electronic device may perform image acquisition through a camera to obtain a scanned image. The electronic device may perform image acquisition of the text to be translated through a camera to obtain an image corresponding to the text to be translated.
[0100] As a method, the electronic device can start the "translation" function of the application in response to an instruction input by the user. When the "translation" function is started, the electronic device can turn on the camera and capture an image of the text to be translated through the camera to obtain an image corresponding to the text to be translated.
[0101] Step S520: Acquire the text scanned by the camera as the first text to be translated.
[0102] In some embodiments, after the electronic device obtains the image scanned by the camera, it can convert the scanned image into text using image-to-text technology to obtain the text scanned by the camera, and use the scanned text as the first text to be translated.
[0103] As a method, after obtaining the image scanned by the camera, the electronic device can use optical character recognition (OCR) to recognize the scanned image, obtain the text scanned by the camera, and use the scanned text as the first text to be translated.
[0104] See also Figure 8 , Figure 8 This application shows Figure 7 The flowchart of step S520 of the text translation method shown in FIG. Figure 8 The process shown is described in detail, and the text translation method may specifically include the following steps:
[0105] Step S521: Acquire the text scanned by the camera.
[0106] In some embodiments, after the electronic device obtains the image scanned by the camera, it can convert the scanned image into text using image-to-text technology to obtain the text scanned by the camera, and use the scanned text as the first text to be translated.
[0107] As a method, after obtaining the image scanned by the camera, the electronic device can use optical character recognition (OCR) to recognize the scanned image, obtain the text scanned by the camera, and use the scanned text as the first text to be translated.
[0108] Step S522: when the text scanned by the camera includes target information, the text scanned by the camera is determined as the first text to be translated.
[0109] In some embodiments, the electronic device may be pre-set and store target information, wherein the target information may be used as a basis for determining the text scanned by the camera. Therefore, in this embodiment, when the text scanned by the camera is obtained, the text scanned by the camera may be compared with the target information to determine whether the text scanned by the camera includes the target information. Wherein, when it is determined that the text scanned by the camera includes the target information, it may be considered that the camera has scanned a more critical part of the text to be translated, that is, the original text may be searched through the text scanned by the camera, and therefore, the text scanned by the camera may be determined as the first text to be translated. Wherein, when it is determined that the text scanned by the camera does not include the target information, it may be considered that the camera has not scanned a more critical part of the text to be translated, that is, there is no way to search for the original text through the text scanned by the camera, and therefore, the text scanned by the camera is not determined as the first text to be translated, and the camera is controlled to continue scanning.
[0110] In some implementations, the target information includes one or a combination of title, author, date, and important keywords.
[0111] In some embodiments, during the process of scanning by the camera, the electronic device may determine whether the text scanned by the camera includes the target information. When it is determined that the text scanned by the camera includes the target information, the scanning may be stopped, and the text scanned by the camera is determined as the first text to be translated. When it is determined that the text scanned by the camera does not include the target information, the scanning may continue.
[0112] In some embodiments, when the electronic device detects an instruction to stop scanning during scanning by the camera, it can stop scanning in response to the instruction to stop scanning, and detect whether the scanned text includes the target information. When it is determined that the text scanned by the electronic device through the camera includes the target information, the scanned text can be determined as the first text to be translated. When it is determined that the text scanned by the electronic device through the camera does not include the target information, a prompt message instructing rescanning can be output.
[0113] Step S530: extracting keywords from the first text to be translated to obtain target keywords in the first text to be translated.
[0114] Step S540: searching according to the target keyword to obtain a second text to be translated, wherein the second text to be translated at least includes the first text to be translated.
[0115] Step S550: Translate the second text to be translated to obtain a translated text.
[0116] For the detailed description of step S530 to step S550, please refer to step S120 to step S140, which will not be repeated here.
[0117] The text translation method provided in an embodiment of the present application controls a camera to scan, obtains the text scanned by the camera as the first text to be translated, extracts keywords from the first text to be translated, obtains the target keywords in the first text to be translated, searches based on the target keywords, obtains the second text to be translated, wherein the second text to be translated includes at least the first text to be translated, and translates the second text to be translated to obtain a translated text. Figure 1 The text translation method shown in this embodiment further controls the camera to scan and obtains the text scanned by the camera as the first text to be translated, thereby improving the efficiency of scanning translation.
[0118] See also Fig. 9 , Fig. 9 The module block diagram of the text translation device provided by the embodiment of the present application is shown. The text translation device 200 is applied to the above electronic device. Fig. 9 The text translation device 200 includes: a first text to be translated acquisition module 210, a target keyword acquisition module 220, a second text to be translated acquisition module 230 and a translation text acquisition module 240, wherein:
[0119] The first text to be translated obtaining module 210 is used to obtain a first text to be translated.
[0120] Furthermore, the electronic device includes a camera, and the first to-be-translated text acquisition module 210 includes: a scanning control submodule and a first to-be-translated text acquisition submodule, wherein:
[0121] The scanning control submodule is used to control the camera to scan.
[0122] The first text to be translated obtaining submodule is used to obtain the text scanned by the camera as the first text to be translated.
[0123] Furthermore, the first text to be translated acquisition submodule includes: a text acquisition unit and a first text to be translated determination unit, wherein:
[0124] The text acquisition unit is used to acquire the text scanned by the camera.
[0125] The first text to be translated determining unit is configured to determine the text scanned by the camera as the first text to be translated when the text scanned by the camera includes target information.
[0126] Furthermore, the first to-be-translated text acquisition submodule includes: an image acquisition unit and a first to-be-translated text acquisition unit, wherein:
[0127] The image acquisition unit is used to acquire the image scanned by the camera.
[0128] The first text-to-be-translated acquiring unit is configured to convert the image scanned by the camera into text by using an image-to-text technology, and obtain the text scanned by the camera as the first text-to-translated text.
[0129] The target keyword obtaining module 220 is used to extract keywords from the first text to be translated to obtain target keywords in the first text to be translated.
[0130] The second text to be translated obtaining module 230 is configured to perform a search based on the target keyword to obtain a second text to be translated, wherein the second text to be translated at least includes the first text to be translated.
[0131] Furthermore, the second to-be-translated text acquisition module 230 includes: a to-be-confirmed text acquisition submodule and a second to-be-translated text acquisition submodule, wherein:
[0132] The submodule for obtaining texts to be confirmed is used to search according to the target keywords to obtain multiple texts to be confirmed.
[0133] The second text to be translated obtaining submodule is used to select a target text to be confirmed from the plurality of texts to be confirmed as the second text to be translated based on the first text to be translated.
[0134] Furthermore, the second text to be translated obtaining submodule includes: a comparison result obtaining unit and a second text to be translated obtaining unit, wherein:
[0135] The comparison result obtaining unit is used to compare the first text to be translated with the multiple texts to be confirmed respectively to obtain comparison results.
[0136] The second text to be translated acquiring unit is configured to use the target text to be translated as the second text to be translated when the comparison result indicates that a target text to be translated among the plurality of texts to be translated includes the first text to be translated.
[0137] Furthermore, the second text to be translated acquisition unit includes: a browsing parameter acquisition subunit and a second text to be translated acquisition subunit, wherein:
[0138] The browsing parameter acquisition subunit is used to acquire the browsing parameters corresponding to each of the at least two texts to be confirmed when the comparison result indicates that at least two texts to be confirmed among the multiple texts to be confirmed include the first text to be translated.
[0139] The second text to be translated obtaining subunit is used to determine a target text to be confirmed from the at least two texts to be confirmed as the second text to be translated based on the browsing parameters corresponding to the at least two texts to be confirmed.
[0140] Furthermore, the second to-be-translated text acquisition module 230 includes: a local search submodule and a network search submodule, wherein:
[0141] The local search submodule is used to search locally on the electronic device according to the target keyword.
[0142] The network search submodule is used to search the server communicating with the electronic device according to the target keyword to obtain the second text to be translated when the second text to be translated is not found locally in the electronic device.
[0143] The translation text obtaining module 240 is used to translate the second text to be translated to obtain a translated text.
[0144] Furthermore, the text translation device 200 further includes: a text storage module for translation, wherein:
[0145] The to-be-translated text storage module is used to store the second to-be-translated text locally in the electronic device.
[0146] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and modules can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here.
[0147] In several embodiments provided in the present application, the coupling between modules may be electrical, mechanical or other forms of coupling.
[0148] In addition, each functional module in each embodiment of the present application can be integrated into a processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above integrated modules can be implemented in the form of hardware or software functional modules.
[0149] See also Fig.10, which shows a structural block diagram of an electronic device 100 provided in an embodiment of the present application. The electronic device 100 may be an electronic device capable of running applications, such as a smart phone, a tablet computer, an e-book, etc. The electronic device 100 in the present application may include one or more of the following components: a processor 110, a memory 120, and one or more applications, wherein the one or more applications may be stored in the memory 120 and configured to be executed by one or more processors 110, and the one or more programs are configured to execute the method described in the aforementioned method embodiment.
[0150] Among them, the processor 110 may include one or more processing cores. The processor 110 uses various interfaces and lines to connect various parts of the entire electronic device 100, and executes various functions and processes data of the electronic device 100 by running or executing instructions, programs, code sets or instruction sets stored in the memory 120, and calling data stored in the memory 120. Optionally, the processor 110 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 110 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 110, but may be implemented separately through a communication chip.
[0151] The memory 120 may include a random access memory (RAM) or a read-only memory (ROM). The memory 120 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 120 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 (such as a phone book, audio and video data, chat record data) created by the electronic device 100 during use.
[0152] See also Fig.11 , which shows a structural block diagram of a computer-readable storage medium provided in an embodiment of the present application. The computer-readable medium 300 stores program codes, which can be called by a processor to execute the method described in the above method embodiment.
[0153] The computer readable storage medium 300 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk, or a ROM. Optionally, the computer readable storage medium 300 includes a non-transitory computer-readable storage medium. The computer readable storage medium 300 has storage space for program code 310 that performs any method steps in the above method. These program codes can be read from or written to one or more computer program products. The program code 310 can be compressed, for example, in an appropriate form.
[0154] In summary, the text translation method, device, electronic device, and storage medium provided in the embodiments of the present application obtain a first text to be translated, extract keywords from the first text to be translated, obtain target keywords in the first text to be translated, search based on the target keywords, obtain a second text to be translated, wherein the second text to be translated at least includes the first text to be translated, and translate the second text to be translated to obtain a translated text. The present application simplifies the operation steps for translating long texts and improves translation efficiency by obtaining keywords in the first text to be translated, searching for keywords to obtain a second text to be translated including the first text to be translated, and translating the second text to be translated to obtain a translated text.
[0155] 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 it. 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 features therein. However, 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 translation method, characterized in that: Applied to electronic equipment, the method comprises: Get the first text to be translated; Extracting keywords from the first text to be translated to obtain target keywords in the first text to be translated; Searching according to the target keyword to obtain a second text to be translated, wherein the second text to be translated at least includes the first text to be translated; Translating the second text to be translated to obtain a translated text; The step of searching according to the target keyword to obtain a second text to be translated includes: Searching according to the target keyword to obtain multiple texts to be confirmed; Comparing the first text to be translated with the multiple texts to be confirmed respectively to obtain comparison results; When the comparison result indicates that a target text to be confirmed among the multiple texts to be confirmed includes the first text to be translated, the target text to be confirmed is used as the second text to be translated, wherein the target text to be confirmed is the original text corresponding to the first text to be translated.
2. The method according to claim 1, characterized in that When the comparison result indicates that a target text to be confirmed among the plurality of texts to be confirmed includes the first text to be translated, taking the target text to be confirmed as the second text to be translated comprises: When the comparison result indicates that at least two of the plurality of texts to be confirmed include the first text to be translated, obtaining browsing parameters corresponding to each of the at least two texts to be confirmed; Based on the browsing parameters corresponding to the at least two texts to be confirmed, a target text to be confirmed is determined from the at least two texts to be confirmed as the second text to be translated.
3. The method according to claim 1, characterized in that After searching according to the target keyword to obtain a second text to be translated, the method further includes: The second text to be translated is stored locally in the electronic device.
4. The method according to claim 1, characterized in that: The step of searching according to the target keyword to obtain a second text to be translated includes: Searching locally on the electronic device according to the target keyword; When the second text to be translated is not found locally in the electronic device, a search is performed on a server in communication with the electronic device according to the target keyword to obtain the second text to be translated.
5. The method according to any one of claims 1 to 4, characterized in that: The electronic device includes a camera, and the step of obtaining a first text to be translated includes: Controlling the camera to scan; The text scanned by the camera is obtained as the first text to be translated.
6. The method according to claim 5, characterized in that The step of obtaining the text scanned by the camera as the first text to be translated includes: Obtaining text scanned by the camera; When the text scanned by the camera includes target information, the text scanned by the camera is determined as the first text to be translated.
7. A text translation device, characterized in that: Applied to electronic equipment, the device comprises: A first text to be translated obtaining module, used to obtain a first text to be translated; a target keyword obtaining module, configured to extract keywords from the first text to be translated, and obtain target keywords from the first text to be translated; A second text to be translated obtaining module, configured to search according to the target keyword to obtain a second text to be translated, wherein the second text to be translated at least includes the first text to be translated; A translation text obtaining module, used for translating the second text to be translated to obtain a translation text; Wherein, the second module for obtaining text to be translated includes: A submodule for obtaining texts to be confirmed is used to search according to the target keyword to obtain multiple texts to be confirmed; A comparison result obtaining unit, used for comparing the first text to be translated with the plurality of texts to be confirmed respectively to obtain a comparison result; The second text to be translated acquiring unit is configured to use the target text to be translated as the second text to be translated when the comparison result indicates that the target text to be translated among the multiple texts to be translated includes the first text to be translated, wherein the target text to be translated is the original text corresponding to the first text to be translated.
8. An electronic device, characterized in that: The method comprises a memory and a processor, wherein the memory is coupled to the processor, and the memory stores instructions. When the instructions are executed by the processor, the processor executes the method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program codes, which can be called by a processor to execute the method according to any one of claims 1 to 6.
