A character conversion method, device, electronic equipment and storage medium

CN117454849BActive Publication Date: 2026-09-15BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210844638.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-18
Publication Date
2026-09-15
Estimated Expiration
2042-07-18

AI Technical Summary

Benefits of technology

[0018] This disclosure provides a text conversion method, apparatus, electronic device, and storage medium. The method includes: receiving a conversion instruction for a target original string, wherein the target original string contains at least one target original character; responding to the conversion instruction, performing text conversion on the at least one target original character based on a target trie to obtain target converted text, wherein the target trie is a trie corresponding to a target conversion type of the target original string, and the target conversion type includes traditional Chinese to simplified Chinese and/or simplified Chinese to traditional Chinese; and generating a text conversion result of the target original string based on the target converted text. Using this technical solution, upon receiving a conversion instruction, text conversion is performed directly on at least one target original character based on a target trie, eliminating the need for multiple searches in multiple databases or lists, thus improving the efficiency and accuracy of text conversion.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117454849B_ABST
    Figure CN117454849B_ABST
Patent Text Reader

Abstract

Embodiments of the present disclosure provide a character conversion method and device, electronic equipment and storage medium. The method comprises: receiving a conversion instruction for a target original string; in response to the conversion instruction, performing character conversion on at least one target original character based on a target dictionary tree to obtain a target converted character, wherein the target dictionary tree corresponds to a target conversion type of the target original string; and generating a character conversion result of the target original string according to the target converted character. By using the method, the efficiency and accuracy of character conversion are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and more particularly to a text conversion method, apparatus, electronic device, and storage medium. Background Technology

[0002] Currently, an increasing number of reading platforms are emerging on the market, offering online reading options for users, such as platforms for reading ancient books. Since ancient books are mostly written in traditional Chinese characters, an online method for converting these characters is needed.

[0003] Existing text conversion methods mainly convert between simplified and traditional Chinese characters in a one-to-one manner, which is relatively limited in functionality and slow in conversion speed. Summary of the Invention

[0004] This disclosure provides a text conversion method, apparatus, electronic device, and storage medium to improve the efficiency of text conversion.

[0005] In a first aspect, embodiments of this disclosure provide a text conversion method, including:

[0006] Receive a conversion instruction for a target raw string, wherein the target raw string contains at least one target raw text;

[0007] In response to the conversion instruction, the at least one target original text is converted based on the target dictionary to obtain the target converted text, wherein the target dictionary is a dictionary corresponding to the target conversion type of the target original string, and the target conversion type includes traditional Chinese to simplified Chinese and / or simplified Chinese to traditional Chinese;

[0008] The text conversion result of the original target string is generated based on the target text.

[0009] Secondly, embodiments of this disclosure also provide a text conversion device, including:

[0010] A receiving module is configured to receive a conversion instruction for a target raw string, wherein the target raw string contains at least one target raw character;

[0011] A response module is configured to respond to the conversion instruction by performing text conversion on the at least one target original text based on the target dictionary to obtain the target converted text, wherein the target dictionary is a dictionary corresponding to the target conversion type of the target original string, and the target conversion type includes traditional Chinese to simplified Chinese and / or simplified Chinese to traditional Chinese;

[0012] The generation module is used to generate the text conversion result of the original target string based on the target text to be converted.

[0013] Thirdly, embodiments of this disclosure also provide an electronic device, including:

[0014] One or more processors;

[0015] Memory, used to store one or more programs.

[0016] When the one or more programs are executed by the one or more processors, the one or more processors implement the text conversion method as described in the embodiments of this disclosure.

[0017] Fourthly, embodiments of this disclosure also provide a computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the text conversion method as described in embodiments of this disclosure.

[0018] This disclosure provides a text conversion method, apparatus, electronic device, and storage medium. The method includes: receiving a conversion instruction for a target original string, wherein the target original string contains at least one target original character; responding to the conversion instruction, performing text conversion on the at least one target original character based on a target trie to obtain target converted text, wherein the target trie is a trie corresponding to a target conversion type of the target original string, and the target conversion type includes traditional Chinese to simplified Chinese and / or simplified Chinese to traditional Chinese; and generating a text conversion result of the target original string based on the target converted text. Using this technical solution, upon receiving a conversion instruction, text conversion is performed directly on at least one target original character based on a target trie, eliminating the need for multiple searches in multiple databases or lists, thus improving the efficiency and accuracy of text conversion. Attached Figure Description

[0019] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale.

[0020] Figure 1 A flowchart illustrating a text conversion method provided in this embodiment of the disclosure;

[0021] Figure 2 A flowchart illustrating another text conversion method provided in this embodiment of the disclosure;

[0022] Figure 3 A schematic diagram illustrating the overall execution process of a text conversion method provided in this embodiment of the disclosure;

[0023] Figure 4This is a schematic diagram of a process for obtaining a target conversion file provided in an embodiment of the present disclosure;

[0024] Figure 5 A schematic diagram of a trie structure provided in an embodiment of this disclosure;

[0025] Figure 6 A schematic diagram illustrating a process for constructing a trie according to an embodiment of this disclosure;

[0026] Figure 7 A schematic diagram illustrating the process of converting a target raw string according to an embodiment of this disclosure;

[0027] Figure 8 This is a schematic diagram of the structure of a text conversion device provided in an embodiment of the present disclosure;

[0028] Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation

[0029] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.

[0030] It should be understood that the steps described in the method embodiments of this disclosure may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of this disclosure is not limited in this respect.

[0031] The term "comprising" and its variations as used herein are open-ended inclusions, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Definitions of other terms will be given in the description below.

[0032] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are used only to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependencies.

[0033] It should be noted that the modifiers "a", "one" and "a plurality of" mentioned in the present disclosure are schematic rather than restrictive. Those skilled in the art should understand that, unless otherwise clearly specified in the context, it should be interpreted as "one or more".

[0034] The names of messages or information interacted between a plurality of devices in the embodiments of the present disclosure are only for illustrative purposes, and are not intended to limit the scope of these messages or information.

[0035] Figure 1 is a schematic flow chart of a character conversion method provided by an embodiment of the present disclosure. The method is applicable to the situation of converting characters, and can be executed by a character conversion device, wherein the device can be implemented by software and / or hardware and is generally integrated in an electronic device. In this embodiment, the electronic device includes, but is not limited to: computers, notebook computers, tablet computers and / or mobile phones and other devices.

[0036] It can be understood that, in some embodiments, there is a conversion scenario where one traditional Chinese character or variant character corresponds to multiple simplified Chinese characters. For example, the character "乾" is a simplified Chinese character itself when pronounced as "qián", and can form the word "qián kūn" (universe); when pronounced as "gān", it is the traditional Chinese character of "干" and can form the word "gàn fù zhī gǔ". Therefore, for an original character string, the existing technical solutions read a character and then search for the character and its corresponding simplified character, which may cause the problem of inaccurate character conversion.

[0037] In other embodiments, there is a conversion scenario where one simplified Chinese character corresponds to multiple traditional Chinese characters or variant characters. For example, in ancient book search, the search results need to include all glyphs of the keyword, and the simplified version of the keyword is output as the matching basis, which cannot be achieved by the existing technical solutions.

[0038] Meanwhile, with more and more chapters of ancient books included, some rare characters may not be included in the font library. An incomplete font library will cause the problem of invalid character conversion, and the existing character expansion methods are relatively cumbersome.

[0039] Existing open-source tools (such as Open CC) support one traditional character corresponding to multiple simplified characters and include some variant characters, but the character conversion has redundancy and is not suitable for ancient books; and they cannot output all corresponding traditional characters or variant characters for one simplified character.

[0040] Based on this, the character conversion method provided by the embodiment of the present disclosure includes the following steps:

[0041] S110: receiving a conversion instruction for a target original character string, wherein the target original character string includes at least one target original character.

