CN110442843B - Character replacement method, system, computer device and computer readable storage medium - Google Patents

Character replacement method, system, computer device and computer readable storage medium Download PDF

Info

Publication number
CN110442843B
CN110442843B CN201910553284.XA CN201910553284A CN110442843B CN 110442843 B CN110442843 B CN 110442843B CN 201910553284 A CN201910553284 A CN 201910553284A CN 110442843 B CN110442843 B CN 110442843B
Authority
CN
China
Prior art keywords
characters
character
query
replacement
searched
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910553284.XA
Other languages
Chinese (zh)
Other versions
CN110442843A (en
Inventor
刘益伟
杨茂星
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN201910553284.XA priority Critical patent/CN110442843B/en
Priority to PCT/CN2019/117404 priority patent/WO2020258652A1/en
Publication of CN110442843A publication Critical patent/CN110442843A/en
Application granted granted Critical
Publication of CN110442843B publication Critical patent/CN110442843B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/903Querying
    • G06F16/90335Query processing
    • G06F16/90344Query processing by using string matching techniques

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Document Processing Apparatus (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the invention provides a character replacement method, which comprises the following steps: acquiring N query characters and N replacement characters input by a user, wherein the N query characters comprise at least two identical query characters, and the N replacement characters comprise at least two different replacement characters; searching whether characters matched with the query characters exist in text information by taking the query characters as query conditions; and when the characters matched with the query characters exist, correspondingly replacing the searched characters with the replacement characters according to the positions of the searched characters in the text information. The embodiment of the invention also provides a character replacement system, computer equipment and a computer storage medium. The embodiment of the invention can realize that a plurality of identical original characters are replaced by different new characters at the same time, and the operations of inputting, searching and replacing each original character are not needed to be carried out again, thereby reducing the complexity of character replacement.

Description

Character replacement method, system, computer device and computer readable storage medium
Technical Field
The embodiment of the invention relates to the technical field of data processing, in particular to a character replacement method, a character replacement system, computer equipment and a computer readable storage medium.
Background
When editing text, if the character is to be replaced, it is usually aimed at a certain original character to be replaced and the original character is used as a query condition, the text information of the whole editing area is traversed to search for the corresponding original character, and the new character is used to replace the searched original character. When a plurality of identical original characters in the text information are required to be replaced by different new characters, the steps of searching and replacing are required to be respectively carried out aiming at each identical original character, and the plurality of times of searching and replacing operations are required, so that the plurality of identical original characters cannot be replaced by different new characters at the same time, and the complexity of character replacement is increased.
Disclosure of Invention
In view of the above, an object of the embodiments of the present invention is to provide a character replacing method, a system, a computer device and a computer readable storage medium, which can replace a plurality of identical original characters with different new characters at the same time, so as to reduce complexity of character replacement.
In order to achieve the above object, an embodiment of the present invention provides a character replacement method, including the steps of:
Acquiring N query characters and N replacement characters input by a user, wherein the N query characters comprise at least two identical query characters, the N replacement characters comprise at least two different replacement characters, and N is a natural number greater than or equal to 2;
Searching whether characters matched with the query characters exist in text information by taking the query characters as query conditions; and
When the characters matched with the query characters exist, replacing the searched character correspondence with the replacement characters according to the positions of the searched characters in the text information, wherein the replacing the searched character correspondence with the replacement characters specifically comprises:
Sequentially acquiring one of the replacement characters, and replacing the searched character with the acquired replacement character;
judging whether the obtained sentence containing the replacement character is legal or not by using a preset semantic model;
And if the character is legal, taking the obtained replacement character as a target replacement character to replace the searched character.
Further, when there is a character matching the query character, the step of replacing the found character with the replacement character according to the position of the found character in the text information includes:
When characters matched with the query characters exist, judging whether the number of the searched characters is the same as the number of the query characters; and
And if the number of the searched characters is the same as that of the query characters, correspondingly replacing the searched characters with the replacement characters according to the positions of the searched characters in the text information.
Further, after the step of determining whether the number of the searched characters is the same as the number of the query characters, the method further includes:
and outputting prompt information when the number of the searched characters is less than the number of the query characters.
Further, after the step of determining whether the number of the searched characters is the same as the number of the query characters, the method further includes:
When the number of the searched characters is smaller than the number of the query characters, the searched characters are correspondingly replaced with the replacement characters according to the positions of the searched characters in the text information.
Further, when searching for the characters matched with the query characters in the text information, if the matching characters with the same number as the query characters are searched for in the text information, executing the step of replacing the searched characters with the replacement characters according to the positions of the searched characters in the text information.
Further, the query character further includes location information of a character to be replaced, and the step of searching for whether a character matching the query character exists in the text information by taking the query character as a query condition includes:
and searching whether characters matched with the query characters exist in the text information according to the position information by taking the query characters as query conditions.
Further, the character replacing method further includes:
an input interface is provided for a user to input the query character and the replacement character.
To achieve the above object, an embodiment of the present invention further provides a computer apparatus including a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the steps of the character replacement method as described above when executing the computer program.
In order to achieve the above object, an embodiment of the present invention further provides a character replacement system, including:
The acquisition module is used for acquiring N query characters and N replacement characters input by a user, wherein the N query characters comprise at least two identical query characters, the number of the N replacement characters is identical to that of the query characters, the replacement characters comprise at least two different replacement characters, and N is a natural number greater than or equal to 2;
the searching module is used for searching whether characters matched with the query characters exist in the text information by taking the query characters as query conditions; and
The replacing module is used for replacing the searched character with the replacing character according to the position of the searched character in the text information when the character matched with the query character exists, wherein the replacing of the searched character with the replacing character is specifically as follows:
Sequentially acquiring one of the replacement characters, and replacing the searched character with the acquired replacement character;
judging whether the obtained sentence containing the replacement character is legal or not by using a preset semantic model;
And if the character is legal, taking the obtained replacement character as a target replacement character to replace the searched character.
To achieve the above object, an embodiment of the present invention also provides a computer-readable storage medium having stored therein a computer program executable by at least one processor to cause the at least one processor to perform the steps of the character replacement method as described above.
The character replacement method, the system, the computer equipment and the computer readable storage medium provided by the embodiment of the invention are characterized in that query characters and replacement characters input by a user are obtained, wherein the query characters comprise at least two identical characters, the number of the replacement characters is identical to that of the query characters, and the replacement characters comprise at least two different characters; searching whether characters matched with the query characters exist in text information by taking the query characters as query conditions; and when the characters matched with the query characters exist, replacing the characters matched with the query characters with the replacement characters, so that a plurality of identical original characters can be replaced with different new characters at the same time, and the operations of inputting, searching and replacing each original character are not required to be carried out again, thereby reducing the complexity of character replacement.
Drawings
FIG. 1 is a flowchart illustrating a character replacement method according to a first embodiment of the present invention.
Fig. 2 is a schematic flow chart of a second embodiment of the character replacing method according to the present invention.
FIG. 3 is a flowchart illustrating a character replacement method according to a third embodiment of the present invention.
Fig. 4 is a schematic flow chart of a fourth embodiment of the character replacing method according to the present invention.
FIG. 5 is a schematic diagram of a program module of a character replacement system according to an embodiment of the invention.
Fig. 6 is a schematic hardware structure of a computer device according to an embodiment of the invention.
Reference numerals
The achievement of the objects, functional features and advantages of the present invention will be further described with reference to the accompanying drawings, in conjunction with the embodiments.
Detailed Description
The present invention will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present invention more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Referring to FIG. 1, a flow chart of a character replacement method according to a first embodiment of the invention is shown. It will be appreciated that the flow charts in the method embodiments are not intended to limit the order in which the steps are performed. An exemplary description will be made below with a character substitution system (hereinafter, "substitution system" for short) as an execution subject, which can be applied to a computer device. The method comprises the following steps:
Step S100, N query characters and N replacement characters input by a user are obtained, wherein the N query characters comprise at least two identical query characters, the number of the N replacement characters is identical to that of the query characters, the replacement characters comprise at least two different replacement characters, and N is a natural number greater than or equal to 2.
Specifically, when the text information is edited by the text editing tool, when a plurality of original characters in the text information need to be replaced, query characters and replacement characters input by a user are acquired. In this embodiment, the query character is a character to be replaced in the text information, and the query character includes at least two identical characters, for example, the text information includes a character "abcdefgab", and if the user wants to replace two characters "a" in the text information at one time, the two characters "a" are the query characters. The replacement character is a character for replacing an original character in the text information. For example, if the user wants to replace two characters "a" in the text information with "c" and "d", that is, "cbcdefgdb", the characters "c" and "d" are the replacement characters. In this embodiment, the replacement character comprises at least two different characters.
In an embodiment, when the query character is input, a plurality of identical characters may be directly input, or the query character may be represented by inputting only one character and a character representing the number of the characters. Examples are as follows:
When the query character is input, "a" may be input; a, A is as follows; a, A is as follows; a ", or" A;4", etc. In this embodiment, when the query character is input, the input plurality of characters may be separated by a separator for separating, where the separator may be a punctuation mark such as comma, semicolon, or pause sign, or a symbol such as space and line feed symbol formed by clicking a key such as space key and enter key on the keyboard. When inputting the replacement character, the plurality of characters to be input may be separated by a separator for separating.
In an embodiment, the characters may be words, letters, words, or other character units capable of composing the text information content.
And step S102, searching whether characters matched with the query characters exist in the text information by taking the query characters as query conditions.
Specifically, the query character is used as a query condition, traversal search is carried out in the text information, and whether characters matched with the query character exist or not is judged.
In an embodiment, when the text information is traversed to find the characters matched with the query characters, if the text information is searched for the characters with the same number as the query characters, whether the characters matched with the query characters are found in the text information is not continued to be found, and step S104 is directly executed, namely, the found characters are correspondingly replaced by the replacement characters according to the positions of the found characters in the text information.
Step S104, when the characters matched with the query characters exist, replacing the searched character correspondence with the replacement character according to the position of the searched character in the text information, wherein the replacing the searched character correspondence with the replacement character specifically comprises the following steps:
Sequentially acquiring one of the replacement characters, and replacing the searched character with the acquired replacement character;
judging whether the obtained sentence containing the replacement character is legal or not by using a preset semantic model;
And if the character is legal, taking the obtained replacement character as a target replacement character to replace the searched character.
Specifically, when the character matched with the query character is found, the position of the found character in the text information is obtained, and the position is the sequence information of the found character in the text information. Examples are as follows:
The text information is "abcdefgab", the matched character is "a", the position of the first searched matched character "a" in the text information is the "first position" in the text information, the position of the second searched matched character "a" in the text information is the "seventh position" in the text information, that is, the "first position" and the "seventh position" are the positions of the searched characters in the text information.
When the position of the searched character in the text information is obtained, the searched character matched with the query character is correspondingly replaced by a new character in the replacement character according to the obtained replacement character input by the user. In one embodiment, when a first original character matched with the query character is found, replacing the first original character matched with the query character with a first character in the replacement characters, and then judging whether a sentence containing the first character in the replacement characters is legal or not by using a preset semantic model, if so, taking the first character in the replacement characters as a target replacement character for replacing the first original character matched with the query character in the text information; if not, continuing to replace the first original character matched with the query character with the second character in the replacement characters, then judging whether sentences containing the second character in the replacement characters are legal or not by using the preset semantic model, and if so, taking the second character in the replacement characters as a target replacement character for replacing the first original character matched with the query character in the text information; if not, repeating the steps until the target replacement character is found.
In this embodiment, the semantic model is an n-gram model, which is a language model constructed by computing maximum likelihood estimates (Maximum Likelihood Estimate), which is also a model that can be used to compute a sentence legal probability. When judging whether the sentence is legal or not by using the model, specifically calculating the probability of sentence validity by using the model, then comparing the calculated probability with a threshold value, judging that the sentence is legal if the calculated probability is larger than the threshold value, and judging that the sentence is illegal if the calculated probability is smaller than the threshold value, wherein the threshold value can be obtained through training. It should be noted that, in this embodiment, the sentence is legal, which means that the grammar and the semantics of the sentence are reasonable, and the meaning of the sentence expression is clear and correct.
After the replacement of the first original character is completed, the query character is continuously used as a query condition, the traversal query is continuously performed in the text information from the position of acquiring the first original character to find a second character matched with the query character, when the second character matched with the query character is found, the original character matched with the query character is replaced by the character in the replacement character, and the like until the replacement of all the characters is completed, and the specific character replacement method is described in detail above and is not repeated here. In another embodiment, after the matching characters with the same number as the query characters are searched in the text information, the matching characters are replaced with each character in the replacement characters according to the positions of each searched matching character in the text information, and of course, the characters can be replaced in a parallel manner, namely, a plurality of characters can be replaced at one time or all the characters can be replaced at one time.
According to the character replacement method provided by the embodiment of the invention, the query characters and the replacement characters input by the user are obtained, wherein the query characters comprise at least two identical characters, the number of the replacement characters is identical to that of the query characters, and the replacement characters comprise at least two different characters; searching whether characters matched with the query characters exist in text information by taking the query characters as query conditions; and when the characters matched with the query characters exist, replacing the characters matched with the query characters with the replacement characters, so that a plurality of identical original characters can be replaced with different new characters at the same time, and the operations of inputting, searching and replacing each original character are not required to be carried out again, thereby reducing the complexity of character replacement.
Referring to fig. 2, a flowchart of a second embodiment of the character replacing method according to the present invention is shown. In this embodiment, the execution sequence of the steps in the flowchart shown in fig. 2 may be changed, and some steps may be omitted according to different requirements. An exemplary description will be made below with a character replacement system (hereinafter, "replacement system" for short) as an execution subject, which can be applied to a server. The method comprises the following steps:
step 200, acquiring N query characters and N replacement characters input by a user, wherein the N query characters comprise at least two identical query characters, the number of the N replacement characters is identical to that of the query characters, the replacement characters comprise at least two different replacement characters, and N is a natural number greater than or equal to 2.
And step S202, searching whether characters matched with the query characters exist in the text information by taking the query characters as query conditions.
Steps S200 to S202 are similar to steps S100 to S102, and are not repeated in this embodiment.
Step S204, when the characters matched with the query characters exist, judging whether the number of the searched characters is the same as the number of the query characters.
Specifically, when searching the characters matched with the query character in the text information, when searching the matched characters, recording what number of the matched characters is the currently searched characters so as to determine whether the number of the currently searched matched characters is enough, namely judging whether the number of the searched characters is the same as the number of the query characters.
And S206, if the number of the searched characters is the same as the number of the query characters, replacing the searched characters with the replacement characters correspondingly according to the positions of the searched characters in the text information.
Specifically, when as many matching characters as the number of the query characters are found in the text information, the found characters can be replaced with the characters in the replacement characters one by one according to the positions of the found characters in the text information.
Examples are as follows: the text information is assumed to consist of the following characters: and absdefcdabcejgalv, wherein the query character is aa, the replacement character is zm, after traversing the text information, the first searched matched character a is positioned at the first position in the text information, the second searched matched character a is positioned at the ninth position in the text information, when the searched character is replaced, the character a in the first position in the text information is replaced with the character z, then whether a sentence after replacement is legal is judged, if yes, the character z is used as a target replacement character, if not, the character a in the first position is replaced with the character m, then whether the sentence after replacement is legal is judged, and if yes, the character m is used as a target replacement character. Similarly, when the character "a" located in the ninth bit in the text information is replaced, the above replacing step is still repeated, assuming that the text information becomes "z bsdefcd m bcejgalv" after the replacement.
Further, in an embodiment, when the number of the found matching characters is found to be less than the number of the query characters when the text information is traversed, a prompt message may be output to remind the user that there are not so many matching characters in the text information. Preferably, the prompt message may prompt "the number of the matching characters is insufficient" or "please reduce the number of the query characters" in a popup window manner.
Further, in another embodiment, when the text information is traversed, the number of the searched matching characters is found to be smaller than the number of the query characters, and the searched characters can be replaced with the replacement characters according to the positions of the searched characters in the text information.
Examples are as follows: the text information is assumed to consist of the following characters: and "abcdefah", wherein the query character is "aaa", the replacement character is "zmg", after traversing the text information, the first searched matching character "a" is located at the first position in the text information, the second searched matching character "a" is located at the seventh position in the text information, and the third matching character is not found, when the searched character is replaced, the first character "a" located in the first position in the text information is replaced with the character "z", then whether the replaced sentence is legal or not is judged, if not, the character "z" is used as a target replacement character, if not, the character "a" in the first position is replaced with the character "m", then whether the replaced sentence is legal or not is judged, if not, the character "m" is used as a target replacement character, if not, the character "a" in the first position is replaced with the character "g", then whether the replaced sentence is legal or not is judged, and if not, the replaced sentence "g" is used as the target character ". Similarly, when the character "a" located in the seventh bit in the text information is replaced, the above-described replacing step is repeated, assuming that the text information becomes "z bcdefmh" after the replacement.
According to the character replacement method provided by the embodiment of the invention, before the characters are replaced, whether the text information has enough matched characters is judged, when the text information has enough matched characters, the searched matched characters are replaced by the characters in the replaced characters in a one-to-one correspondence mode, and when the text information does not have enough matched characters, a prompt message can be output to prompt a user.
Referring to fig. 3, a flowchart of a third embodiment of the character replacing method according to the present invention is shown. In this embodiment, the execution sequence of the steps in the flowchart shown in fig. 3 may be changed, and some steps may be omitted according to different requirements. An exemplary description will be made below with a character replacement system (hereinafter, "replacement system" for short) as an execution subject, which can be applied to a server. The method comprises the following steps:
Step S300, N query characters and N replacement characters input by a user are obtained, wherein the N query characters comprise at least two identical query characters, the number of the N replacement characters is identical to that of the query characters, the replacement characters comprise at least two different replacement characters, and N is a natural number greater than or equal to 2.
The step S300 is similar to the step S100, and is not repeated in the present embodiment.
And step S302, searching whether characters matched with the query characters exist in the text information according to the position information by taking the query characters as query conditions.
Specifically, the query character further includes position information of a character to be replaced, where the character to be replaced is a character in the text information, and a new character (i.e., a replacement character in the present invention) needs to be used to replace the character to be replaced. The position information is the position of the character to be replaced in the text information. In a specific embodiment, the location information in the query character is represented as follows: the query characters are "a1 and a4", and the query characters represent that the first character "a" and the 4 th character "a" in the text information need to be replaced by new characters.
When the query character is used as a query condition, through traversing searching in the text information, when the character matched with the query character is searched, whether the searched character belongs to the character matched with the query character or not is further required to be judged according to the position information.
Examples are as follows: assuming that the text information is "abcdaeaf", the query character is "a1, a4", when the first character "a" is found in the text information, the position information of the first character "a" is found to be the same as the position information of the query character, so that the first character "a" can be used as the character matched with the query character, when the second character "a" is found in the continuous search, the position information of the second character "a" is found to be different from the position information of the query character, and the second character "a" is not used as the character matched with the query character.
And step S304, when the characters matched with the query characters exist, replacing the searched characters with the replacement characters correspondingly according to the positions of the searched characters in the text information.
Step S304 is similar to step S104, and will not be described in detail in this embodiment.
According to the character replacement method provided by the embodiment of the invention, the character to be replaced is replaced more flexibly by inserting the position information of the character to be replaced into the query information.
Referring to fig. 4, a flowchart of a third embodiment of the character replacing method according to the present invention is shown. In this embodiment, the execution sequence of the steps in the flowchart shown in fig. 4 may be changed, and some steps may be omitted according to different requirements. An exemplary description will be made below with a character replacement system (hereinafter, "replacement system" for short) as an execution subject, which can be applied to a server. The method comprises the following steps:
step S400, providing an input interface for the user to input the query character and the replacement character.
Specifically, before a plurality of original characters in the text information need to be replaced, an input interface can be provided for a user through an editing tool operated currently, and the user can input the query characters and the replacement characters through the input interface.
Step S402, N query characters and N replacement characters input by a user are obtained, wherein the N query characters comprise at least two identical query characters, the number of the N replacement characters is identical to that of the query characters, the replacement characters comprise at least two different replacement characters, and N is a natural number greater than or equal to 2.
Step S404, searching whether characters matched with the query characters exist in text information by taking the query characters as query conditions;
And step S406, when the characters matched with the query characters exist, replacing the searched characters with the replacement characters correspondingly according to the positions of the searched characters in the text information.
Steps S402 to S406 are similar to steps S100 to S104, and are not repeated in this embodiment.
According to the character replacement method provided by the embodiment of the invention, the user can conveniently input the query character and the replacement character by providing an input interface.
Referring to FIG. 5, a schematic diagram of a program module of a character replacement system 500 (hereinafter referred to as "replacement system" 500) according to an embodiment of the invention is shown. In this embodiment, the substitution system 500 may include or be divided into one or more program modules stored in a storage medium and executed by one or more processors to accomplish the present invention and may implement the character substitution method described above. Program modules in accordance with the embodiments of the present invention may be referred to as a series of computer program instruction segments capable of performing particular functions, and are more suitable than programs themselves for describing the execution of the character replacement method in a storage medium. The following description will specifically describe functions of each program module of the present embodiment:
The obtaining module 501 is configured to obtain N query characters and N replacement characters input by a user, where the N query characters include at least two identical query characters, the number of the N replacement characters is identical to the number of the query characters, the replacement characters include at least two different replacement characters, and N is a natural number greater than or equal to 2 and includes at least.
Specifically, when the text information is edited by the text editing tool, when a plurality of original characters in the text information need to be replaced, query characters and replacement characters input by a user are acquired. In this embodiment, the query character is a character to be replaced in the text information, and the query character includes at least two identical characters, for example, the text information includes a character "abcdefgab", and if the user wants to replace two characters "a" in the text information at one time, the two characters "a" are the query characters. The replacement character is a character for replacing an original character in the text information. For example, the user wants to replace two characters "a" in the text information with "c" and "d", that is, "cbcdefgdb", and then the character "cd" is the replacement character. In this embodiment, the replacement character comprises at least two different characters.
In an embodiment, when the query character is input, a plurality of identical characters may be directly input, or the query character may be represented by inputting only one character and a character representing the number of the characters. Examples are as follows:
When the query character is input, "a" may be input; a, A is as follows; a, A is as follows; a' may alternatively be input with "A"; 4", etc. In this embodiment, when the query character is input, the input plurality of characters may be separated by a separator for separating, where the separator may be a punctuation mark such as comma, semicolon, or pause sign, or a symbol such as space and line feed symbol formed by clicking a key such as space key and enter key on the keyboard. When inputting the replacement character, the plurality of characters to be input may be separated by a separator for separating.
In an embodiment, the characters may be words, letters, words, or other character units capable of composing the text information content.
And the searching module 502 uses the query character as a query condition to search whether characters matched with the query character exist in the text information.
Specifically, the query character is used as a query condition, traversal search is carried out in the text information, and whether characters matched with the query character exist or not is judged.
In one embodiment, when the text information is traversed to find the characters matched with the query characters, if the text information is searched for the characters matched with the query characters, the text information is not searched for whether the characters matched with the query characters are matched with the characters, but the step of replacing the characters matched with the query characters with the replacement characters is directly executed.
And a replacing module 503, configured to replace, when there is a character matching the query character, the found character with the replacement character according to the position of the found character in the text information.
Specifically, when the character matched with the query character is found, the position of the found character in the text information is obtained, and the position is the sequence information of the found character in the text information. Examples are as follows:
The text information is "abcdefgab", the matched character is "a", the position of the first searched matched character "a" in the text information is the "first position" in the text information, the position of the second searched matched character "a" in the text information is the "seventh position" in the text information, that is, the "first position" and the "seventh position" are the positions of the searched characters in the text information.
When the position of the searched character in the text information is obtained, the searched character matched with the query character is correspondingly replaced by a new character in the replacement character according to the obtained replacement character input by the user. In one embodiment, when a first original character matched with the query character is found, replacing the first original character matched with the query character with a first character in the replacement characters, and then judging whether a sentence containing the first character in the replacement characters is legal or not by using a preset semantic model, if so, taking the first character in the replacement characters as a target replacement character for replacing the first original character matched with the query character in the text information; if not, continuing to replace the first original character matched with the query character with the second character in the replacement characters, then judging whether sentences containing the second character in the replacement characters are legal or not by using the preset semantic model, and if so, taking the second character in the replacement characters as a target replacement character for replacing the first original character matched with the query character in the text information; if not, repeating the steps until the target replacement character is found.
In this embodiment, the semantic model is an n-gram model, which is a language model constructed by computing maximum likelihood estimates (Maximum Likelihood Estimate), which is also a model that can be used to compute a sentence legal probability. When judging whether the sentence is legal or not by using the model, specifically calculating the probability of sentence validity by using the model, then comparing the calculated probability with a threshold value, judging that the sentence is legal if the calculated probability is larger than the threshold value, and judging that the sentence is illegal if the calculated probability is smaller than the threshold value, wherein the threshold value can be obtained through training. It should be noted that, in this embodiment, the sentence is legal, which means that the grammar and the semantics of the sentence are reasonable, and the meaning of the sentence expression is clear and correct.
After the replacement of the first original character is completed, the query character is continuously used as a query condition, the traversal query is continuously performed in the text information from the position of acquiring the first original character to find a second character matched with the query character, when the second character matched with the query character is found, the original character matched with the query character is replaced by the character in the replacement character, and the like until the replacement of all the characters is completed, and the specific character replacement method is described in detail above and is not repeated here. In another embodiment, after the matching characters with the same number as the query characters are searched in the text information, the matching characters are replaced with each character in the replacement characters according to the positions of each searched matching character in the text information, and of course, the characters can be replaced in a parallel manner, namely, a plurality of characters can be replaced at one time or all the characters can be replaced at one time.
Further, in an embodiment, the replacing module 503 is further configured to determine whether the number of the searched characters is the same as the number of the query characters when there are characters matched with the query characters; and the method is used for correspondingly replacing the searched characters with the replacement characters according to the positions of the searched characters in the text information when the number of the searched characters is the same as that of the query characters.
Specifically, when searching the characters matched with the query character in the text information, when searching the matched characters, recording what number of the matched characters is the currently searched characters so as to determine whether the number of the currently searched matched characters is enough, namely judging whether the number of the searched characters is the same as the number of the query characters.
When the matching characters with the number equal to the number of the query characters are found in the text information, the found characters are replaced with the characters in the replacement characters in a one-to-one correspondence mode according to the positions of the found characters in the text information. In this embodiment, the position is the sequence of the searched characters in the text information.
Examples are as follows: the text information is assumed to consist of the following characters: and absdefcdabcejgalv, wherein the query character is aa, the replacement character is zm, after traversing the text information, the first searched matched character a is positioned at the first position in the text information, the second searched matched character a is positioned at the ninth position in the text information, when the searched character is replaced, the character a in the first position in the text information is replaced with the character z, then whether a sentence after replacement is legal is judged, if yes, the character z is used as a target replacement character, if not, the character a in the first position is replaced with the character m, then whether the sentence after replacement is legal is judged, and if yes, the character m is used as a target replacement character. Similarly, when the character "a" located in the ninth bit in the text information is replaced, the above replacing step is still repeated, assuming that the text information becomes "z bsdefcd m bcejgalv" after the replacement.
Further, in an embodiment, when the number of the found matching characters is found to be less than the number of the query characters when the text information is traversed, a prompt message may be output to remind the user that there are not so many matching characters in the text information. Preferably, the prompt message may prompt "the number of the matching characters is insufficient" or "please reduce the number of the query characters" in a popup window manner.
Further, in another embodiment, when the text information is traversed, the number of found matching characters is found to be smaller than the number of query characters, and the found characters can still be replaced with the replacement characters according to the positions of the found characters in the text information.
Examples are as follows: the text information is assumed to consist of the following characters: and "abcdefah", wherein the query character is "aaa", the replacement character is "zmg", after traversing the text information, the first searched matching character "a" is located at the first position in the text information, the second searched matching character "a" is located at the seventh position in the text information, and the third matching character is not found, when the searched character is replaced, the first character "a" located in the first position in the text information is replaced with the character "z", then whether the replaced sentence is legal or not is judged, if not, the character "z" is used as a target replacement character, if not, the character "a" in the first position is replaced with the character "m", then whether the replaced sentence is legal or not is judged, if not, the character "m" is used as a target replacement character, if not, the character "a" in the first position is replaced with the character "g", then whether the replaced sentence is legal or not is judged, and if not, the replaced sentence "g" is used as the target character ". Similarly, when the character "a" located in the seventh bit in the text information is replaced, the above-described replacing step is repeated, assuming that the text information becomes "z bcdefmh" after the replacement.
Still further, in an embodiment, the searching module 502 is further configured to search whether a character matching the query character exists in the text information according to the location information using the query character as a query condition.
Specifically, the query character further includes position information of a character to be replaced, where the character to be replaced is a character in the text information, and a new character (i.e., a replacement character in the present invention) needs to be used to replace the character to be replaced. The position information is the position of the character to be replaced in the text information. In a specific embodiment, the location information in the query character is represented as follows: the query characters are "a1 and a4", and the query characters represent that the first character "a" and the 4 th character "a" in the text information need to be replaced by new characters.
When the query character is used as a query condition, through traversing searching in the text information, when the character matched with the query character is searched, whether the searched character belongs to the character matched with the query character or not is further required to be judged according to the position information.
Examples are as follows: assuming that the text information is "abcdaeaf", the query character is "a1, a4", when the first character "a" is found in the text information, the position information of the first character "a" is found to be the same as the position information of the query character, so that the first character "a" can be used as the character matched with the query character, when the second character "a" is found in the continuous search, the position information of the second character "a" is found to be different from the position information of the query character, and the second character "a" is not used as the character matched with the query character.
In another embodiment of the present invention, the replacement system 500 further includes:
the providing module is used for providing an input interface for a user to input the query character and the replacement character.
Specifically, before a plurality of original characters in the text information need to be replaced, an input interface can be provided for a user through an editing tool operated currently, and the user can input the query characters and the replacement characters through the input interface.
According to the character replacement system provided by the embodiment of the invention, query characters and replacement characters input by a user are obtained, wherein the query characters comprise at least two identical characters, the number of the replacement characters is identical to that of the query characters, and the replacement characters comprise at least two different characters; searching whether characters matched with the query characters exist in text information by taking the query characters as query conditions; and when the characters matched with the query characters exist, replacing the characters matched with the query characters with the replacement characters, so that a plurality of identical original characters can be replaced with different new characters at the same time, and the operations of inputting, searching and replacing each original character are not required to be carried out again, thereby reducing the complexity of character replacement.
Referring to fig. 6, a hardware architecture diagram of a computer device 600 according to an embodiment of the invention is shown. In this embodiment, the computer device 600 is a device capable of automatically performing numerical calculation and/or information processing according to a preset or stored instruction. As shown, the computer device 600 includes, but is not limited to, at least a memory 601, a processor 602, a network interface 603, and a character substitution system 604 communicatively coupled to each other via a system bus. Wherein:
In this embodiment, the memory 601 includes at least one type of computer-readable storage medium including flash memory, a hard disk, a multimedia card, a card memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, and the like. In some embodiments, the memory 601 may be an internal storage unit of the computer device 600, such as a hard disk or memory of the computer device 600. In other embodiments, the memory 601 may also be an external storage device of the computer device 600, such as a plug-in hard disk, a smart memory card (SMART MEDIA CARD, SMC), a Secure Digital (SD) card, a flash memory card (FLASH CARD), etc. that are provided on the computer device 600. Of course, the memory 601 may also include both internal storage units of the computer device 600 and external storage devices. In this embodiment, the memory 601 is typically used to store an operating system installed on the computer device 600 and various types of application software, such as program code of the character substitution system 604. In addition, the memory 601 may also be used to temporarily store various types of data that have been output or are to be output.
The processor 602 may be a central processing unit (Central Processing Unit, CPU), controller, microcontroller, microprocessor, or other data processing chip in some embodiments. The processor 602 is generally used to control the overall operation of the computer device 600. In this embodiment, the processor 602 is configured to execute the program code stored in the memory 601 or process data, for example, execute the character substitution system 604, to implement the character substitution method in each of the above embodiments.
The network interface 603 may include a wireless network interface or a wired network interface, which network interface 603 is typically used to establish a communication connection between the computer apparatus 600 and other electronic devices. For example, the network interface 603 is used to connect the computer device 600 to an external terminal through a network, establish a data transmission channel and a communication connection between the computer device 600 and the external terminal, and the like. The network may be an Intranet (Intranet), the Internet (Internet), a global system for mobile communications (Global System of Mobile communication, GSM), wideband code division multiple access (Wideband Code Division Multiple Access, WCDMA), a 4G network, a 5G network, bluetooth (Bluetooth), wi-Fi, or other wireless or wired network.
It should be noted that fig. 6 only shows a computer device 600 having components 601-604, but it should be understood that not all of the illustrated components are required to be implemented and that more or fewer components may be implemented instead.
In this embodiment, the character substitution system 604 stored in the memory 601 may be further divided into one or more program modules, which are stored in the memory 601 and executed by one or more processors (the processor 602 in this embodiment) to perform the character substitution method of the present invention.
The present embodiment also provides a computer-readable storage medium such as a flash memory, a hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, a server, an App application store, etc., on which a computer program is stored, which when executed by a processor, performs the corresponding functions. The computer readable storage medium of the present embodiment is used to store the character replacement system 500 or 604 to implement the character replacement method of the present invention when executed by a processor.
The foregoing embodiment numbers of the present invention are merely for the purpose of description, and do not represent the advantages or disadvantages of the embodiments.
From the above description of the embodiments, it will be clear to those skilled in the art that the above-described embodiment method may be implemented by means of software plus a necessary general hardware platform, but of course may also be implemented by means of hardware, but in many cases the former is a preferred embodiment.
The foregoing description is only of the preferred embodiments of the present invention, and is not intended to limit the scope of the invention, but rather is intended to cover any equivalents of the structures or equivalent processes disclosed herein or in the alternative, which may be employed directly or indirectly in other related arts.

Claims (9)

1. A character substitution method, comprising the steps of:
Acquiring N query characters and N replacement characters input by a user, wherein the N query characters comprise at least two identical query characters, the N replacement characters comprise at least two different replacement characters, and N is a natural number greater than or equal to 2;
Searching whether characters matched with the query characters exist in text information by taking the query characters as query conditions; and
When the characters matched with the query characters exist, replacing the searched character correspondence with the replacement character according to the position of the searched character in the text information, wherein the position is the sequence information of the searched character in the text information, and the replacement of the searched character correspondence with the replacement character is specifically as follows:
Sequentially acquiring one of the replacement characters, and replacing the searched character with the acquired replacement character;
judging whether the obtained sentence containing the replacement character is legal or not by using a preset semantic model;
If the character is legal, the obtained replacement character is used as a target replacement character to replace the searched character;
when the characters matched with the query characters exist, the step of correspondingly replacing the searched characters with the replacement characters according to the positions of the searched characters in the text information comprises the following steps:
When characters matched with the query characters exist, judging whether the number of the searched characters is the same as the number of the query characters; and
And if the number of the searched characters is the same as that of the query characters, correspondingly replacing the searched characters with the replacement characters according to the positions of the searched characters in the text information.
2. The character replacement method according to claim 1, wherein after the step of judging whether the number of the searched characters is the same as the number of the query characters, further comprising:
and outputting prompt information when the number of the searched characters is less than the number of the query characters.
3. The character replacement method according to claim 1, wherein after the step of judging whether the number of the searched characters is the same as the number of the query characters, further comprising:
When the number of the searched characters is smaller than the number of the query characters, the searched characters are correspondingly replaced with the replacement characters according to the positions of the searched characters in the text information.
4. The character replacement method according to claim 1, wherein when searching for characters matching the query character in the text information, if matching characters having the same number as the query character are searched for in the text information, the step of replacing the searched characters with the replacement characters according to the positions of the searched characters in the text information is performed.
5. The character replacement method as claimed in claim 1, wherein the query character further includes location information of a character to be replaced, and the step of searching text information for whether there is a character matching the query character using the query character as a query condition includes:
and searching whether characters matched with the query characters exist in the text information according to the position information by taking the query characters as query conditions.
6. The character replacement method according to any one of claims 1 to 5, characterized in that the character replacement method further comprises:
an input interface is provided for a user to input the query character and the replacement character.
7. A character substitution system, comprising:
The acquisition module is used for acquiring N query characters and N replacement characters input by a user, wherein the N query characters comprise at least two identical query characters, the number of the N replacement characters is identical to that of the query characters, the replacement characters comprise at least two different replacement characters, and N is a natural number greater than or equal to 2;
the searching module is used for searching whether characters matched with the query characters exist in the text information by taking the query characters as query conditions; and
The replacing module is used for replacing the searched character correspondence with the replacing character according to the position of the searched character in the text information when the character matched with the query character exists, wherein the position is the sequence information of the searched character in the text information, and the replacing of the searched character correspondence with the replacing character is specifically:
Sequentially acquiring one of the replacement characters, and replacing the searched character with the acquired replacement character;
judging whether the obtained sentence containing the replacement character is legal or not by using a preset semantic model;
If the character is legal, the obtained replacement character is used as a target replacement character to replace the searched character;
The replacing module is further used for judging whether the number of the searched characters is the same as the number of the query characters when the characters matched with the query characters exist; and
And if the number of the searched characters is the same as that of the query characters, correspondingly replacing the searched characters with the replacement characters according to the positions of the searched characters in the text information.
8. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the steps of the character replacement method according to any one of claims 1 to 6 when the computer program is executed.
9. A computer-readable storage medium, in which a computer program is stored, the computer program being executable by at least one processor to cause the at least one processor to perform the steps of the character replacement method according to any one of claims 1-6.
CN201910553284.XA 2019-06-25 2019-06-25 Character replacement method, system, computer device and computer readable storage medium Active CN110442843B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201910553284.XA CN110442843B (en) 2019-06-25 2019-06-25 Character replacement method, system, computer device and computer readable storage medium
PCT/CN2019/117404 WO2020258652A1 (en) 2019-06-25 2019-11-12 Character replacement method and system, computer apparatus, and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910553284.XA CN110442843B (en) 2019-06-25 2019-06-25 Character replacement method, system, computer device and computer readable storage medium

Publications (2)

Publication Number Publication Date
CN110442843A CN110442843A (en) 2019-11-12
CN110442843B true CN110442843B (en) 2024-06-11

Family

ID=68428306

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910553284.XA Active CN110442843B (en) 2019-06-25 2019-06-25 Character replacement method, system, computer device and computer readable storage medium

Country Status (2)

Country Link
CN (1) CN110442843B (en)
WO (1) WO2020258652A1 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112363655A (en) * 2020-11-30 2021-02-12 中国银行股份有限公司 Data processing method and device
CN113434641B (en) * 2021-07-26 2022-10-11 广州四三九九信息科技有限公司 Multithreading mask word query replacement method

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101140581A (en) * 2007-05-24 2008-03-12 中兴通讯股份有限公司 SQL statement construct method and apparatus of preprocess special-character
CN103678554A (en) * 2013-12-06 2014-03-26 金蝶软件(中国)有限公司 Character substituting method and device
CN106502979A (en) * 2016-09-20 2017-03-15 海信集团有限公司 A kind of data processing method of natural language information and device
CN106650715A (en) * 2016-10-26 2017-05-10 西安电子科技大学 Method for detecting and correcting errors of OCR recognition results of character strings according to permission set
CN109241504A (en) * 2018-09-03 2019-01-18 合肥智慧龙图腾知识产权股份有限公司 A kind of character string replacement method, device, computer equipment and computer readable storage medium

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6631501B1 (en) * 1999-06-30 2003-10-07 Microsoft Corporation Method and system for automatic type and replace of characters in a sequence of characters
CN105608064A (en) * 2015-11-24 2016-05-25 小米科技有限责任公司 Character replacement method and apparatus
JP6605995B2 (en) * 2016-03-16 2019-11-13 株式会社東芝 Speech recognition error correction apparatus, method and program

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101140581A (en) * 2007-05-24 2008-03-12 中兴通讯股份有限公司 SQL statement construct method and apparatus of preprocess special-character
CN103678554A (en) * 2013-12-06 2014-03-26 金蝶软件(中国)有限公司 Character substituting method and device
CN106502979A (en) * 2016-09-20 2017-03-15 海信集团有限公司 A kind of data processing method of natural language information and device
CN106650715A (en) * 2016-10-26 2017-05-10 西安电子科技大学 Method for detecting and correcting errors of OCR recognition results of character strings according to permission set
CN109241504A (en) * 2018-09-03 2019-01-18 合肥智慧龙图腾知识产权股份有限公司 A kind of character string replacement method, device, computer equipment and computer readable storage medium

Also Published As

Publication number Publication date
WO2020258652A1 (en) 2020-12-30
CN110442843A (en) 2019-11-12

Similar Documents

Publication Publication Date Title
CN110502608B (en) Man-machine conversation method and man-machine conversation device based on knowledge graph
AU2017408800B2 (en) Method and system of mining information, electronic device and readable storable medium
CN111177184A (en) Structured query language conversion method based on natural language and related equipment thereof
WO2021151270A1 (en) Method and apparatus for extracting structured data from image, and device and storage medium
CN111428474A (en) Language model-based error correction method, device, equipment and storage medium
CN111310440B (en) Text error correction method, device and system
CN110515951B (en) BOM standardization method and system, electronic device and storage medium
CN110866115B (en) Sequence labeling method, system, computer equipment and computer readable storage medium
CN108959247B (en) Data processing method, server and computer readable medium
CN112396049A (en) Text error correction method and device, computer equipment and storage medium
CN107832035B (en) Voice input method of intelligent terminal
CN111339166A (en) Word stock-based matching recommendation method, electronic device and storage medium
CN111984792A (en) Website classification method and device, computer equipment and storage medium
CN110442843B (en) Character replacement method, system, computer device and computer readable storage medium
CN113127621A (en) Dialogue module pushing method, device, equipment and storage medium
CN104090865B (en) Text similarity calculation method and device
CN109871544B (en) Entity identification method, device, equipment and storage medium based on Chinese medical record
CN110502620B (en) Method, system and computer equipment for generating guide diagnosis similar problem pairs
CN110929514B (en) Text collation method, text collation apparatus, computer-readable storage medium, and electronic device
CN114238602A (en) Dialogue analysis method, device, equipment and storage medium based on corpus matching
CN113177407A (en) Data dictionary construction method and device, computer equipment and storage medium
US11790170B2 (en) Converting unstructured technical reports to structured technical reports using machine learning
CN106407332B (en) Search method and device based on artificial intelligence
CN107798004B (en) Keyword searching method and device and terminal
CN112784611A (en) Data processing method, device and computer storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant