# US 2023/0065965 A1 · Text processing method and apparatus

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2023/0065965 A1
- Document ID: US20230065965A1
- Status: Published application
- Kind: A1
- Application number: 17/788,052
- Filed: 2020-12-11
- Published: 2023-03-02
- Earliest claimed: 2019-12-23
- Assignees: Huawei Technologies Co., Ltd.
- Applicants: Huawei Technologies Co., Ltd.
- Inventors: Jie LIU; Guanwen ZHU
- Web page: https://patentgrep.com/patent/US20230065965A1

## CPC

- G06F 40/232: Orthographic correction, e.g. spell checking or vowelisation
- G06F 40/284: Lexical analysis, e.g. tokenisation or collocates
- G06F 40/166: Editing, e.g. inserting or deleting
- G06F 40/40: Processing or translation of natural language (natural language analysis G06F40/20; semantic analysis G06F40/30)
- G06N 3/0464: Convolutional networks [CNN, ConvNet]
- G06N 3/048: Activation functions
- G06N 3/084: Backpropagation, e.g. using gradient descent
- G06F 40/242: Dictionaries
- G06F 40/30: Semantic analysis
- G06N 3/08: Learning methods
- G06N 3/09: Supervised learning
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)
- G06N: COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS

## Abstract

This application discloses a text processing method and apparatus in the natural language processing field in the artificial intelligence field. The method includes: obtaining a to-be-processed text; performing error detection processing on the to-be-processed text to obtain a non-word in the to-be-processed text; and if the non-word in the to-be-processed text belongs to a first type of non-word, skipping correcting the non-word in the to-be-processed text; or if the non-word in the to-be-processed text belongs to a second type of non-word, a third type of non-word, or a fourth type of non-word, selecting a correction mode matching the type of the non-word in the to-be-processed text to correct the non-word in the to-be-processed text and obtain a correction result of the non-word in the to-be-processed text. According to the technical solutions of this application, a plurality of types of character strings can be detected and filtered.

## Claims

### Claim at position 1

1-24. (canceled)

### Claim 25

A text processing method, comprising:
obtaining a to-be-processed text;
performing error detection processing on the to-be-processed text to obtain a non-word in the to-be-processed text; and
responsive to a type of the non-word in the to-be-processed text belonging to a first type of non-word, using the non-word in the to-be-processed text as a correction result of the non-word in the to-be-processed text; or
responsive to the type of the non-word in the to-be-processed text belonging to a second type of non-word, a third type of non-word, or a fourth type of non-word, selecting a correction mode matching the type of the non-word in the to-be-processed text to correct the non-word in the to-be-processed text and obtain a correction result of the non-word in the to-be-processed text, wherein
the first type of non-word comprises at least one of an all-uppercase-letter non-word, a non-word whose length is within a preset length range, or a non-word belonging to a first preset lexicon, the second type of non-word comprises a compound incorrect non-word, the third type of non-word comprises a non-word comprising a non-letter character, and the fourth type of non-word comprises non-words other than the first type of non-word, the second type of non-word, and the third type of non-word.

### Claim 26 (depends on 25)

The method according to claim 25, wherein the selecting the correction mode matching the type of the non-word in the to-be-processed text to correct the non-word in the to-be-processed text and obtain the correction result of the non-word in the to-be-processed text responsive to the type of the non-word in the to-be-processed text belonging to the second type of non-word, the third type of non-word, or the fourth type of non-word comprises:
responsive to the type of the non-word in the to-be-processed text belonging to the fourth type of non-word, generating candidate words corresponding to the non-word in the to-be-processed text;
determining, from the candidate words corresponding to the non-word in the to-be-processed text, a target candidate word corresponding to the non-word in the to-be-processed text; and
correcting the non-word in the to-be-processed text based on the target candidate word corresponding to the non-word in the to-be-processed text, to obtain the correction result of the non-word in the to-be-processed text.

### Claim 27 (depends on 26)

The method according to claim 26, wherein the determining, from the candidate words corresponding to the non-word in the to-be-processed text, the target candidate word corresponding to the non-word in the to-be-processed text comprises:
scoring, based on a similarity between the non-word in the to-be-processed text and a candidate word corresponding to the non-word in the to-be-processed text and a perplexity of the candidate word corresponding to the non-word in the to-be-processed text, the candidate word corresponding to the non-word in the to-be-processed text, wherein the perplexity of the candidate word corresponding to the non-word in the to-be-processed text is used to indicate a possibility that the candidate word corresponding to the non-word in the to-be-processed text occurs in the to-be-processed text; and
determining a candidate word with a highest score among the candidate words corresponding to the non-word in the to-be-processed text as the target candidate word corresponding to the non-word in the to-be-processed text.

### Claim 28 (depends on 27)

The method according to claim 27, wherein the similarity between the non-word in the to-be-processed text and the candidate word corresponding to the non-word in the to-be-processed text meets a first preset condition.

### Claim 29 (depends on 26)