[0042] The target raw string can be considered as the string that needs to be converted into text. The target raw string contains one or more target raw texts, and the target raw text can be a single text.

[0043] A conversion instruction can be understood as an instruction to perform text conversion on the target original string. In this embodiment, a conversion instruction can be received to perform text conversion. The method of triggering the generation of the conversion instruction is not limited. For example, the conversion instruction can be triggered by clicking a conversion button or conversion icon after selecting the target original string, or by entering a shortcut command through an input device (such as a keyboard) after selecting the target original string. The method of receiving the conversion instruction can be determined according to the actual triggering situation. For example, when the conversion instruction is triggered by clicking a conversion button or conversion icon, the electronic device can analyze the click operation and generate the corresponding conversion instruction. For instance, a user can select the target original string to be converted and click the corresponding conversion button to cause the electronic device to generate a conversion instruction for the target original string.

[0044] S120. In response to the conversion instruction, the at least one target original text is converted based on the target dictionary to obtain the target converted text, wherein the target dictionary is a dictionary corresponding to the target conversion type of the target original string, and the target conversion type includes traditional Chinese to simplified Chinese and / or simplified Chinese to traditional Chinese.

[0045] The target trie can be considered as a trie corresponding to the target conversion type of the original target string. The target trie stores a large number of simplified Chinese characters / words corresponding to traditional Chinese characters / words, and / or traditional Chinese characters / words corresponding to simplified Chinese characters / words, used for converting the original target text. The target conversion type can include traditional to simplified and / or simplified to traditional; more specifically, the target conversion type can include traditional to simplified characters, traditional to simplified words, and simplified to traditional characters. The target converted text can refer to the text obtained after converting the original target text.

[0046] Upon receiving a conversion instruction for the target original string, the system can respond to this instruction by performing text conversion on at least one target original character in the target original string based on the target dictionary to obtain the target converted character. The specific conversion process is not limited. For example, the target converted character can be sequentially searched in the target dictionary according to the order of the target original characters in the target original string; alternatively, all target original characters contained in the target original string can be determined first, and then the target converted character corresponding to each target original character can be searched in the target dictionary simultaneously. This embodiment does not limit this approach.

[0047] S130. Generate the text conversion result of the original target string based on the target converted text.

[0048] The text conversion result can refer to the string obtained after converting the original target string into a text string.

[0049] After obtaining the target converted text corresponding to all target original text in the target original string, the text conversion result of the target original string can be generated based on the target converted text. The steps for generating the text conversion result are not limited here. For example, the target converted text can be concatenated according to the order of the target original text corresponding to the target converted text in the target original string to obtain the text conversion result; or the text conversion result of the target original string can be generated according to preset rules. The preset rules can be set in advance by relevant personnel, which will not be elaborated further here.

[0050] This disclosure provides a text conversion method that receives a conversion instruction for a target original string, wherein the target original string contains at least one target original character; in response to the conversion instruction, performs text conversion on the at least one target original character based on a target trie to obtain a target converted character, wherein the target trie is a trie corresponding to a target conversion type of the target original string, and the target conversion type includes traditional Chinese to simplified Chinese and / or simplified Chinese to traditional Chinese; and generates a text conversion result of the target original string based on the target converted character. Using this method, upon receiving a conversion instruction, text conversion is performed directly on at least one target original character based on the target trie, eliminating the need for multiple searches in multiple databases or lists, thus improving the efficiency and accuracy of text conversion.

[0051] In one embodiment, prior to receiving the conversion instruction for the target original string, the method further includes:

[0052] Obtain a target conversion file in a preset format, wherein the target conversion file is used to record the conversion strings corresponding to different original strings, and the original strings contain at least one original text.

[0053] A trie is constructed based on the target conversion file, wherein the trie includes the target trie.

[0054] The target conversion file is used to record the conversion strings corresponding to different original strings. The original string can contain at least one original text. For example, the original string can include text or words. Correspondingly, when the original string is text, it can contain only one original text. When the original string is words, it can contain at least two original texts. The preset format refers to the format set in advance by relevant personnel, such as JSON format.

[0055] Specifically, firstly, a target conversion file in a preset format can be obtained. The method of obtaining the target conversion file is not limited. For example, it can be obtained directly from other devices, or it can be obtained by converting files of other formats, such as txt format. Then, a trie is constructed based on the obtained target conversion file. The constructed trie can correspond to one or more conversion types. Therefore, the construction process can vary depending on the conversion type. This embodiment will not elaborate on this further, as long as the trie can be constructed.

[0056] In one embodiment, obtaining the target conversion file in a preset format includes:

[0057] Obtain the original conversion file in the original format and create a base object, wherein the original conversion file includes a first original conversion file and / or a second original conversion file, the first original conversion file corresponds to the conversion type from traditional Chinese to simplified Chinese, and the second original conversion file corresponds to the conversion type from simplified Chinese to traditional Chinese;

[0058] For each original conversion file, identify each original string in the current original conversion file and the corresponding conversion string for each original string;

[0059] According to the preset concatenation rules, each original string in the current original conversion file and the corresponding conversion string of each original string are concatenated to obtain the conversion content corresponding to the current original conversion file.

[0060] The conversion type and conversion content of each original conversion file are written into the base object to obtain the target conversion file in the preset format.

[0061] The original conversion file can refer to a file existing in its original format, such as txt or excel. The original conversion file contains multiple original strings and a corresponding conversion string for each original string. For example, the original conversion file may include a first original conversion file and / or a second original conversion file, specifically determined by the conversion type of the dictionary to be constructed. For instance, when constructing a dictionary with Traditional Chinese to Simplified Chinese conversion functionality, the original conversion file may include the first original conversion file; when constructing a dictionary with Simplified Chinese to Traditional Chinese conversion functionality, the original conversion file may include the second original conversion file; when constructing a dictionary with both Simplified Chinese to Traditional Chinese and Traditional Chinese to Simplified Chinese conversion functionality, the original conversion file may include both the first and second original conversion files.

[0062] The first original conversion file can correspond to the conversion type from Traditional Chinese to Simplified Chinese. For example, the first original conversion file may include a file for converting Traditional Chinese characters to Simplified Chinese characters and / or a file for converting Traditional Chinese words to Simplified Chinese words. The file for converting Traditional Chinese characters to Simplified Chinese characters contains several Traditional Chinese characters and their corresponding Simplified Chinese counterparts, and the file for converting Traditional Chinese words to Simplified Chinese words contains several Traditional Chinese words and their corresponding Simplified Chinese counterparts. The second original conversion file can correspond to the conversion type from Simplified Chinese to Traditional Chinese characters. The second original conversion file may include a file for converting Simplified Chinese characters to Traditional Chinese characters, and the file for converting Simplified Chinese characters to Traditional Chinese characters contains several Simplified Chinese characters and their corresponding Simplified Chinese counterparts. It should be noted that in this embodiment, relevant personnel can directly add new original strings and corresponding conversion strings to the original conversion files to expand the strings, thereby reducing the difficulty of expansion. The basic object is the initially constructed object, such as an empty object.

[0063] In this step, the original conversion file in its original format is first obtained and a basic object is created. Then, the original strings and their corresponding conversion strings in each original conversion file are traversed. For example, for each original conversion file, each original string and its corresponding conversion string can be identified. Each original string and its corresponding conversion string in the current original conversion file are concatenated according to a preset concatenation rule to obtain the conversion content corresponding to the current original conversion file. The preset concatenation rule can be set by relevant personnel. For example, the original string and its corresponding conversion string can be concatenated with a space. If there is a case where one original string corresponds to multiple conversion strings, the multiple conversion strings can be connected with commas. Different original strings and their corresponding conversion strings can be concatenated with "|".

[0064] Finally, the conversion type and conversion content of each original conversion file can be written into the base object to obtain the target conversion file in the preset format. The specific writing steps are not limited. For example, the conversion type of the original conversion file can be used as the key and the conversion content of the original conversion file can be used as the value to write into the base object.

[0065] In one embodiment, constructing a trie based on the target conversion file includes:

[0066] Construct a target dictionary tree corresponding to the target transformation type based on the target transformation file.

[0067] In this embodiment, a target dictionary tree corresponding to the target conversion type can be constructed based on the target conversion file. For example, when the target conversion type is traditional Chinese to simplified Chinese, a target dictionary tree with the function of converting traditional Chinese characters to simplified Chinese characters and / or converting traditional Chinese words to simplified Chinese words can be constructed. Preferably, a target dictionary tree with the function of converting traditional Chinese characters to simplified Chinese characters and converting traditional Chinese words to simplified Chinese words can be constructed. When the target conversion type is simplified Chinese to traditional Chinese, a target dictionary tree with the function of converting simplified Chinese characters to traditional Chinese characters can be constructed.

[0068] In one embodiment, constructing a target trie corresponding to the target conversion type based on the target conversion file includes:

[0069] Construct a basic trie corresponding to the target conversion type, and obtain the conversion content corresponding to the target conversion type from the target conversion file, wherein the conversion content contains at least one original string and a conversion string corresponding to the at least one original string;

[0070] In the basic trie, a node corresponding to each original string is created, and the transformed string corresponding to each original string is used as the transformation attribute value of the node corresponding to the original string, thus obtaining the target trie.

[0071] The basic dictionary tree can refer to the initially created dictionary tree corresponding to the target conversion type. For example, when the target conversion type is traditional Chinese to simplified Chinese or simplified Chinese to traditional Chinese, the basic dictionary tree can be a dictionary tree with one level, that is, a dictionary tree that only contains the root node. The final target dictionary tree needs to be obtained by creating nodes in the basic dictionary tree through the target conversion file.

[0072] Specifically, after constructing the basic trie corresponding to the target conversion type, the conversion content corresponding to the target conversion type can be obtained from the target conversion file. That is, each original string and its corresponding conversion string can be obtained from the conversion content corresponding to the target conversion type. Then, a node corresponding to each original string is created in the basic trie, and the conversion string corresponding to each original string is used as the conversion attribute value of the node corresponding to the original string, thus obtaining the target trie. The steps for creating the node corresponding to each original string are not limited. For example, the nodes corresponding to the original strings can be created sequentially according to the order of the original strings. Alternatively, nodes corresponding to original strings that do not contain the same characters can be created simultaneously in the basic trie, and nodes corresponding to original strings that contain the same characters can be created sequentially. This embodiment does not limit this.

[0073] In one embodiment, before creating a node corresponding to each original string in the basic trie, the method further includes:

[0074] The converted content is segmented to obtain each original string contained in the converted content and the corresponding converted string.

[0075] It can be assumed that the conversion content contains multiple original strings and their corresponding conversion strings. These original strings are concatenated according to a preset concatenation rule. Therefore, before creating a node corresponding to each original string, it is necessary to segment the original strings and their corresponding conversion strings within the conversion content to obtain the individual original strings and their corresponding conversion strings. The segmentation process can be determined according to the preset concatenation rule. For example, when an original string and its corresponding conversion string are concatenated using spaces, if one original string corresponds to multiple conversion strings, the multiple conversion strings are connected using commas. When different original strings and their corresponding conversion strings are concatenated using "|", each "|" can be used to segment different original strings and their corresponding conversion strings. For each original string and its corresponding conversion string, the original string and its corresponding conversion string are separated by spaces, and the different conversion strings corresponding to the original string are separated by commas.

[0076] In one embodiment, the step of creating a node corresponding to each original string in the basic trie and using the transformed string corresponding to each original string as the transformed attribute value of the node corresponding to the original string to obtain the target trie includes:

[0077] The first original string in the transformed content is taken as the current string, and the basic trie is taken as the current trie, wherein each original string is sorted according to a preset rule;

[0078] Create a node in the current trie corresponding to the current string, and use the transformed string corresponding to the current string as the transformed attribute value of the node corresponding to the current string, so as to update the current trie;

[0079] Determine whether a next original string exists in the transformed content. If yes, use the next original string as the current string, use the updated current trie as the current trie, and return to execute the operation of creating a node corresponding to the current string in the current trie. If no, use the updated current trie as the target trie.

[0080] In one implementation, nodes can be created and corresponding transformation attribute values ​​set according to the order of the original strings to obtain the target trie. This order can be flexibly set, such as the order in which the original strings are arranged within the transformed content or a random order.

[0081] Specifically, firstly, the first original string in the transformed content can be used as the current string, and the basic trie can be used as the current trie; then, a node corresponding to the current string can be created in the current trie, and the transformed string corresponding to the current string can be used as the transformation attribute value of the node corresponding to the current string, so as to update the current trie;

[0082] Next, it checks if a next original string exists in the transformed content. If a next original string exists, it continues to create the node corresponding to the next original string and set the transformation attribute value for the node. That is, it uses the next original string as the current string and the updated current trie as the current trie, repeating the operation of creating the node corresponding to the current string in the current trie to complete the creation of the corresponding node and the setting of the corresponding transformation attribute value for the current string. It then continues to check if a next original string exists in the transformed content, and subsequent steps are similar, until no next original string exists. If no next original string exists, the updated current trie can be used as the target trie. The method of creating the node corresponding to the current string in the current trie is not limited and can be determined according to the actual situation of the current string, as long as the corresponding node can be created.

[0083] In one embodiment, creating a node corresponding to the current string in the current trie includes:

[0084] The first original character in the current string is taken as the second current character, and the root node of the current trie is taken as the second current node;

[0085] Determine whether the second current node has a second child node corresponding to the second current text;

[0086] If so, then the next original text in the current string is taken as the second current text, the second child node is taken as the second current node, and the operation of determining whether the second current node has a second child node corresponding to the second current text is returned until there is no next original text in the current string.

[0087] If not, then create a second child node corresponding to the second current text for the second current node, take the next original text in the current string as the second current text, take the second child node as the second current node, and return to execute the operation of judging whether the second current node has a second child node corresponding to the second current text, until there is no next original text in the current string;

[0088] When there is no next original text in the current string, the second current node is taken as the node corresponding to the current string.

[0089] The first original text can be considered the first original text in the current string. The second original text can be considered the original text for which the corresponding node is to be created. The second original node can refer to a node that may have a second child node corresponding to the second original text; the second child node is the node corresponding to the second original text. The next original text can be considered the text in the current string that is after and adjacent to the second original text.

[0090] In one implementation, when creating a node corresponding to the current string in the current trie, it can be created according to the order of the original characters in the current string. For example, it can start from the first original character of the current string, take the first original character of the current string as the second current character, and take the root node of the current trie as the second current node. Then, it is determined whether the second current node has a second child node corresponding to the second current character. If it does, the node corresponding to the second current character has been created and can be directly used as the second child node corresponding to the second current character. Continue to take the next original character in the current string as the second current character, take the second child node as the second current node, and return to perform the operation of determining whether the second current node has a second child node corresponding to the second current character, until there is no next original character in the current string.

[0091] If it does not exist, it means that there is no node corresponding to the second current text in the current trie. Therefore, it is necessary to create a second child node corresponding to the second current text for the second current node. Continue to use the next original text in the current string as the second current text, the second child node as the second current node, and return to perform the operation of checking whether there is a second child node corresponding to the second current text for the second current node, until there is no next original text in the current string. If there is no next original text in the current string, then the second current node can be used as the node corresponding to the current string.

[0092] Figure 2 This is a schematic flowchart illustrating another text conversion method provided in this embodiment. The solution in this embodiment can be combined with one or more optional solutions in the above embodiments.

[0093] S210. Receive a conversion instruction for a target original string, wherein the target original string contains at least one target original character.