The method according to claim 26, wherein the correcting the non-word in the to-be-processed text based on the target candidate word corresponding to the non-word in the to-be-processed text, to obtain the correction result of the non-word in the to-be-processed text comprises:
responsive to a perplexity of the target candidate word corresponding to the non-word in the to-be-processed text being less than or equal to a first perplexity threshold, replacing the non-word in the to-be-processed text with the target candidate word corresponding to the non-word in the to-be-processed text, and using the target candidate word as the correction result of the non-word in the to-be-processed text.

### Claim 30 (depends on 25)

The method according to claim 25, wherein the compound incorrect non-word is a non-word comprising at least two real words, and
wherein the selecting the correction mode matching the type of the non-word in the to-be-processed text to correct the non-word in the to-be-processed text and obtain the correction result of the non-word in the to-be-processed text responsive to the type of the non-word in the to-be-processed text belonging to the second type of non-word, the third type of non-word, or the fourth type of non-word comprises:
responsive to the type of the non-word in the to-be-processed text belonging to the second type of non-word, correcting the non-word in the to-be-processed text to obtain the at least two real words, and using the at least two real words as the correction result of the non-word in the to-be-processed text.

### Claim 31 (depends on 25)

The method according to claim 25, wherein the selecting the correction mode matching the type of the non-word in the to-be-processed text to correct the non-word in the to-be-processed text and obtain the correction result of the non-word in the to-be-processed text responsive to the type of the non-word in the to-be-processed text belonging to the second type of non-word, the third type of non-word, or the fourth type of non-word comprises:
responsive to the type of the non-word in the to-be-processed text belonging to the third type of non-word, modifying the non-letter character in the non-word in the to-be-processed text to a letter, and using a modified word as the correction result of the non-word in the to-be-processed text.

### Claim 32 (depends on 25)

The method according to claim 25, wherein the method further comprises:
performing real-word error detection on the to-be-processed text to obtain an incorrect real word in the to-be-processed text;
generating candidate words corresponding to the incorrect real word;
determining, from the candidate words corresponding to the incorrect real word, a target candidate word corresponding to the incorrect real word; and
correcting the incorrect real word based on the target candidate word corresponding to the incorrect real word, to obtain a correction result of the incorrect real word.

### Claim 33 (depends on 32)

The method according to claim 32, wherein the determining, from the candidate words corresponding to the incorrect real word, the target candidate word corresponding to the incorrect real word comprises:
scoring, based on a similarity between the incorrect real word and a candidate word corresponding to the incorrect real word and a perplexity of the candidate word corresponding to the incorrect real word, the candidate word corresponding to the incorrect real word, wherein the perplexity of the candidate word corresponding to the incorrect real word is used to indicate a possibility that the candidate word corresponding to the incorrect real word occurs in the to-be-processed text; and
determining a candidate word with a highest score among the candidate words corresponding to the incorrect real word as the target candidate word corresponding to the incorrect real word.

### Claim 34 (depends on 33)

The method according to claim 33, wherein the similarity between the incorrect real word and the candidate word corresponding to the incorrect real word meets a second preset condition.

### Claim 35 (depends on 32)

The method according to claim 32, wherein the correcting the incorrect real word based on the target candidate word corresponding to the incorrect real word, to obtain the correction result of the incorrect real word comprises:
responsive to a perplexity of the target candidate word corresponding to the incorrect real word being less than or equal to a second perplexity threshold, replacing the incorrect real word with the target candidate word corresponding to the incorrect real word, and using the target candidate word as the correction result of the incorrect real word.

### Claim 36

A text processing apparatus, comprising:
a memory, configured to store a program; and
a processor, configured to execute the program stored in the memory, wherein when the processor executes the program stored in the memory, the processor is configured to perform operations comprising:
obtaining a to-be-processed text;
performing error detection processing on the to-be-processed text to obtain a non-word in the to-be-processed text; and
responsive to a type of the non-word in the to-be-processed text belonging to a first type of non-word, using the non-word in the to-be-processed text as a correction result of the non-word in the to-be-processed text; or
responsive to the type of the non-word in the to-be-processed text belonging to a second type of non-word, a third type of non-word, or a fourth type of non-word, selecting a correction mode matching the type of the non-word in the to-be-processed text to correct the non-word in the to-be-processed text and obtain a correction result of the non-word in the to-be-processed text, wherein
the first type of non-word comprises at least one of an all-uppercase-letter non-word, a non-word whose length is within a preset length range, or a non-word belonging to a first preset lexicon, the second type of non-word comprises a compound incorrect non-word, the third type of non-word comprises a non-word comprising a non-letter character, and the fourth type of non-word comprises non-words other than the first type of non-word, the second type of non-word, and the third type of non-word.

### Claim 37 (depends on 36)