[0094] S220. In response to the conversion instruction, according to the arrangement order of the at least one target original text in the target original string, the target conversion text matching the at least one target original text is sequentially searched in the target dictionary, wherein the target dictionary is a dictionary corresponding to the target conversion type of the target original string, and the target conversion type includes traditional Chinese to simplified Chinese and / or simplified Chinese to traditional Chinese.

[0095] In this embodiment, after receiving a conversion instruction for the target original string, the target converted text that matches the target original text can be sequentially searched in the target dictionary according to the order in which the target original text is arranged in the target original string. The steps for searching for the target converted text are not limited here, but can be determined according to the specific structure of the target dictionary.

[0096] In one embodiment, each edge in the target trie corresponds to an original text; for each node in the target trie, the original string corresponding to the node is composed of the original text corresponding to each edge in the path from the root node of the target trie to the node, and the transformation attribute value of the node is the transformation string corresponding to the original string of the node.

[0097] It can be considered that the trie structure has a high query efficiency of O(L) (where L is the length of the string to be queried) and the characteristic of dynamic query. In the scenario of reading ancient books, the function of converting traditional Chinese characters to simplified Chinese characters is to convert the entire ancient text. It is necessary to traverse each character in the ancient text one by one, and also to convert it to different simplified characters according to fixed word combinations. If a hash or double array structure is used, it will make the matching of words more complicated. Therefore, this embodiment uses a trie structure as the storage structure for traditional and simplified characters to improve the efficiency of text conversion.

[0098] In this embodiment, each edge in the target trie can correspond to an original character, which may contain Unicode. The target trie also contains multiple nodes for storing the converted characters. For each node, the corresponding original string can be composed of the original characters corresponding to each edge in the path from the root node of the target trie to the node. The conversion attribute value of a node can be considered as the converted string corresponding to the original string of the node; the converted string refers to the string formed after converting each original character in the original string.

[0099] That is, the conversion attribute value of each node except the root node can be used as the conversion value of the original text on the path from the root node to the current node. For converting traditional Chinese characters to simplified Chinese characters and vice versa, the corresponding target trie is a two-level tree (including the root node), while for converting traditional Chinese words to simplified Chinese words, the corresponding target trie will be split into multiple levels (such as more than or equal to three levels) according to the length of the original string.

[0100] In one embodiment, the process of sequentially searching for target converted text that matches the at least one target original text in the target original string, according to the order in which the at least one target original text is arranged, includes:

[0101] The first target original text in the target original string is taken as the first current text;

[0102] The root node of the target trie is taken as the first current node;

[0103] Determine whether the first current node has a first child node corresponding to the first current text;

[0104] If so, then the first child node is taken as the first current node, the next target original text in the target original string is taken as the first current text, and the operation of determining whether the first current node has a first child node corresponding to the first current text is returned until there is no next target original text in the target original string.

[0105] If not, the transformation attribute value of the first current node is written into the transformation array, and the operation of taking the root node in the target trie as the first current node is returned, until there is no next target original text in the target original string.

[0106] The first target original text can be considered as the first target original text in the target original string. The first current text can be considered as the target original text to be converted. The first current node can refer to the node that may have the first child node corresponding to the first current text. The first child node is the node corresponding to the current target original text.

[0107] The next target original text can be considered as the text in the target original string that is located after the first current text and adjacent to the first current text. The transformation array can refer to an array used to store the transformed text of each target.

[0108] Specifically, we can start by looking up the first target character in the target string, treating it as the first current character, and then searching the target trie. We can also use the root node of the target trie as the first current node. At this point, we can determine whether the first current node has a first child node corresponding to the first current character.

[0109] If the first current node contains a first child node corresponding to the first current text, it means that the target original text exists in the target trie. Then, the corresponding first child node can be used as the first current node to search for the node corresponding to the next target original text in the target original string. Similarly, the next target original text in the target original string can be used as the first current text. It is then determined whether the first current node contains a first child node corresponding to the first current text. If it does, the search continues for the node corresponding to the next target original text, using the current first child node as the first current node and the next target original text in the target original string (currently the third target original text in the target original string) as the first current text, until the target original string has been traversed. If it does not, it means that there is no node corresponding to the first current text. Therefore, the transformation attribute value of the first current node can be written into the transformation array, and the operation of using the root node in the target trie as the first current node is returned. The process of re-determining whether the first current node contains a first child node corresponding to the first current text is repeated, and subsequent steps are similar to the above.

[0110] If the target trie does not contain a first child node corresponding to the first current character, it means that the target original character does not exist in the target trie, i.e., a simplified / traditional character not found in the character set. In this case, the conversion attribute value of the first current node (i.e., the root node) (which can be a preset value of 0 to remind the user that no target converted character corresponding to the target original character was found) can be written to the conversion array, or no new character can be added to the conversion array. The next target original character in the target original string is taken as the first current character, and the operation of taking the root node in the target trie as the first current node is returned to search for the target converted character matching the first current character in the target trie until no next original character exists in the target original string. During the above search process, the first current node may or may not have a conversion attribute value. For example, when the first current node has a conversion attribute value, it can be directly written to the conversion array during the process of writing the conversion attribute value of the first current node. When the first current node does not have a conversion attribute value, the search can be performed according to the actual situation.

[0111] In one embodiment, writing the transformation attribute value of the first current node into the transformation array includes:

[0112] If the first current node has a transformation attribute value, then write the transformation attribute value of the first current node into the transformation array.

[0113] In one embodiment, writing the transformation attribute value of the first current node into the transformation array further includes:

[0114] If the first current node does not have a conversion attribute value, then the target node in the target path that is closest to the first current node and has a conversion attribute value is taken as the first current node, the first current text in the target original string when the target node is taken as the first current node is taken as the first current text, and the conversion attribute value of the first current node is written into the conversion array.

[0115] In one implementation, when the first current node does not have a conversion attribute value, the parent node of the first current node is used as the first current node, and the previous original text in the target original string is used as the first current text. It is then determined whether the current node (i.e., the first current node) has a conversion attribute value. If the current node (i.e., the first current node) has a conversion attribute value, the conversion attribute value of this first current node is written into the conversion array. If the current node (i.e., the first current node) does not have a conversion attribute value, the operation of using the parent node of the current node as the first current node and the previous original text in the target original string as the first current text is returned. If a target node with a conversion attribute value is found, the conversion attribute value of the target node is used as the conversion attribute value of the first current node and written into the conversion array. If no target node with a conversion attribute value exists in the target path, the parent node of the first current node is used as the first current node, and the above operation is repeated.

[0116] S230. Generate the text conversion result of the original target string based on the target converted text.

[0117] The text conversion method provided in this disclosure, in response to a conversion instruction for a target original string, can sequentially traverse the target dictionary tree to find target conversion text that matches each target original text according to the order in which the target original text is arranged in the target original string. At the same time, it can correctly convert adjacent target original text with fixed collocation relationships through the dictionary tree, further improving the accuracy of the conversion.

[0118] In one embodiment, generating the text conversion result of the target original string based on the target converted text includes:

[0119] When there is no next target original text in the target original string, the conversion attribute values ​​in the conversion array are concatenated to obtain the text conversion result of the target original string.

[0120] When there is no next target original text in the target original string, that is, when every target original text in the target original string has been traversed, the conversion attribute values ​​in the conversion array can be concatenated to obtain the text conversion result of the target original string. The concatenation order can be the order in which the conversion attribute values ​​are written into the conversion array. After the concatenation is completed, the text conversion result can be verified to obtain the final text conversion result. Verification may include grammar correction, word order adjustment, etc.

[0121] Figure 3 This is a schematic diagram illustrating the overall execution process of a text conversion method provided in this embodiment of the disclosure, as shown below. Figure 3As shown, the original conversion file in the original format can be obtained first. The original conversion file can be divided into three txt documents according to the conversion type: Traditional Chinese -> Simplified Chinese (characters), Traditional Chinese -> Simplified Chinese (words), and Simplified Chinese -> Traditional Chinese (characters). The original characters or words (i.e., the original string) are placed at the beginning of the txt document, and the target characters (i.e., the conversion string) are placed at the end.

[0122] Taking Traditional Chinese to Simplified Chinese (characters) conversion as an example, the TSCharacters document (i.e., the document corresponding to Traditional Chinese to Simplified Chinese (characters)) can be stored in the following format: each line represents a group of corresponding conversion characters (i.e., the original string and the corresponding conversion string), and a group of characters is separated by tabs, with the former being Traditional Chinese characters and the latter being Simplified Chinese characters. When one Traditional Chinese character may correspond to multiple Simplified Chinese characters, the multiple Simplified Chinese characters can be separated by spaces.

[0123] 1. History

[0124] 2. Dry Dry Dry

[0125] Taking Traditional Chinese to Simplified Chinese (words) as an example, a TSPhrases document (i.e., the document corresponding to Traditional Chinese to Simplified Chinese (words)) can be stored in the following format: the word document is similar to the character document, and can also be separated by tabs on a single line. The former contains Traditional Chinese words, and the latter contains Simplified Chinese words. Unlike the one-to-many correspondence of characters, words are generally one-to-one.

[0126] 1. Dry and crispy

[0127] 2. Heaven and Earth

[0128] Taking Simplified Chinese -> Traditional Chinese (characters) as an example, the STCharacters document (i.e., the document corresponding to Simplified Chinese -> Traditional Chinese (characters)) can be stored in the following format, which is similar to the document of Traditional Chinese -> Simplified Chinese (characters), where the former is the Simplified Chinese character set and the latter is the Traditional Chinese character set.

[0129] 1 each

[0130] 2 Abundant

[0131] At the same time, administrators can also add new simplified and traditional characters verified during the reading of ancient books to the end of the corresponding documents to expand the font.

[0132] Then, the original conversion file is converted into a JSON file (i.e., the target conversion file with the preset format is obtained). Since the txt file cannot be directly imported by the front-end code, the content of the txt document needs to be read out and stored in the JSON file for easy loading and use by the front-end.

[0133] Figure 4 This is a schematic diagram of a process for obtaining a target conversion file provided in an embodiment of the present disclosure, such as... Figure 4 As shown, an empty object (i.e., a basic object) is created first, then the document content of a txt document is read, split into lines, the original character and the target character (i.e., the original string and the corresponding converted string) are split from each line. The original character and the target character are combined by a space, and the result of each line is spliced through "|" (that is, splicing each original string and the converted string corresponding to each original string in the current original conversion file according to a preset splicing rule to obtain the conversion content corresponding to the current original conversion file); then the splicing result is used as the value, the document type is used as the keyword, and inserted into the empty object. By analogy, after traversing the txt documents of three document types, a JSON file can be obtained after the traversal (that is, the conversion types corresponding to each original conversion file and the conversion content corresponding to each original conversion file are correspondingly written into the basic object to obtain the target conversion file in a preset format).

[0134] For example, the record form of the JSON file is as follows:

[0135] 1{

[0136] 2"STCharacters":"个個,箇|丰豐,丰",

[0137] 3"TSCharacters":"歷历|乾干,乾",

[0138] 4"TSPhrases":"乾乾脆脆干干脆脆|乾坤乾坤",

[0139] 5}

[0140] Then, the conversion file is loaded and a dictionary library is created (that is, a trie is constructed according to the target conversion file), Figure 5 it is a structural schematic diagram of a trie provided by an embodiment of the present disclosure, as shown in Figure 5 , each path corresponds to a Unicode of an original character (not shown in the figure), each node except the root node contains a conversion attribute, and the attribute value of the conversion attribute is used as the conversion value corresponding to the original character on the path from the root node to the current node. For document types STCharacters and TSCharacters, only a two-layer tree (including the root node) will be generated respectively, and for the document type TSPhrases, it will be split into multiple layers according to the original word, Figure 5 take constructing a trie based on the TSPhrases document as an example.

[0141] In this embodiment, a trie corresponding to the conversion type can be constructed according to the target conversion file, for example, a target trie corresponding to the target conversion type can be constructed according to the target conversion file.

[0142] Figure 6This is a schematic diagram of a process for constructing a trie according to an embodiment of the present disclosure, such as... Figure 6 As shown, firstly, a trie map is created based on the conversion type (i.e., a basic trie corresponding to the target conversion type is constructed). The corresponding value is read from the JSON file (i.e., the conversion content corresponding to the target conversion type is obtained from the target conversion file, where the conversion content contains at least one original string and at least one conversion string corresponding to the original string). The value is then split by | to obtain the lines array. The lines array is traversed, and for each line, the corresponding s and v substrings are split by spaces (i.e., the conversion content is split to obtain each original string contained in the conversion content and the conversion string corresponding to each original string).

[0143] Then, obtain the root node map1 of the trie (i.e., the root node of the trie is used as map1), traverse each string s (i.e., the original string), for example, for each string s, take the first original character in the string s (e.g., the character c) as the second current character, obtain the Unicode of the character c, search for the nextMap (i.e., the second child node) corresponding to the Unicode of the character c in the child nodes of map1, check if the nextMap exists (i.e., check if the second current node has a second child node corresponding to the second current character), if it exists, then map1 is set to point to tmp (i.e., the second child node is used as map1), continue to search for the nextMap corresponding to the Unicode of the next character in the child nodes of map1 (i.e., take the next original character in the current string as the second current character, and return to execute the operation of checking if the second current node has a second child node corresponding to the second current character, until there is no next original character in the current string);

[0144] If it does not exist, create a new node tmp (that is, create a second child node corresponding to the second current text for the second current node), with cp as the key and tmp as the specific value (such as using the Unicode corresponding to the second current text as the key and the original string corresponding to the node as the value), add it to map1, and continue to traverse the next character (that is, take the next original text in the current string as the second current text, take the second child node as the second current node, and return to perform the operation of checking whether the second current node has a second child node corresponding to the second current text, until there is no next original text in the current string).

[0145] When the traversal ends (there is no next original text in the current string), the second current node is taken as the node corresponding to the current string, and the transformation string corresponding to the current string is taken as the transformation attribute value of the node corresponding to the current string, so as to update the current trie; after traversing each s string (i.e. the original string), the updated current trie is taken as the target trie.

[0146] Finally, the conversion process based on the target original string can be implemented. Upon receiving a conversion instruction for the target original string, in response to the conversion instruction, at least one target original text is converted based on the target trie to obtain the target converted text, and the text conversion result of the target original string is generated based on the target converted text.

[0147] Figure 7 This is a schematic diagram of a process for converting a target raw string according to an embodiment of the present disclosure, such as... Figure 7 The conversion process involves iterating through each character (i.e., the target original string) of the input original string (i.e., the target original text), searching for that character in the trie, and storing the corresponding conversion value in the array `arr` if a conversion value is found (i.e., writing the conversion attribute value into the conversion array); otherwise, storing the original character, adjusting the traversal position to the path in the trie plus the current position (i.e., using the found path length plus the current position to get the new traversal position), and starting to traverse the next character, with the specific traversal process being similar. Finally, after the traversal is complete, the array `arr` is concatenated into a string, and the string is output, i.e., the stored characters are concatenated and then output. Because all original characters are traversed only once, this process has a time complexity of O(L) (L is the length of the original string).

[0148] Figure 8 This is a schematic diagram of a text conversion device provided in an embodiment of the present disclosure. The device is applicable to situations where text conversion is required. The device can be implemented by software and / or hardware and is generally integrated into an electronic device.

[0149] like Figure 8 As shown, the device includes:

[0150] The receiving module 310 is configured to receive a conversion instruction for a target original string, wherein the target original string contains at least one target original character;