The apparatus according to claim 36, wherein the selecting the correction mode matching the type of the non-word in the to-be-processed text to correct the non-word in the to-be-processed text and obtain the correction result of the non-word in the to-be-processed text responsive to the type of the non-word in the to-be-processed text belonging to the second type of non-word, the third type of non-word, or the fourth type of non-word comprises:
responsive to the type of the non-word in the to-be-processed text belonging to the fourth type of non-word, generating candidate words corresponding to the non-word in the to-be-processed text;
determining, from the candidate words corresponding to the non-word in the to-be-processed text, a target candidate word corresponding to the non-word in the to-be-processed text; and
correcting the non-word in the to-be-processed text based on the target candidate word corresponding to the non-word in the to-be-processed text, to obtain the correction result of the non-word in the to-be-processed text.

### Claim 38 (depends on 37)

The apparatus according to claim 37, wherein the determining, from the candidate words corresponding to the non-word in the to-be-processed text, the target candidate word corresponding to the non-word in the to-be-processed text comprises:
scoring, based on a similarity between the non-word in the to-be-processed text and a candidate word corresponding to the non-word in the to-be-processed text and a perplexity of the candidate word corresponding to the non-word in the to-be-processed text, the candidate word corresponding to the non-word in the to-be-processed text, wherein the perplexity of the candidate word corresponding to the non-word in the to-be-processed text is used to indicate a possibility that the candidate word corresponding to the non-word in the to-be-processed text occurs in the to-be-processed text; and
determining a candidate word with a highest score among the candidate words corresponding to the non-word in the to-be-processed text as the target candidate word corresponding to the non-word in the to-be-processed text.

### Claim 39 (depends on 38)

The apparatus according to claim 38, wherein the similarity between the non-word in the to-be-processed text and the candidate word corresponding to the non-word in the to-be-processed text meets a first preset condition.

### Claim 40 (depends on 37)

The apparatus according to claim 37, wherein the correcting the non-word in the to-be-processed text based on the target candidate word corresponding to the non-word in the to-be-processed text, to obtain the correction result of the non-word in the to-be-processed text comprises:
responsive to a perplexity of the target candidate word corresponding to the non-word in the to-be-processed text being less than or equal to a first perplexity threshold, replacing the non-word in the to-be-processed text with the target candidate word corresponding to the non-word in the to-be-processed text, and using the target candidate word as the correction result of the non-word in the to-be-processed text.

### Claim 41 (depends on 36)

The apparatus according to claim 36, wherein the compound incorrect non-word is a non-word comprising at least two real words, and
wherein the selecting the correction mode matching the type of the non-word in the to-be-processed text to correct the non-word in the to-be-processed text and obtain the correction result of the non-word in the to-be-processed text responsive to the type of the non-word in the to-be-processed text belonging to the second type of non-word, the third type of non-word, or the fourth type of non-word comprises:
responsive to the type of the non-word in the to-be-processed text belonging to the second type of non-word, correcting the non-word in the to-be-processed text to obtain the at least two real words, and using the at least two real words as the correction result of the non-word in the to-be-processed text.

### Claim 42 (depends on 36)

The apparatus according to claim 36, wherein the selecting the correction mode matching the type of the non-word in the to-be-processed text to correct the non-word in the to-be-processed text and obtain the correction result of the non-word in the to-be-processed text responsive to the type of the non-word in the to-be-processed text belonging to the second type of non-word, the third type of non-word, or the fourth type of non-word comprises:
responsive to the type of the non-word in the to-be-processed text belonging to the third type of non-word, modifying the non-letter character in the non-word in the to-be-processed text to a letter, and using a modified word as the correction result of the non-word in the to-be-processed text.

### Claim 43 (depends on 36)

The apparatus according to claim 36, wherein the operations further comprise:
performing real-word error detection on the to-be-processed text to obtain an incorrect real word in the to-be-processed text;
generating candidate words corresponding to the incorrect real word;
determining, from the candidate words corresponding to the incorrect real word, a target candidate word corresponding to the incorrect real word; and
correcting the incorrect real word based on the target candidate word corresponding to the incorrect real word, to obtain a correction result of the incorrect real word.

### Claim 44

A computer readable storage medium, wherein the computer readable storage medium stores a program instruction, and when the program instruction is run by a processor, to perform operations comprising:
obtaining a to-be-processed text;
performing error detection processing on the to-be-processed text to obtain a non-word in the to-be-processed text; and
responsive to a type of the non-word in the to-be-processed text belonging to a first type of non-word, using the non-word in the to-be-processed text as a correction result of the non-word in the to-be-processed text; or
responsive to the type of the non-word in the to-be-processed text belonging to a second type of non-word, a third type of non-word, or a fourth type of non-word, selecting a correction mode matching the type of the non-word in the to-be-processed text to correct the non-word in the to-be-processed text and obtain a correction result of the non-word in the to-be-processed text, wherein
the first type of non-word comprises at least one of an all-uppercase-letter non-word, a non-word whose length is within a preset length range, or a non-word belonging to a first preset lexicon, the second type of non-word comprises a compound incorrect non-word, the third type of non-word comprises a non-word comprising a non-letter character, and the fourth type of non-word comprises non-words other than the first type of non-word, the second type of non-word, and the third type of non-word.