[0151] The response module 320 is configured to respond to the conversion instruction by performing text conversion on the at least one target original text based on the target dictionary tree to obtain the target converted text, wherein the target dictionary tree is a dictionary tree corresponding to the target conversion type of the target original string, and the target conversion type includes traditional Chinese to simplified Chinese and / or simplified Chinese to traditional Chinese;

[0152] The generation module 330 is used to generate the text conversion result of the target original string based on the target converted text.

[0153] This disclosure provides a text conversion device that receives a conversion instruction for a target original string via a receiving module 310, wherein the target original string contains at least one target original character; responding to the conversion instruction via a response module 320, the device performs text conversion on the at least one target original character based on a target dictionary to obtain a target converted character, wherein the target dictionary is a dictionary corresponding to a target conversion type of the target original string, and the target conversion type includes traditional Chinese to simplified Chinese and / or simplified Chinese to traditional Chinese; and a generation module 330 generates a text conversion result of the target original string based on the target converted character. Using this device, upon receiving a conversion instruction, text conversion is performed directly on at least one target original character based on the target dictionary, eliminating the need for multiple searches in multiple databases or lists, thus improving the efficiency and accuracy of text conversion.

[0154] Optionally, the response module 320 includes:

[0155] The search unit is used to sequentially search for target converted text that matches the at least one target original text in the target original string according to the arrangement order of the at least one target original text in the target original string.

[0156] Optionally, each edge in the target trie corresponds to an original text; for each node in the target trie, the original string corresponding to the node is composed of the original text corresponding to each edge in the path from the root node of the target trie to the node, and the transformation attribute value of the node is the transformation string corresponding to the original string of the node.

[0157] Optionally, the search unit is specifically used for:

[0158] The first target original text in the target original string is taken as the first current text;

[0159] The root node of the target trie is taken as the first current node;

[0160] Determine whether the first current node has a first child node corresponding to the first current text;

[0161] If so, then the first child node is taken as the first current node, the next target original text in the target original string is taken as the first current text, and the operation of determining whether the first current node has a first child node corresponding to the first current text is returned until there is no next target original text in the target original string.

[0162] If not, the transformation attribute value of the first current node is written into the transformation array, and the operation of taking the root node in the target trie as the first current node is returned, until there is no next target original text in the target original string.

[0163] Optionally, the search unit is used for:

[0164] If the first current node has a transformation attribute value, then write the transformation attribute value of the first current node into the transformation array.

[0165] Optionally, the search unit is further configured to:

[0166] If the first current node does not have a conversion attribute value, then the target node in the target path that is closest to the first current node and has a conversion attribute value is taken as the first current node, the first current text in the target original string when the target node is taken as the first current node is taken as the first current text, and the conversion attribute value of the first current node is written into the conversion array.

[0167] Optionally, the generation module 330 includes:

[0168] When there is no next target original text in the target original string, the conversion attribute values ​​in the conversion array are concatenated to obtain the text conversion result of the target original string.

[0169] Optionally, the text conversion apparatus provided in this embodiment of the present disclosure further includes:

[0170] The acquisition module is used to acquire a target conversion file in a preset format before receiving the conversion instruction for the target original string, wherein the target conversion file is used to record the conversion strings corresponding to different original strings, and the original strings contain at least one original character;

[0171] A construction module is used to construct a trie based on the target conversion file, wherein the trie includes the target trie.

[0172] Optionally, the acquisition module is specifically used for:

[0173] Obtain the original conversion file in the original format and create a base object, wherein the original conversion file includes a first original conversion file and / or a second original conversion file, the first original conversion file corresponds to the conversion type from traditional Chinese to simplified Chinese, and the second original conversion file corresponds to the conversion type from simplified Chinese to traditional Chinese;

[0174] For each original conversion file, identify each original string in the current original conversion file and the corresponding conversion string for each original string;

[0175] According to the preset concatenation rules, each original string in the current original conversion file and the corresponding conversion string of each original string are concatenated to obtain the conversion content corresponding to the current original conversion file.

[0176] The conversion type and conversion content of each original conversion file are written into the base object to obtain the target conversion file in the preset format.

[0177] Optionally, the building module includes:

[0178] The construction unit is used to construct a target dictionary tree corresponding to the target conversion type based on the target conversion file.

[0179] Optionally, the building unit includes:

[0180] The first construction subunit is used to construct a basic trie corresponding to the target conversion type and obtain the conversion content corresponding to the target conversion type from the target conversion file, wherein the conversion content contains at least one original string and a conversion string corresponding to the at least one original string;

[0181] The second construction subunit is used to create a node corresponding to each original string in the basic trie, and use the transformed string corresponding to each original string as the transformation attribute value of the node corresponding to the original string to obtain the target trie.

[0182] Optionally, the text conversion apparatus provided in this embodiment of the present disclosure further includes:

[0183] The segmentation module is used to segment the transformed content before creating a node corresponding to each original string in the basic trie, so as to obtain each original string contained in the transformed content and the transformed string corresponding to each original string.

[0184] Optionally, the second building subunit is specifically used for:

[0185] The first original string in the transformed content is taken as the current string, and the basic trie is taken as the current trie, wherein each original string is sorted according to a preset rule;

[0186] Create a node in the current trie corresponding to the current string, and use the transformed string corresponding to the current string as the transformed attribute value of the node corresponding to the current string, so as to update the current trie;

[0187] Determine whether a next original string exists in the transformed content. If yes, use the next original string as the current string, use the updated current trie as the current trie, and return to execute the operation of creating a node corresponding to the current string in the current trie. If no, use the updated current trie as the target trie.

[0188] Optionally, the second building subunit is specifically used for:

[0189] The first original character in the current string is taken as the second current character, and the root node of the current trie is taken as the second current node;

[0190] Determine whether the second current node has a second child node corresponding to the second current text;

[0191] If so, then the next original text in the current string is taken as the second current text, the second child node is taken as the second current node, and the operation of determining whether the second current node has a second child node corresponding to the second current text is returned until there is no next original text in the current string.

[0192] If not, then create a second child node corresponding to the second current text for the second current node, take the next original text in the current string as the second current text, take the second child node as the second current node, and return to execute the operation of judging whether the second current node has a second child node corresponding to the second current text, until there is no next original text in the current string;

[0193] When there is no next original text in the current string, the second current node is taken as the node corresponding to the current string.

[0194] The above-described text conversion device can execute the text conversion method provided in any embodiment of this disclosure, and has the corresponding functional modules and beneficial effects of executing the method.

[0195] The following is for reference. Figure 9This diagram illustrates a structural schematic of an electronic device 400 suitable for implementing embodiments of the present disclosure. The terminal devices in these embodiments may include, but are not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 9 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.

[0196] like Figure 9 As shown, electronic device 400 may include a processing device (e.g., a central processing unit, a graphics processor, etc.) 401, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 402 or a program loaded from storage device 408 into random access memory (RAM) 403. RAM 403 also stores various programs and data required for the operation of electronic device 400. Processing device 401, ROM 402, and RAM 403 are interconnected via bus 404. Input / output (I / O) interface 405 is also connected to bus 404.

[0197] Typically, the following devices can be connected to I / O interface 405: input devices 406 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 407 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 408 including, for example, magnetic tapes, hard disks, etc.; and communication devices 409. Communication device 409 allows electronic device 400 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 9 An electronic device 400 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.

[0198] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication device 409, or installed from storage device 408, or installed from ROM 402. When the computer program is executed by processing device 401, it performs the functions defined in the methods of embodiments of this disclosure.

[0199] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.

[0200] In some implementations, clients and servers can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol) and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet of Things), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future-developed networks.

[0201] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.

[0202] The aforementioned computer-readable medium carries one or more programs that, when executed by the electronic device, cause the electronic device to: receive a conversion instruction for a target raw string, wherein the target raw string contains at least one target raw text;

[0203] In response to the conversion instruction, the at least one target original text is converted based on the target dictionary to obtain the target converted text, wherein the target dictionary is a dictionary corresponding to the target conversion type of the target original string, and the target conversion type includes traditional Chinese to simplified Chinese and / or simplified Chinese to traditional Chinese;

[0204] The text conversion result of the original target string is generated based on the target text.

[0205] Computer program code for performing the operations of this disclosure can be written in one or more programming languages ​​or a combination thereof, including but not limited to object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0206] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0207] The units described in the embodiments of this disclosure can be implemented in software or hardware. The names of modules do not, in some cases, constitute a limitation on the unit itself.

[0208] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.

[0209] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0210] According to one or more embodiments of this disclosure, Example 1 provides a text conversion method, including:

[0211] Receive a conversion instruction for a target raw string, wherein the target raw string contains at least one target raw text;

[0212] In response to the conversion instruction, the at least one target original text is converted based on the target dictionary to obtain the target converted text, wherein the target dictionary is a dictionary corresponding to the target conversion type of the target original string, and the target conversion type includes traditional Chinese to simplified Chinese and / or simplified Chinese to traditional Chinese;

[0213] The text conversion result of the original target string is generated based on the target text.

[0214] According to one or more embodiments of this disclosure, Example 2, based on the method described in Example 1, involves performing text conversion on the at least one target original text based on a target trie to obtain target converted text, including:

[0215] According to the order in which the at least one target original text is arranged in the target original string, the target converted text that matches the at least one target original text is sequentially searched in the target trie.

[0216] According to one or more embodiments of this disclosure, Example 3 describes the method described in Example 2, in which each edge in the target trie corresponds to an original text; for each node in the target trie, the original string corresponding to the node is composed of the original text corresponding to each edge in the path from the root node of the target trie to the node, and the conversion attribute value of the node is the conversion string corresponding to the original string of the node.

[0217] According to one or more embodiments of this disclosure, Example 4, based on the method described in Example 3, sequentially searches for target converted text matching the at least one target original text in the target original string according to the order of the at least one target original text in the target original string, including:

[0218] The first target original text in the target original string is taken as the first current text;

[0219] The root node of the target trie is taken as the first current node;

[0220] Determine whether the first current node has a first child node corresponding to the first current text;

[0221] If so, then the first child node is taken as the first current node, the next target original text in the target original string is taken as the first current text, and the operation of determining whether the first current node has a first child node corresponding to the first current text is returned until there is no next target original text in the target original string.

[0222] If not, the transformation attribute value of the first current node is written into the transformation array, and the operation of taking the root node in the target trie as the first current node is returned, until there is no next target original text in the target original string.

[0223] According to one or more embodiments of this disclosure, Example 5 describes the method described in Example 4, wherein writing the transformation attribute value of the first current node into the transformation array includes:

[0224] If the first current node has a transformation attribute value, then write the transformation attribute value of the first current node into the transformation array.

[0225] According to one or more embodiments of this disclosure, Example 6, based on the method described in Example 5, further includes writing the transformation attribute value of the first current node into the transformation array:

[0226] If the first current node does not have a conversion attribute value, then the target node in the target path that is closest to the first current node and has a conversion attribute value is taken as the first current node, the first current text in the target original string when the target node is taken as the first current node is taken as the first current text, and the conversion attribute value of the first current node is written into the conversion array.

[0227] According to one or more embodiments of this disclosure, Example 7 describes the method described in Example 4, wherein generating the text conversion result of the target original string based on the target converted text includes:

[0228] When there is no next target original text in the target original string, the conversion attribute values ​​in the conversion array are concatenated to obtain the text conversion result of the target original string.

[0229] According to one or more embodiments of this disclosure, Example 8, based on any one of Examples 1-7, further includes, before receiving the conversion instruction for the target original string:

[0230] Obtain a target conversion file in a preset format, wherein the target conversion file is used to record the conversion strings corresponding to different original strings, and the original strings contain at least one original text.

[0231] A trie is constructed based on the target conversion file, wherein the trie includes the target trie.

[0232] According to one or more embodiments of this disclosure, Example 9 describes the method described in Example 8, wherein obtaining the target conversion file in a preset format includes:

[0233] Obtain the original conversion file in the original format and create a base object, wherein the original conversion file includes a first original conversion file and / or a second original conversion file, the first original conversion file corresponds to the conversion type from traditional Chinese to simplified Chinese, and the second original conversion file corresponds to the conversion type from simplified Chinese to traditional Chinese;

[0234] For each original conversion file, identify each original string in the current original conversion file and the corresponding conversion string for each original string;

[0235] According to the preset concatenation rules, each original string in the current original conversion file and the corresponding conversion string of each original string are concatenated to obtain the conversion content corresponding to the current original conversion file.

[0236] The conversion type and conversion content of each original conversion file are written into the base object to obtain the target conversion file in the preset format.

[0237] According to one or more embodiments of this disclosure, Example 10 describes the method described in Example 8, wherein constructing a trie based on the target conversion file includes:

[0238] Construct a target dictionary tree corresponding to the target transformation type based on the target transformation file.

[0239] According to one or more embodiments of this disclosure, Example 11, based on the method described in Example 10, includes constructing a target trie corresponding to the target conversion type based on the target conversion file, comprising:

[0240] Construct a basic trie corresponding to the target conversion type, and obtain the conversion content corresponding to the target conversion type from the target conversion file, wherein the conversion content contains at least one original string and a conversion string corresponding to the at least one original string;

[0241] In the basic trie, a node corresponding to each original string is created, and the transformed string corresponding to each original string is used as the transformation attribute value of the node corresponding to the original string, thus obtaining the target trie.

[0242] According to one or more embodiments of this disclosure, Example 12, based on the method described in Example 11, further includes, before creating a node corresponding to each original string in the basic trie:

[0243] The converted content is segmented to obtain each original string contained in the converted content and the corresponding converted string.

[0244] According to one or more embodiments of this disclosure, Example 13 describes the method described in Example 11, wherein creating a node corresponding to each original string in the basic trie and using the transformed string corresponding to each original string as the transformed attribute value of the node corresponding to the corresponding original string to obtain the target trie includes:

[0245] The first original string in the transformed content is taken as the current string, and the basic trie is taken as the current trie, wherein each original string is sorted according to a preset rule;

[0246] Create a node in the current trie corresponding to the current string, and use the transformed string corresponding to the current string as the transformed attribute value of the node corresponding to the current string, so as to update the current trie;

[0247] Determine whether a next original string exists in the transformed content. If yes, use the next original string as the current string, use the updated current trie as the current trie, and return to execute the operation of creating a node corresponding to the current string in the current trie. If no, use the updated current trie as the target trie.

[0248] According to one or more embodiments of this disclosure, Example 14, based on the method described in Example 13, includes creating a node corresponding to the current string in the current trie, comprising:

[0249] The first original character in the current string is taken as the second current character, and the root node of the current trie is taken as the second current node;

[0250] Determine whether the second current node has a second child node corresponding to the second current text;

[0251] If so, then the next original text in the current string is taken as the second current text, the second child node is taken as the second current node, and the operation of determining whether the second current node has a second child node corresponding to the second current text is returned until there is no next original text in the current string.

[0252] If not, then create a second child node corresponding to the second current text for the second current node, take the next original text in the current string as the second current text, take the second child node as the second current node, and return to execute the operation of judging whether the second current node has a second child node corresponding to the second current text, until there is no next original text in the current string;

[0253] When there is no next original text in the current string, the second current node is taken as the node corresponding to the current string.

[0254] According to one or more embodiments of this disclosure, Example 15 provides a text conversion apparatus, including:

[0255] A receiving module is configured to receive a conversion instruction for a target raw string, wherein the target raw string contains at least one target raw character;

[0256] A response module is configured to respond to the conversion instruction by performing text conversion on the at least one target original text based on the target dictionary to obtain the target converted text, wherein the target dictionary is a dictionary corresponding to the target conversion type of the target original string, and the target conversion type includes traditional Chinese to simplified Chinese and / or simplified Chinese to traditional Chinese;

[0257] The generation module is used to generate the text conversion result of the original target string based on the target text to be converted.

[0258] According to one or more embodiments of this disclosure, Example 16 provides an electronic device comprising:

[0259] One or more processors;

[0260] Memory, used to store one or more programs.

[0261] When the one or more programs are executed by the one or more processors, the one or more processors implement the text conversion method as described in any of Examples 1-14.

[0262] According to one or more embodiments of the present disclosure, Example 17 provides a computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the text conversion method as described in any of Examples 1-14.

[0263] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.

[0264] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.

[0265] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.

Claims

1. A text conversion method, characterized in that, include: Receive a conversion instruction for a target raw string, wherein the target raw string contains at least one target raw text; In response to the conversion instruction, the at least one target original text is converted based on the target dictionary to obtain the target converted text, wherein the target dictionary is a dictionary corresponding to the target conversion type of the target original string, and the target conversion type includes traditional Chinese to simplified Chinese and / or simplified Chinese to traditional Chinese; Generate the text conversion result of the original target string based on the target text; The step of converting the at least one target original text based on the target trie to obtain the target converted text includes: The first target original text in the target original string is taken as the first current text; The root node of the target trie is taken as the first current node; Determine whether the first current node has a first child node corresponding to the first current text; If so, then the first child node is taken as the first current node, the next target original text in the target original string is taken as the first current text, and the operation of determining whether the first current node has a first child node corresponding to the first current text is returned until there is no next target original text in the target original string. If not, the transformation attribute value of the first current node is written into the transformation array, and the operation of taking the root node in the target trie as the first current node is returned, until there is no next target original text in the target original string.

2. The method according to claim 1, characterized in that, Each edge in the target trie corresponds to an original text; for each node in the target trie, the original string corresponding to the node is composed of the original text corresponding to each edge in the path from the root node of the target trie to the node, and the transformation attribute value of the node is the transformation string corresponding to the original string of the node.

3. The method according to claim 1, characterized in that, The step of writing the transformation attribute value of the first current node into the transformation array includes: If the first current node has a transformation attribute value, then write the transformation attribute value of the first current node into the transformation array.

4. The method according to claim 3, characterized in that, The step of writing the transformation attribute value of the first current node into the transformation array further includes: If the first current node does not have a conversion attribute value, then the target node in the target path that is closest to the first current node and has a conversion attribute value is taken as the first current node, the first current text in the target original string when the target node is taken as the first current node is taken as the first current text, and the conversion attribute value of the first current node is written into the conversion array.

5. The method according to claim 1, characterized in that, The step of generating the text conversion result of the target original string based on the target converted text includes: When there is no next target original text in the target original string, the conversion attribute values ​​in the conversion array are concatenated to obtain the text conversion result of the target original string.

6. The method according to any one of claims 1-5, characterized in that, Before receiving the conversion instruction for the target original string, the method further includes: Obtain a target conversion file in a preset format, wherein the target conversion file is used to record the conversion strings corresponding to different original strings, and the original strings contain at least one original text. A trie is constructed based on the target conversion file, wherein the trie includes the target trie.

7. The method according to claim 6, characterized in that, The process of obtaining the target conversion file in the preset format includes: Obtain the original conversion file in the original format and create a base object, wherein the original conversion file includes a first original conversion file and / or a second original conversion file, the first original conversion file corresponds to the conversion type from traditional Chinese to simplified Chinese, and the second original conversion file corresponds to the conversion type from simplified Chinese to traditional Chinese; For each original conversion file, identify each original string in the current original conversion file and the corresponding conversion string for each original string; According to the preset concatenation rules, each original string in the current original conversion file and the corresponding conversion string of each original string are concatenated to obtain the conversion content corresponding to the current original conversion file. The conversion type and conversion content of each original conversion file are written into the base object to obtain the target conversion file in the preset format.

8. The method according to claim 6, characterized in that, The step of constructing a trie based on the target conversion file includes: Construct a target dictionary tree corresponding to the target transformation type based on the target transformation file.

9. The method according to claim 8, characterized in that, The step of constructing a target trie corresponding to the target conversion type based on the target conversion file includes: Construct a basic trie corresponding to the target conversion type, and obtain the conversion content corresponding to the target conversion type from the target conversion file, wherein the conversion content contains at least one original string and a conversion string corresponding to the at least one original string; In the basic trie, a node corresponding to each original string is created, and the transformed string corresponding to each original string is used as the transformation attribute value of the node corresponding to the original string, thus obtaining the target trie.

10. The method according to claim 9, characterized in that, Before creating the node corresponding to each original string in the basic trie, the process also includes: The converted content is segmented to obtain each original string contained in the converted content and the corresponding converted string.

11. The method according to claim 9, characterized in that, The step of creating a node corresponding to each original string in the basic trie and using the transformed string corresponding to each original string as the transformed attribute value of the node corresponding to the original string to obtain the target trie includes: The first original string in the transformed content is taken as the current string, and the basic trie is taken as the current trie, wherein each original string is sorted according to a preset rule; Create a node in the current trie corresponding to the current string, and use the transformed string corresponding to the current string as the transformed attribute value of the node corresponding to the current string, so as to update the current trie; Determine whether a next original string exists in the transformed content. If yes, use the next original string as the current string, use the updated current trie as the current trie, and return to execute the operation of creating a node corresponding to the current string in the current trie. If no, use the updated current trie as the target trie.

12. The method according to claim 11, characterized in that, Creating a node corresponding to the current string in the current trie includes: The first original character in the current string is taken as the second current character, and the root node of the current trie is taken as the second current node; Determine whether the second current node has a second child node corresponding to the second current text; If so, then the next original text in the current string is taken as the second current text, the second child node is taken as the second current node, and the operation of determining whether the second current node has a second child node corresponding to the second current text is returned until there is no next original text in the current string. If not, then create a second child node corresponding to the second current text for the second current node, take the next original text in the current string as the second current text, take the second child node as the second current node, and return to execute the operation of judging whether the second current node has a second child node corresponding to the second current text, until there is no next original text in the current string; When there is no next original text in the current string, the second current node is taken as the node corresponding to the current string.

13. A text conversion device, characterized in that, include: A receiving module is configured to receive a conversion instruction for a target raw string, wherein the target raw string contains at least one target raw character; A response module is configured to respond to the conversion instruction by performing text conversion on the at least one target original text based on the target dictionary to obtain the target converted text, wherein the target dictionary is a dictionary corresponding to the target conversion type of the target original string, and the target conversion type includes traditional Chinese to simplified Chinese and / or simplified Chinese to traditional Chinese; The generation module is used to generate the text conversion result of the original target string based on the target text to be converted; The response module is specifically used for: The first target original text in the target original string is taken as the first current text; The root node of the target trie is taken as the first current node; Determine whether the first current node has a first child node corresponding to the first current text; If so, then the first child node is taken as the first current node, the next target original text in the target original string is taken as the first current text, and the operation of determining whether the first current node has a first child node corresponding to the first current text is returned until there is no next target original text in the target original string. If not, the transformation attribute value of the first current node is written into the transformation array, and the operation of taking the root node in the target trie as the first current node is returned, until there is no next target original text in the target original string.

14. An electronic device, characterized in that, include: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the text conversion method according to any one of claims 1-12.

15. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that cause a processor to execute the text conversion method according to any one of claims 1-12.

Citation Information

Patent Citations

  • Method and system for mutual conversion between simplified Chinese characters and traditional Chinese characters

    CN101131690A

  • Method and system for realizing conversion of simplified and traditional Chinese characters in rich text editor

    CN102929852A