WO2022174495A1 - 文本纠错方法、装置、电子设备及存储介质 - Google Patents

文本纠错方法、装置、电子设备及存储介质 Download PDF

Info

Publication number
WO2022174495A1
WO2022174495A1 PCT/CN2021/083709 CN2021083709W WO2022174495A1 WO 2022174495 A1 WO2022174495 A1 WO 2022174495A1 CN 2021083709 W CN2021083709 W CN 2021083709W WO 2022174495 A1 WO2022174495 A1 WO 2022174495A1
Authority
WO
WIPO (PCT)
Prior art keywords
word
character
sentence
probability
extended
Prior art date
Application number
PCT/CN2021/083709
Other languages
English (en)
French (fr)
Inventor
李俊杰
黄力
马骏
王少军
Original Assignee
平安科技(深圳)有限公司
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 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2022174495A1 publication Critical patent/WO2022174495A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • G06F40/289Phrasal analysis, e.g. finite state techniques or chunking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/3331Query processing
    • G06F16/334Query execution
    • G06F16/3344Query execution using natural language analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating training patterns; Bootstrap methods, e.g. bagging or boosting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/205Parsing
    • G06F40/211Syntactic parsing, e.g. based on context-free grammar [CFG] or unification grammars
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks

Definitions

  • the present application relates to the technical field of natural language processing, and in particular, to a text error correction method, apparatus, electronic device, and computer-readable storage medium.
  • Text error correction refers to the process of correcting erroneous content in text. Text error correction is an increasingly important part of natural language processing.
  • a text error correction method provided by this application includes:
  • the present application also provides a text error correction device, the device includes:
  • the ill-sentence judgment module is used to analyze the text input by the user by using a pre-trained character expansion model, and obtain the expanded word on each character position in the text and the output probability of each expanded word, and the output probability of the
  • the expanded word is screened to obtain an expanded word set, and according to the expanded word set, it is judged whether the character at the corresponding position in the text is a typo, and the sentence with the typo is extracted to obtain a sick sentence;
  • a probability calculation module used to calculate the replacement probability of each extended word in the extended word set, and obtain a candidate word set corresponding to each character in the sick sentence by screening from the extended word set according to the replacement probability;
  • the disease sentence recombination module is used to combine the candidate word sets corresponding to adjacent characters in the disease sentence to obtain a word sequence, and when the word sequence is in the pre-built standard vocabulary, the word sequence is stored in a preset the set of phrases;
  • the optimal sentence query module is used to construct a word grid by using the phrase set and the candidate character set, and query the word combination statement on each path in the word grid, and select the word combination statement from the word combination statement.
  • the optimal sentence is selected, and the bad sentence is replaced by the optimal sentence.
  • the present application also provides an electronic device, the electronic device comprising:
  • the memory stores computer program instructions executable by the at least one processor, the computer program instructions being executed by the at least one processor to enable the at least one processor to perform the steps of:
  • the present application also provides a computer-readable storage medium, including a storage data area and a storage program area, the storage data area stores created data, and the storage program area stores a computer program; wherein, the computer program is implemented as follows when executed by a processor step:
  • FIG. 1 is a schematic flowchart of a text error correction method provided by an embodiment of the present application.
  • FIG. 2 is a schematic block diagram of a text error correction device provided by an embodiment of the present application.
  • FIG. 3 is a schematic diagram of the internal structure of an electronic device for implementing a text error correction method provided by an embodiment of the present application
  • the embodiment of the present application provides a text error correction method.
  • the execution body of the text error correction method includes, but is not limited to, at least one of electronic devices that can be configured to execute the method provided by the embodiments of the present application, such as a server and a terminal.
  • the text error correction method can be executed by software or hardware installed in a terminal device or a server device, and the software can be a blockchain platform.
  • the server includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, and the like.
  • the text error correction method includes:
  • S1 analyze the text input by the user by using a pre-trained character expansion model, obtain the expanded word at each character position in the text and the output probability of each expanded word, and perform the expanded word according to the output probability. Screening to obtain an extended character set, and according to the extended character set, it is judged whether the characters in the corresponding positions in the text are typos, and sentences with typos are extracted to obtain ill sentences.
  • the character expansion model in the embodiment of the present application is a neural network model for judging which characters in the sentence can be replaced according to the semantics before and after the sentence.
  • the neural network model may be a Bert neural network model, wherein the Bert neural network is a text classification network commonly used in natural language processing.
  • the embodiment of the present application uses the Chinese training set to fine-tune the Bert neural network, so that the Bert neural network is more suitable for processing the Chinese semantic environment, and the Chinese character expansion model is obtained.
  • the pre-trained character expansion model is used to analyze the text input by the user, and the expanded word at each character position in the text and the output probability of each expanded word are obtained, including:
  • the character expansion model uses the character expansion model to infer a replacement result of the extracted single word according to the remaining sentences before and after the extracted single word, wherein the replacement result includes the expanded word and the output probability corresponding to the expanded word.
  • the word “I” is extracted from the sentence “My bookcase is down” as a single word, then according to the remaining sentences of the sentence "() The bookcase is down", the replacement result of the single word can be determined. It can be "you, 0.5", “he, 0.5”, etc.
  • the word “ark” is extracted as a single word, and the single word can be determined according to the remaining sentences of the sentence “My family book () is down”
  • the replacement result can be "shelf, 0.3", “room, 0.6”, “sign, 0.5”, etc., and the replacement result is ["I”: “you, 0.5", “he, 0.5", ..., "cabinet” “: “frame, 0.3", “room, 0.6”, “sign, 0.5”...].
  • the expanded word set is obtained by screening the expanded word according to the output probability, including:
  • a preset probability threshold determine whether the output probability is greater than the probability threshold
  • the extended words corresponding to the output probability greater than the probability threshold are reserved to form an extended word set.
  • the probability threshold is set to 0.5
  • the expanded word set with high probability obtained by screening is ["I”: “you, 0.5", “he, 0.5", ..., “cabinet”: “room, 0.6” ", "Sign, 0.5”...].
  • the character expansion model is used to analyze the sentence input by the user, and according to the word meanings before and after the specified position, it is judged which words can be replaced at the specified position, and a candidate character set is obtained, wherein each expanded character in the expanded character set is There is a corresponding output probability, and the extended words are arranged according to the output probability, and the extended word set with the high probability is reserved.
  • the word at the specified position is in the extended word set with high probability, it is not a typo, otherwise, The sentences are sick sentences.
  • the S1 may further include:
  • Step 1 construct a character expansion model comprising a layer linear activation layer and a character extraction network.
  • the present application constructs a linear activation layer to help the symbol-spread model perform model training, wherein the linear activation layer includes normalization and an activation function, and the activation function can use a Gaussian distribution function.
  • Step II Obtain a pre-built word segmentation sample set and a training label set, and use the character extraction network to perform text extraction on the word segmentation sample set to obtain a feature sequence training set.
  • the word segmentation sample set and the training label set are training sets provided by the International Association for Computational Linguistics (ACL) Chinese Group (SIGHAN), which include various common Chinese words with substitution relationships.
  • ACL International Association for Computational Linguistics
  • SIGHAN Chinese Group
  • the replacement relationship of characters has two forms: the replacement of physical proximity and the replacement of sound proximity.
  • “wu” can be replaced by "ox” in shape proximity
  • “gui” can be replaced by "ark” in sound proximity.
  • the training sequence training set in the embodiment of the present application is: “our book is expensive", wherein the training label set is: the word “gui” should be the word "cabinet”.
  • Step III using the multi-layer linear activation layer to perform an activation operation on the feature sequence training set to obtain a prediction sequence set.
  • the word "I” is replaced by [I, oh...]
  • the word "men” is replaced by [door, two...]
  • the word “expensive” is replaced by [cabinet, kneel... ]Wait.
  • the obtained prediction sequence set is [our bookcase is here, my family members are expensive, and the two of you marry a tree and kneel down...].
  • Step IV calculating and calculating the error value of the predicted sequence set according to the training label set, and judging the magnitude relationship between the error value and a preset error threshold;
  • Step V If the error value is greater than the error threshold, then adjust the internal parameters of the character extension model to be trained, and return to the step II, until the error value is less than or equal to the error threshold, the training is completed. character extension model.
  • the S2 includes:
  • the extended words whose replacement probability is greater than the preset threshold are screened to obtain a candidate word set corresponding to each character in the sick sentence.
  • the replacement probability in this embodiment of the present application is equal to [output probability + sound proximity probability + shape proximity probability].
  • the near probability and the near probability can be obtained by calculating the edit distance.
  • the edit distance is also called the Levenshtein distance, and the edit distance algorithm is a quantitative measurement of the degree of difference between two character strings (eg, English words).
  • the shape proximity probability is to split and quantify the strokes of the candidate character
  • the phonetic proximity probability is to split and quantify the pinyin of the candidate character. For example, “Tian” and "You”, “Wu” and “Niu” have the same stroke and stroke order, therefore, the probability of shape proximity is high, and "Form” and "Test” have the same pinyin, so the probability of sound proximity is high .
  • This embodiment of the present application sorts the extended word set according to the replacement probability in descending order, to obtain a preset number of candidate word sets.
  • the candidate word set for "I” is [I, oh...]
  • the candidate word set for "men” is [door, li...], "home”
  • the candidate word sets for "jia, marry...], etc. match each other to obtain the word sequence of [we, ohmen, menjia, family letters, bookcases, shugui...], which can be found in the pre-built standard vocabulary.
  • the phrase set obtained from the query is [we, home letters, bookcases, kneeling down...].
  • the standard vocabulary may be a vocabulary provided by the International Association for Computational Linguistics (ACL) Chinese Group (SIGHAN), including synonyms, antonyms, commonly used words, catchphrases and other corpora.
  • ACL International Association for Computational Linguistics
  • SIGHAN Chinese Group
  • the standard vocabulary may be stored in a blockchain node.
  • the S4 includes:
  • the phrase set corresponding to each character and the replacement candidate character set are used as nodes, and adjacent nodes in the nodes are connected to obtain a word grid;
  • the word grid is constructed from each phrase set and the candidate word set, and the word combination sentence is constructed along the connection route of the word grid to obtain
  • the pre-built query tool beam search is used to search each word combination statement in the word combination statement set, and the word combination statement with the optimal solution is the correction sentence.
  • the embodiment of the present application uses a pre-trained character expansion model to determine the extended word at each character position in the text, so as to determine the disease sentence in the text;
  • words can be connected to each other to obtain phrase sets; sentences can be re-divided according to phrase sets to obtain sentence sets of various versions, and the ill sentences can be split into multiple interpretation methods to cover various possible errors.
  • the constructed query tool can query the optimal solution from the sentence set, obtain corrected sentences, and increase the efficiency and accuracy of interpretation.
  • FIG. 2 it is a schematic diagram of a module of the text error correction apparatus of the present application.
  • the text error correction apparatus 100 described in this application can be installed in an electronic device. According to the realized functions, the text error correction device 100 can be divided into a bad sentence judgment module 101 , a probability calculation module 102 , a bad sentence reconstruction module 103 , and an optimal sentence query module 104 .
  • the modules described in this application may also be referred to as units, which refer to a series of computer program segments that can be executed by the processor of an electronic device and can perform fixed functions, and are stored in the memory of the electronic device.
  • each module/unit is as follows:
  • the sick sentence judgment module 101 is used to analyze the text input by the user by using a pre-trained character expansion model, and obtain the expanded word on each character position in the text and the output probability of each expanded word. According to the output probability Screening the expanded word to obtain an expanded word set, according to the expanded word set, judge whether the character at the corresponding position in the text is a typo, and extract the sentence with the typo to obtain a sick sentence;
  • the probability calculation module 102 is used to calculate and obtain the replacement probability of each extended word in the extended word set, and select a candidate word set corresponding to each character in the sick sentence from the extended word set according to the replacement probability ;
  • the sick sentence reorganization module 103 is used to combine the candidate word sets corresponding to adjacent characters in the sick sentence to obtain a word sequence, and when the word sequence is in a pre-built standard vocabulary, the word sequence is stored. to a preset set of phrases;
  • the optimal sentence query module 104 is used to construct a word grid by using the phrase set and the candidate character set, and query the word combination statement on each path in the word grid, from the word
  • the optimal sentence is selected from the combined sentences, and the bad sentence is replaced by the optimal sentence.
  • FIG. 3 it is a schematic structural diagram of an electronic device implementing the text error correction method of the present application.
  • the electronic device 1 may include a processor 10, a memory 11 and a bus, and may also include a computer program stored in the memory 11 and executable on the processor 10, such as a text error correction program 12.
  • the memory 11 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, mobile hard disk, multimedia card, card-type memory (for example: SD or DX memory, etc.), magnetic memory, magnetic disk, CD etc.
  • the memory 11 may be an internal storage unit of the electronic device 1 in some embodiments, such as a mobile hard disk of the electronic device 1 .
  • the memory 11 may also be an external storage device of the electronic device 1, such as a pluggable mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital Digital, SD) card, flash memory card (Flash Card), etc.
  • the memory 11 may also include both an internal storage unit of the electronic device 1 and an external storage device.
  • the memory 11 can not only be used to store application software installed in the electronic device 1 and various types of data, such as the code of the text error correction program 12, etc., but also can be used to temporarily store data that has been output or will be output.
  • the processor 10 may be composed of integrated circuits, for example, may be composed of a single packaged integrated circuit, or may be composed of multiple integrated circuits packaged with the same function or different functions, including one or more integrated circuits.
  • Central Processing Unit CPU
  • microprocessor digital processing chip
  • graphics processor and combination of various control chips, etc.
  • the processor 10 is the control core (Control Core) of the electronic device. Unit), using various interfaces and lines to connect various components of the entire electronic device, by running or executing programs or modules stored in the memory 11 (for example, executing text error correction programs, etc.), and calling the memory 11 to perform various functions of the electronic device 1 and process data.
  • the bus may be a peripheral component interconnect (PCI for short) bus or an extended industry standard structure (extended). industry standard architecture, referred to as EISA) bus, etc.
  • PCI peripheral component interconnect
  • EISA industry standard architecture
  • the bus can be divided into address bus, data bus, control bus and so on.
  • the bus is configured to implement connection communication between the memory 11 and at least one processor 10 and the like.
  • FIG. 3 only shows an electronic device with components. Those skilled in the art can understand that the structure shown in FIG. 3 does not constitute a limitation on the electronic device 1, and may include fewer or more components than those shown in the figure. components, or a combination of certain components, or a different arrangement of components.
  • the electronic device 1 may also include a power source (such as a battery) for powering the various components, preferably, the power source may be logically connected to the at least one processor 10 through a power management device, so that the power source can be managed by the power source.
  • the device implements functions such as charge management, discharge management, and power consumption management.
  • the power source may also include one or more DC or AC power sources, recharging devices, power failure detection circuits, power converters or inverters, power status indicators, and any other components.
  • the electronic device 1 may further include various sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be repeated here.
  • the electronic device 1 may also include a network interface, optionally, the network interface may include a wired interface and/or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is usually used in the electronic device 1 Establish a communication connection with other electronic devices.
  • a network interface optionally, the network interface may include a wired interface and/or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is usually used in the electronic device 1 Establish a communication connection with other electronic devices.
  • the electronic device 1 may further include a user interface, and the user interface may be a display (Display), an input unit (such as a keyboard (Keyboard)), optionally, the user interface may also be a standard wired interface or a wireless interface.
  • the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode, Organic Light Emitting Diode) Touch, etc.
  • the display may also be appropriately called a display screen or a display unit, which is used for displaying information processed in the electronic device 1 and for displaying a visualized user interface.
  • the text error correction program 12 stored in the memory 11 in the electronic device 1 is a combination of multiple computer programs. When running in the processor 10, it can realize:
  • the modules/units integrated in the electronic device 1 may be stored in a computer-readable storage medium.
  • the computer-readable storage medium may be volatile or non-volatile.
  • the computer-readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a removable hard disk, a magnetic disk, an optical disc, a computer memory, a read-only memory (ROM, Read-Only Memory) Memory).
  • the computer usable storage medium may mainly include a stored program area and a stored data area, wherein the stored program area may store an operating system, an application program required for at least one function, and the like; using the created data, etc.
  • the present application also provides a computer-readable storage medium, where the readable storage medium stores a computer program, and when executed by a processor of an electronic device, the computer program can realize:
  • modules described as separate components may or may not be physically separated, and components shown as modules may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution in this embodiment.
  • each functional module in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit.
  • the above-mentioned integrated units can be implemented in the form of hardware, or can be implemented in the form of hardware plus software function modules.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Data Mining & Analysis (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Evolutionary Computation (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Evolutionary Biology (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Databases & Information Systems (AREA)
  • Machine Translation (AREA)

Abstract

本申请涉及自然语言处理的技术领域,揭露了一种文本纠错方法,包括:分析文本中在每个字符位置上的扩展字及输出概率,得到扩展字集,判断句子中对应位置的字符是否为错别字;计算每个扩展字的替换概率,并根据替换概率筛选得到病句中每个字符对应的候选字集;将相邻字符对应的候选字集进行组合,得到字序列,当字序列标准词表中时,将字序列存储至词组集;利用词组集及候选字集,构建词网格,查询每条路径上的字词组合语句,选择最优语句,利用最优语句替换病句。本申请还涉及区块链技术,所述标准词表可存储于区块链节点中。本申请还提出了文本纠错装置、设备及计算机可读存储介质。本申请目的提供一种能够增加文本纠错结果的准确性的方法。

Description

文本纠错方法、装置、电子设备及存储介质
本申请要求于2021年2月19日提交中国专利局、申请号为CN202110189443.X、名称为“文本纠错方法、装置、电子设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及自然语言处理技术领域,尤其涉及一种文本纠错方法、装置、电子设备及计算机可读存储介质。
背景技术
文本纠错是指对文本中出现错误的内容进行纠正的过程。文本纠错处理在自然语言处理中占据越来越大的比重。
技术问题
近年来,有通过深度学习的方法来解决中文文本纠错问题,发明人意识到过程中需要语言学家参与制定人工定义的规则与混淆集,扩展性不高,常常只能处理单个字的错误,无法处理连在一起的字的错误。
技术解决方案
本申请提供的一种文本纠错方法,包括:
利用预先训练的字符扩展模型对用户输入的文本进行分析,得到所述文本中每个字符位置上的扩展字及各个扩展字的输出概率,根据所述输出概率对所述扩展字进行筛选,得到扩展字集,根据所述扩展字集,判断所述文本中对应位置的字符是否为错别字,并提取有错别字的句子,得到病句;
计算得到所述扩展字集中每个扩展字的替换概率,并根据所述替换概率从所述扩展字集中筛选得到所述病句中每个字符对应的候选字集;
将所述病句中相邻字符对应的候选字集进行组合,得到字序列,当所述字序列在预构建的标准词表中时,将所述字序列存储至预设的词组集中;
利用所述词组集及所述候选字集,构建词网格,查询所述词网格中每条路径上的字词组合语句,从所述字词组合语句中选择最优语句,利用所述最优语句替换所述病句。
本申请还提供一种文本纠错装置,所述装置包括:
病句判断模块,用于利用预先训练的字符扩展模型对用户输入的文本进行分析,得到所述文本中每个字符位置上的扩展字及各个扩展字的输出概率,根据所述输出概率对所述扩展字进行筛选,得到扩展字集,根据所述扩展字集,判断所述文本中对应位置的字符是否为错别字,并提取有错别字的句子,得到病句;
概率计算模块,用于计算得到所述扩展字集中每个扩展字的替换概率,并根据所述替换概率从所述扩展字集中筛选得到所述病句中每个字符对应的候选字集;
病句重组模块,用于将所述病句中相邻字符对应的候选字集进行组合,得到字序列,当所述字序列在预构建的标准词表中时,将所述字序列存储至预设的词组集中;
最优语句查询模块,用于利用所述词组集及所述候选字集,构建词网格,查询所述词网格中每条路径上的字词组合语句,从所述字词组合语句中选择最优语句,利用所述最优语句替换所述病句。
本申请还提供一种电子设备,所述电子设备包括:
至少一个处理器;以及,
与所述至少一个处理器通信连接的存储器;其中,
所述存储器存储有可被所述至少一个处理器执行的计算机程序指令,所述计算机程序指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行如下步骤:
利用预先训练的字符扩展模型对用户输入的文本进行分析,得到所述文本中每个字符位置上的扩展字及各个扩展字的输出概率,根据所述输出概率对所述扩展字进行筛选,得到扩展字集,根据所述扩展字集,判断所述文本中对应位置的字符是否为错别字,并提取有错别字的句子,得到病句;
计算得到所述扩展字集中每个扩展字的替换概率,并根据所述替换概率从所述扩展字集中筛选得到所述病句中每个字符对应的候选字集;
将所述病句中相邻字符对应的候选字集进行组合,得到字序列,当所述字序列在预构建的标准词表中时,将所述字序列存储至预设的词组集中;
利用所述词组集及所述候选字集,构建词网格,查询所述词网格中每条路径上的字词组合语句,从所述字词组合语句中选择最优语句,利用所述最优语句替换所述病句。
本申请还提供一种计算机可读存储介质,包括存储数据区和存储程序区,存储数据区存储创建的数据,存储程序区存储有计算机程序;其中,所述计算机程序被处理器执行时实现如下步骤:
利用预先训练的字符扩展模型对用户输入的文本进行分析,得到所述文本中每个字符位置上的扩展字及各个扩展字的输出概率,根据所述输出概率对所述扩展字进行筛选,得到扩展字集,根据所述扩展字集,判断所述文本中对应位置的字符是否为错别字,并提取有错别字的句子,得到病句;
计算得到所述扩展字集中每个扩展字的替换概率,并根据所述替换概率从所述扩展字集中筛选得到所述病句中每个字符对应的候选字集;
将所述病句中相邻字符对应的候选字集进行组合,得到字序列,当所述字序列在预构建的标准词表中时,将所述字序列存储至预设的词组集中;
利用所述词组集及所述候选字集,构建词网格,查询所述词网格中每条路径上的字词组合语句,从所述字词组合语句中选择最优语句,利用所述最优语句替换所述病句。
附图说明
图1为本申请一实施例提供的文本纠错方法的流程示意图;
图2为本申请一实施例提供的文本纠错装置的模块示意图;
图3为本申请一实施例提供的实现文本纠错方法的电子设备的内部结构示意图;
本申请目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。
本发明的实施方式
应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。
本申请实施例提供一种文本纠错方法。所述文本纠错方法的执行主体包括但不限于服务端、终端等能够被配置为执行本申请实施例提供的该方法的电子设备中的至少一种。换言之,所述文本纠错方法可以由安装在终端设备或服务端设备的软件或硬件来执行,所述软件可以是区块链平台。所述服务端包括但不限于:单台服务器、服务器集群、云端服务器或云端服务器集群等。
参照图1所示,为本申请一实施例提供的文本纠错方法的流程示意图。在本实施例中,所述文本纠错方法包括:
S1、利用预先训练的字符扩展模型对用户输入的文本进行分析,得到所述文本中在每个字符位置上的扩展字及各个扩展字的输出概率,根据所述输出概率对所述扩展字进行筛选,得到扩展字集,根据所述扩展字集,判断所述文本中对应位置的字符是否为错别字,并提取有错别字的句子,得到病句。
本申请实施例中所述字符扩展模型是一种根据句子前后语义判断所述句子中的字符还可以被哪些字符代替的神经网络模型。所述神经网络模型可以为Bert神经网络模型,其中,所述Bert神经网络为自然语言处理中常用的文字分类网络。本申请实施例利用中文训练集对Bert神经网络的微调,使得所述Bert神经网络更适合中文语义环境的处理,得到所述中文字符扩展模型。
详细地,本申请实施例中,所述利用预先训练的字符扩展模型对用户输入的文本进行分析,得到所述文本中每个字符位置上的扩展字及各个扩展字的输出概率,包括:
将所述文本中的每个句子拆分为单个字集合,依次提取所述单个字集合中的单个字;
利用所述字符扩展模型根据提取的所述单个字前后的剩余语句推断得到提取的所述单个字的替换结果,其中,所述替换结果包括扩展字及所述扩展字对应的输出概率。
例如,本申请实施例从句子“我家书柜倒了”中提取出“我”字作为单个字,则根据语句“()家书柜倒了”的剩余语句,可以判断出所述单个字的替换结果可以为“你,0.5”、“他,0.5”等,进一步地,提取出“柜”字作为单个字,则根据语句“我家书()倒了”的剩余语句,可以判断出所述单个字的替换结果可以为“架,0.3”、“房,0.6”、“签,0.5”等,得到替换结果为[“我”:“你,0.5”、“他,0.5”,……,“柜”:“架,0.3”、“房,0.6”、“签,0.5”……]。
详细地,本申请实施例中,所述根据所述输出概率对所述扩展字进行筛选,得到扩展字集,包括:
根据预设概率阈值,判断所述输出概率是否大于所述概率阈值;
保留大于所述概率阈值的输出概率对应的扩展字,构成扩展字集。
本申请实施例设置所述概率阈值为0.5,则筛选得到大概率的扩展字集为[“我”:“你,0.5”、“他,0.5”,……,“柜”:“房,0.6”、“签,0.5”……]。
进一步地,本申请实施例中,所述根据所述扩展字集,判断所述句子中对应位置的字符是否为错别字,包括:
判断所述句子中的字符是否在对应字符位置的扩展字集中;
当所述句子中的字在对应字符位置的扩展字集中时,判断所述字符不是错别字;
当所述句子中的字符不在对应字符位置的扩展字集中时,判断所述字符是错别字。
本申请实施例利用所述字符扩展模型分析所述用户输入的语句,根据指定位置的前后词义,判断所述指定位置可以有哪些字可以替换,得到候选字集,其中扩展字集中每一个扩展字有对应的输出概率,并按照所述输出概率排列所述扩展字,保留所述大概率的扩展字集,当指定位置上的字在所述大概率的扩展字集中,则不是错别字,反之,所述句子为病句。
进一步的,本申请实施例中,所述S1之前,还可以包括:
步骤I、构建包含层线性激活层及字符提取网络的字符扩展模型。
本申请构建线性激活层帮助所述符扩展模型进行模型训练,其中所述线性激活层包括归一化和激活函数,所述激活函数可使用高斯分布函数。
步骤II、获取预构建的分词样本集及训练标签集,并利用所述字符提取网络对所述分词样本集进行文本提取,得到特征序列训练集。
本申请实施例中,所述分词样本集及所述训练标签集为国际计算语言学会(ACL)汉语小组(SIGHAN)提供的训练集,其中包含了各种常见有替换关系的中文字词。其中,字符的替换关系有形近替换及音近替换两种形式,例如“午”可以形近替换为“牛”,“贵”可音近替换为“柜”。本申请实施例中所述训练序列训练集为:“我们家书贵到了”,其中所述训练标签集为:“贵”字应为“柜”字。
步骤III、利用所述多层线性激活层对所述特征序列训练集执行激活操作,得到预测序列集。
根据所述多层线性激活层将“我”字替换为[我,哦……],“们”字替换为[门,俩……],……“贵”替换为[柜,跪……]等。得到的所述预测序列集为[我们家书柜到了,我门家属贵到了、哦俩嫁树跪到子……]。
步骤IV、根据所述训练标签集计算计算所述预测序列集的误差值,并判断所述误差值与预设的误差阈值的大小关系;
步骤V若所述误差值大于所述误差阈值,则调整所述待训练字符扩展模型的内部参数,并返回所述步骤II,直到所述误差值小于或等于所述误差阈值时,得到训练完成的字符扩展模型。
S2、计算得到所述扩展字集中每个扩展字的替换概率,并根据所述替换概率从所述扩展字集中筛选得到所述病句中每个字符对应的候选字集。
详细地,本申请实施例中,所述S2,包括:
利用编辑距离算法,计算所述扩展字集与所述病句中对应字符之间的形近概率及音近概率,根据所述输出概率、所述形近概率及所述音近概率计算得到所述扩展字的替换概率:
根据所述替换概率的大小及预设阈值,筛选所述替换概率大于所述预设阈值的扩展字,得到所述病句中每个字符对应的候选字集。
本申请实施例中所述替换概率等于【输出概率+音近概率+形近概率】。其中所述音近概率及所述形近概率可通过编辑距离计算得到。其中,所述编辑距离也叫莱文斯坦距离(Levenshtein),所述编辑距离算法是针对二个字符串(例如英文字)的差异程度的量化量测。所述形近概率将所述候选字的笔画进行拆分量化,而音近概率是将所述候选字的拼音拆分量化。例如“田”与“由”,“午”与“牛”具有相同的笔画及笔画顺序,因此,形近概率较大,“式”与“试”具有相同的拼音,因此音近概率较大。
本申请实施例根据所述替换概率从大到小的顺序对所述扩展字集进行排序,得到预设数量的候选字集。
S3、将所述病句中相邻字符对应的候选字集进行组合,得到字序列,当所述字序列在预构建的标准词表中时,将所述字序列存储至预设的词组集中。
本申请实施例根据所述病句“我们家书柜到了”中,“我”的候选字集为[我,哦……],“们”的候选字集为[门,俩……],“家”的候选字集为[佳,嫁……]等,彼此匹配得到[我们、哦门、门家、家书、书柜、树贵……]的字序列,其中能够在预构建的标准词表中查询得到的词组集为[我们,家书,书柜,跪到……]。
本申请实施例中,所述标准词表可以为一种由国际计算语言学会(ACL)汉语小组(SIGHAN)提供的包含近义词、反义词、常用词、流行语等语料的词表。本申请其中一个实施例中,所述标准词表可以存储于区块链节点中。
S4、利用所述词组集及所述候选字集,构建词网格,查询所述词网格中每条路径上的字词组合语句,从所述字词组合语句中选择最优语句,利用所述最优语句替换所述病句。
详细地,本申请实施例中,所述S4,包括:
根据所述病句中各个字符的顺序,将每个字符对应的词组集及替换候选字集作为节点,并连接所述节点中的相邻节点,得到词网格;
将所述词网格中各个路径上的节点进行顺序排列,得到字词组合语句;
利用预构建的查询工具,分析所述字词组合语句的通顺度及语意,对比查询所述字词组合语句中的最优语句。
本申请实施例中,根据所述病句中各字的位置进行排列,再将各个词组集及候选字集构建词网格,沿着所述词网格的连接路线,构建字词组合语句,得到所述字词组合语句集合,利用预构建的查询工具beam search搜索所述字词组合语句集合中的每个字词组合语句,得到最优解的字词组合语句即所述改正句子。
本申请实施例利用预训练的字符扩展模型,通过判断出文本中每个字符位置上的扩展字,能够判断所述文本中的病句;将病句中各字符位置上的候选字集进行组合匹配,得到词组,可以将字与字之间进行连接,得到词组集;根据词组集合重新进行语句划分,得到各个版本的语句集合,将病句拆分出多种解读方式,涵盖各种错误可能,利用预构建的查询工具,从所述语句集合中查询最优解,得到改正句子,增加解读效率及准确性。
如图2所示,是本申请文本纠错装置的模块示意图。
本申请所述文本纠错装置100可以安装于电子设备中。根据实现的功能,所述文本纠错装置100可以被划分为病句判断模块101、概率计算模块102、病句重组模块103、最优语句查询模块104。本申请所述模块也可以称之为单元,是指一种能够被电子设备处理器所执行,并且能够完成固定功能的一系列计算机程序段,其存储在电子设备的存储器中。
在本实施例中,关于各模块/单元的功能如下:
所述病句判断模块101,用于利用预先训练的字符扩展模型对用户输入的文本进行分析,得到所述文本中每个字符位置上的扩展字及各个扩展字的输出概率,根据所述输出概率对所述扩展字进行筛选,得到扩展字集,根据所述扩展字集,判断所述文本中对应位置的字符是否为错别字,并提取有错别字的句子,得到病句;
所述概率计算模块102,用于计算得到所述扩展字集中每个扩展字的替换概率,并根据所述替换概率从所述扩展字集中筛选得到所述病句中每个字符对应的候选字集;
所述病句重组模块103,用于将所述病句中相邻字符对应的候选字集进行组合,得到字序列,当所述字序列在预构建的标准词表中时,将所述字序列存储至预设的词组集中;
所述最优语句查询模块104,用于利用所述词组集及所述候选字集,构建词网格,查询所述词网格中每条路径上的字词组合语句,从所述字词组合语句中选择最优语句,利用所述最优语句替换所述病句。
本申请实施例中,所述文本纠错装置100中的各个模块在由电子设备的处理器所执行时,可以实现如上述图1所述的文本纠错方法,并产生相同的效果,这里不再赘述。
如图3所示,是本申请实现文本纠错方法的电子设备的结构示意图。
所述电子设备1可以包括处理器10、存储器11和总线,还可以包括存储在所述存储器11中并可在所述处理器10上运行的计算机程序,如文本纠错程序12。
其中,所述存储器11至少包括一种类型的可读存储介质,所述可读存储介质包括闪存、移动硬盘、多媒体卡、卡型存储器(例如:SD或DX存储器等)、磁性存储器、磁盘、光盘等。所述存储器11在一些实施例中可以是电子设备1的内部存储单元,例如该电子设备1的移动硬盘。所述存储器11在另一些实施例中也可以是电子设备1的外部存储设备,例如电子设备1上配备的插接式移动硬盘、智能存储卡(Smart Media Card, SMC)、安全数字(Secure Digital, SD)卡、闪存卡(Flash Card)等。进一步地,所述存储器11还可以既包括电子设备1的内部存储单元也包括外部存储设备。所述存储器11不仅可以用于存储安装于电子设备1的应用软件及各类数据,例如文本纠错程序12的代码等,还可以用于暂时地存储已经输出或者将要输出的数据。
所述处理器10在一些实施例中可以由集成电路组成,例如可以由单个封装的集成电路所组成,也可以是由多个相同功能或不同功能封装的集成电路所组成,包括一个或者多个中央处理器(Central Processing unit,CPU)、微处理器、数字处理芯片、图形处理器及各种控制芯片的组合等。所述处理器10是所述电子设备的控制核心(Control Unit),利用各种接口和线路连接整个电子设备的各个部件,通过运行或执行存储在所述存储器11内的程序或者模块(例如执行文本纠错程序等),以及调用存储在所述存储器11内的数据,以执行电子设备1的各种功能和处理数据。
所述总线可以是外设部件互连标准(peripheral component interconnect,简称PCI)总线或扩展工业标准结构(extended industry standard architecture,简称EISA)总线等。该总线可以分为地址总线、数据总线、控制总线等。所述总线被设置为实现所述存储器11以及至少一个处理器10等之间的连接通信。
图3仅示出了具有部件的电子设备,本领域技术人员可以理解的是,图3示出的结构并不构成对所述电子设备1的限定,可以包括比图示更少或者更多的部件,或者组合某些部件,或者不同的部件布置。
例如,尽管未示出,所述电子设备1还可以包括给各个部件供电的电源(比如电池),优选地,电源可以通过电源管理装置与所述至少一个处理器10逻辑相连,从而通过电源管理装置实现充电管理、放电管理、以及功耗管理等功能。电源还可以包括一个或一个以上的直流或交流电源、再充电装置、电源故障检测电路、电源转换器或者逆变器、电源状态指示器等任意组件。所述电子设备1还可以包括多种传感器、蓝牙模块、Wi-Fi模块等,在此不再赘述。
进一步地,所述电子设备1还可以包括网络接口,可选地,所述网络接口可以包括有线接口和/或无线接口(如WI-FI接口、蓝牙接口等),通常用于在该电子设备1与其他电子设备之间建立通信连接。
可选地,该电子设备1还可以包括用户接口,用户接口可以是显示器(Display)、输入单元(比如键盘(Keyboard)),可选地,用户接口还可以是标准的有线接口、无线接口。可选地,在一些实施例中,显示器可以是LED显示器、液晶显示器、触控式液晶显示器以及OLED(Organic Light-Emitting Diode,有机发光二极管)触摸器等。其中,显示器也可以适当的称为显示屏或显示单元,用于显示在电子设备1中处理的信息以及用于显示可视化的用户界面。
应该了解,所述实施例仅为说明之用,在专利申请范围上并不受此结构的限制。
所述电子设备1中的所述存储器11存储的文本纠错程序12是多个计算机程序的组合,在所述处理器10中运行时,可以实现:
利用预先训练的字符扩展模型对用户输入的文本进行分析,得到所述文本中每个字符位置上的扩展字及各个扩展字的输出概率,根据所述输出概率对所述扩展字进行筛选,得到扩展字集,根据所述扩展字集,判断所述句子中对应位置的字符是否为错别字,并提取有错别字的句子,得到病句;
计算得到所述扩展字集中每个扩展字的替换概率,并根据所述替换概率从所述扩展字集中筛选得到所述病句中每个字符对应的候选字集;
将所述病句中相邻字符对应的候选字集进行组合,得到字序列,当所述字序列在预构建的标准词表中时,将所述字序列存储至预设的词组集中;
利用所述词组集及所述候选字集,构建词网格,查询所述词网格中每条路径上的字词组合语句,从所述字词组合语句中选择最优语句,利用所述最优语句替换所述病句。
进一步地,所述电子设备1集成的模块/单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。所述计算机可读存储介质可以是易失性的,也可以是非易失性的。例如,所述计算机可读介质可以包括:能够携带所述计算机程序代码的任何实体或装置、记录介质、U盘、移动硬盘、磁碟、光盘、计算机存储器、只读存储器(ROM,Read-Only Memory)。
进一步地,所述计算机可用存储介质可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的应用程序等;存储数据区可存储根据区块链节点的使用所创建的数据等。
本申请还提供一种计算机可读存储介质,所述可读存储介质存储有计算机程序,所述计算机程序在被电子设备的处理器所执行时,可以实现:
利用预先训练的字符扩展模型对用户输入的文本进行分析,得到所述文本中每个字符位置上的扩展字及各个扩展字的输出概率,根据所述输出概率对所述扩展字进行筛选,得到扩展字集,根据所述扩展字集,判断所述句子中对应位置的字符是否为错别字,并提取有错别字的句子,得到病句;
计算得到所述扩展字集中每个扩展字的替换概率,并根据所述替换概率从所述扩展字集中筛选得到所述病句中每个字符对应的候选字集;
将所述病句中相邻字符对应的候选字集进行组合,得到字序列,当所述字序列在预构建的标准词表中时,将所述字序列存储至预设的词组集中;
利用所述词组集及所述候选字集,构建词网格,查询所述词网格中每条路径上的字词组合语句,从所述字词组合语句中选择最优语句,利用所述最优语句替换所述病句。
在本申请所提供的几个实施例中,应该理解到,所揭露的设备,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述模块的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。
所述作为分离部件说明的模块可以是或者也可以不是物理上分开的,作为模块显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能模块可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用硬件加软件功能模块的形式实现。
对于本领域技术人员而言,显然本申请不限于上述示范性实施例的细节,而且在不背离本申请的精神或基本特征的情况下,能够以其他的具体形式实现本申请。
因此,无论从哪一点来看,均应将实施例看作是示范性的,而且是非限制性的,本申请的范围由所附权利要求而不是上述说明限定,因此旨在将落在权利要求的等同要件的含义和范围内的所有变化涵括在本申请内。不应将权利要求中的任何附关联图表记视为限制所涉及的权利要求。
此外,显然“包括”一词不排除其他单元或步骤,单数不排除复数。系统权利要求中陈述的多个单元或装置也可以由一个单元或装置通过软件或者硬件来实现。第二等词语用来表示名称,而并不表示任何特定的顺序。
最后应说明的是,以上实施例仅用以说明本申请的技术方案而非限制,尽管参照较佳实施例对本申请进行了详细说明,本领域的普通技术人员应当理解,可以对本申请的技术方案进行修改或等同替换,而不脱离本申请技术方案的精神和范围。

Claims (20)

  1. 一种文本纠错方法,其中,所述方法包括:
    利用预先训练的字符扩展模型对用户输入的文本进行分析,得到所述文本中每个字符位置上的扩展字及各个扩展字的输出概率,根据所述输出概率对所述扩展字进行筛选,得到扩展字集,根据所述扩展字集,判断所述文本中对应位置的字符是否为错别字,并提取有错别字的句子,得到病句;
    计算得到所述扩展字集中每个扩展字的替换概率,并根据所述替换概率从所述扩展字集中筛选得到所述病句中每个字符对应的候选字集;
    将所述病句中相邻字符对应的候选字集进行组合,得到字序列,当所述字序列在预构建的标准词表中时,将所述字序列存储至预设的词组集中;
    利用所述词组集及所述候选字集,构建词网格,查询所述词网格中每条路径上的字词组合语句,从所述字词组合语句中选择最优语句,利用所述最优语句替换所述病句。
  2. 如权利要求1所述的文本纠错方法,其中,所述利用预先训练的字符扩展模型对用户输入的文本进行分析,得到所述文本中在每个字符位置上的扩展字及各个扩展字的输出概率之前,所述方法还包括:
    步骤I、构建包含层线性激活层及字符提取网络的字符扩展模型;
    步骤II、获取预构建的分词样本集及训练标签集,并利用所述字符提取网络对所述分词样本集进行文本提取,得到特征序列训练集;
    步骤III、利用所述多层线性激活层对所述特征序列训练集执行激活操作,得到预测序列集;
    步骤IV、根据所述训练标签集计算所述预测序列集的误差值,并判断所述误差值与预设的误差阈值的大小关系;
    步骤V、若所述误差值大于所述误差阈值,则调整所述待训练字符扩展模型的内部参数,并返回所述步骤II,直到所述误差值小于或等于所述误差阈值时,得到训练完成的字符扩展模型。
  3. 如权利要求1所述的文本纠错方法,其中,所述利用预先训练的字符扩展模型对用户输入的文本进行分析,得到所述文本中每个字符位置上的扩展字及各个扩展字的输出概率,包括:
    将所述文本中每个句子拆分为单个字集合,依次提取所述单个字集合中的单个字;
    利用所述字符扩展模型根据提取的所述单个字前后的剩余语句推断得到提取的所述单个字的替换结果,其中,所述替换结果包括扩展字及所述扩展字对应的输出概率。
  4. 如权利要求1所述的文本纠错方法,其中,所述根据所述输出概率对所述扩展字进行筛选,得到扩展字集,包括:
    根据预设概率阈值,判断所述输出概率是否大于所述概率阈值;
    保留大于所述概率阈值的输出概率对应的扩展字,构成扩展字集。
  5. 如权利要求1至4中任意一项所述的文本纠错方法,其中,所述根据所述扩展字集,判断所述文本中对应位置的字符是否为错别字,包括:
    判断所述句子中的字符是否在对应字符位置的扩展字集中;
    当所述句子中的字在对应字符位置的扩展字集中时,判断所述字符不是错别字;
    当所述句子中的字符不在对应字符位置的扩展字集中时,判断所述字符是错别字。
  6. 如权利要求1至4中任意一项所述的文本纠错方法,其中,所述计算得到所述扩展字集中每个扩展字的替换概率,并根据所述替换概率从所述扩展字集中筛选得到所述病句中每个字符对应的候选字集,包括:
    利用编辑距离算法,计算所述扩展字与所述病句中对应字符之间的形近概率及音近概率,根据所述输出概率、所述形近概率及所述音近概率计算得到所述扩展字的替换概率:
    根据所述替换概率的大小及预设阈值,筛选所述替换概率大于所述预设阈值的扩展字,得到所述病句中每个字符对应的候选字集。
  7. 如权利要求1至4中任意一项所述的文本纠错方法,其中,所述利用所述词组集及所述候选字集,构建词网格,查询所述词网格中每条路径上的字词组合语句,从所述字词组合语句中选择最优语句,包括:
    根据所述病句中各个字符的顺序,将每个字符对应的词组集及替换候选字集作为节点,并连接所述节点中的相邻节点,得到词网格;
    将所述词网格中各个路径上的节点进行顺序排列,得到字词组合语句;
    利用预构建的查询工具,分析所述字词组合语句的通顺度及语意,对比查询所述字词组合语句中的最优语句。
  8. 一种文本纠错装置,其中,所述装置包括:
    病句判断模块,用于利用预先训练的字符扩展模型对用户输入的文本进行分析,得到所述文本中每个字符位置上的扩展字及各个扩展字的输出概率,根据所述输出概率对所述扩展字进行筛选,得到扩展字集,根据所述扩展字集,判断所述文本中对应位置的字符是否为错别字,并提取有错别字的句子,得到病句;
    概率计算模块,用于计算得到所述扩展字集中每个扩展字的替换概率,并根据所述替换概率从所述扩展字集中筛选得到所述病句中每个字符对应的候选字集;
    病句重组模块,用于将所述病句中相邻字符对应的候选字集进行组合,得到字序列,当所述字序列在预构建的标准词表中时,将所述字序列存储至预设的词组集中;
    最优语句查询模块,用于利用所述词组集及所述候选字集,构建词网格,查询所述词网格中每条路径上的字词组合语句,从所述字词组合语句中选择最优语句,利用所述最优语句替换所述病句。
  9. 一种电子设备,其中,所述电子设备包括:
    至少一个处理器;以及,
    与所述至少一个处理器通信连接的存储器;其中,
    所述存储器存储有可被所述至少一个处理器执行的计算机程序指令,所述计算机程序指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行如下步骤:
    利用预先训练的字符扩展模型对用户输入的文本进行分析,得到所述文本中每个字符位置上的扩展字及各个扩展字的输出概率,根据所述输出概率对所述扩展字进行筛选,得到扩展字集,根据所述扩展字集,判断所述文本中对应位置的字符是否为错别字,并提取有错别字的句子,得到病句;
    计算得到所述扩展字集中每个扩展字的替换概率,并根据所述替换概率从所述扩展字集中筛选得到所述病句中每个字符对应的候选字集;
    将所述病句中相邻字符对应的候选字集进行组合,得到字序列,当所述字序列在预构建的标准词表中时,将所述字序列存储至预设的词组集中;
    利用所述词组集及所述候选字集,构建词网格,查询所述词网格中每条路径上的字词组合语句,从所述字词组合语句中选择最优语句,利用所述最优语句替换所述病句。
  10. 如权利要求9所述的电子设备,其中,所述利用预先训练的字符扩展模型对用户输入的文本进行分析,得到所述文本中在每个字符位置上的扩展字及各个扩展字的输出概率之前,所述计算机程序指令被所述至少一个处理器执行时还实现如下步骤:
    步骤I、构建包含层线性激活层及字符提取网络的字符扩展模型;
    步骤II、获取预构建的分词样本集及训练标签集,并利用所述字符提取网络对所述分词样本集进行文本提取,得到特征序列训练集;
    步骤III、利用所述多层线性激活层对所述特征序列训练集执行激活操作,得到预测序列集;
    步骤IV、根据所述训练标签集计算所述预测序列集的误差值,并判断所述误差值与预设的误差阈值的大小关系;
    步骤V、若所述误差值大于所述误差阈值,则调整所述待训练字符扩展模型的内部参数,并返回所述步骤II,直到所述误差值小于或等于所述误差阈值时,得到训练完成的字符扩展模型。
  11. 如权利要求9所述的电子设备,其中,所述利用预先训练的字符扩展模型对用户输入的文本进行分析,得到所述文本中每个字符位置上的扩展字及各个扩展字的输出概率,包括:
    将所述文本中每个句子拆分为单个字集合,依次提取所述单个字集合中的单个字;
    利用所述字符扩展模型根据提取的所述单个字前后的剩余语句推断得到提取的所述单个字的替换结果,其中,所述替换结果包括扩展字及所述扩展字对应的输出概率。
  12. 如权利要求9所述的电子设备,其中,所述根据所述输出概率对所述扩展字进行筛选,得到扩展字集,包括:
    根据预设概率阈值,判断所述输出概率是否大于所述概率阈值;
    保留大于所述概率阈值的输出概率对应的扩展字,构成扩展字集。
  13. 如权利要求9至12中任意一项所述的电子设备,其中,所述根据所述扩展字集,判断所述文本中对应位置的字符是否为错别字,包括:
    判断所述句子中的字符是否在对应字符位置的扩展字集中;
    当所述句子中的字在对应字符位置的扩展字集中时,判断所述字符不是错别字;
    当所述句子中的字符不在对应字符位置的扩展字集中时,判断所述字符是错别字。
  14. 如权利要求9至12中任意一项所述的电子设备,其中,所述计算得到所述扩展字集中每个扩展字的替换概率,并根据所述替换概率从所述扩展字集中筛选得到所述病句中每个字符对应的候选字集,包括:
    利用编辑距离算法,计算所述扩展字与所述病句中对应字符之间的形近概率及音近概率,根据所述输出概率、所述形近概率及所述音近概率计算得到所述扩展字的替换概率:
    根据所述替换概率的大小及预设阈值,筛选所述替换概率大于所述预设阈值的扩展字,得到所述病句中每个字符对应的候选字集。
  15. 如权利要求9至12中任意一项所述的电子设备,其中,所述利用所述词组集及所述候选字集,构建词网格,查询所述词网格中每条路径上的字词组合语句,从所述字词组合语句中选择最优语句,包括:
    根据所述病句中各个字符的顺序,将每个字符对应的词组集及替换候选字集作为节点,并连接所述节点中的相邻节点,得到词网格;
    将所述词网格中各个路径上的节点进行顺序排列,得到字词组合语句;
    利用预构建的查询工具,分析所述字词组合语句的通顺度及语意,对比查询所述字词组合语句中的最优语句。
  16. 一种计算机可读存储介质,包括存储数据区和存储程序区,存储数据区存储创建的数据,存储程序区存储有计算机程序;其中,所述计算机程序被处理器执行时实现如下步骤:
    利用预先训练的字符扩展模型对用户输入的文本进行分析,得到所述文本中每个字符位置上的扩展字及各个扩展字的输出概率,根据所述输出概率对所述扩展字进行筛选,得到扩展字集,根据所述扩展字集,判断所述文本中对应位置的字符是否为错别字,并提取有错别字的句子,得到病句;
    计算得到所述扩展字集中每个扩展字的替换概率,并根据所述替换概率从所述扩展字集中筛选得到所述病句中每个字符对应的候选字集;
    将所述病句中相邻字符对应的候选字集进行组合,得到字序列,当所述字序列在预构建的标准词表中时,将所述字序列存储至预设的词组集中;
    利用所述词组集及所述候选字集,构建词网格,查询所述词网格中每条路径上的字词组合语句,从所述字词组合语句中选择最优语句,利用所述最优语句替换所述病句。
  17. 如权利要求16所述的计算机可读存储介质,其中,所述利用预先训练的字符扩展模型对用户输入的文本进行分析,得到所述文本中在每个字符位置上的扩展字及各个扩展字的输出概率之前,所述计算机程序被处理器执行时还实现如下步骤:
    步骤I、构建包含层线性激活层及字符提取网络的字符扩展模型;
    步骤II、获取预构建的分词样本集及训练标签集,并利用所述字符提取网络对所述分词样本集进行文本提取,得到特征序列训练集;
    步骤III、利用所述多层线性激活层对所述特征序列训练集执行激活操作,得到预测序列集;
    步骤IV、根据所述训练标签集计算所述预测序列集的误差值,并判断所述误差值与预设的误差阈值的大小关系;
    步骤V、若所述误差值大于所述误差阈值,则调整所述待训练字符扩展模型的内部参数,并返回所述步骤II,直到所述误差值小于或等于所述误差阈值时,得到训练完成的字符扩展模型。
  18. 如权利要求16所述的计算机可读存储介质,其中,所述利用预先训练的字符扩展模型对用户输入的文本进行分析,得到所述文本中每个字符位置上的扩展字及各个扩展字的输出概率,包括:
    将所述文本中每个句子拆分为单个字集合,依次提取所述单个字集合中的单个字;
    利用所述字符扩展模型根据提取的所述单个字前后的剩余语句推断得到提取的所述单个字的替换结果,其中,所述替换结果包括扩展字及所述扩展字对应的输出概率。
  19. 如权利要求16所述的计算机可读存储介质,其中,所述根据所述输出概率对所述扩展字进行筛选,得到扩展字集,包括:
    根据预设概率阈值,判断所述输出概率是否大于所述概率阈值;
    保留大于所述概率阈值的输出概率对应的扩展字,构成扩展字集。
  20. 如权利要求16至19中任意一项所述的计算机可读存储介质,其中,所述根据所述扩展字集,判断所述文本中对应位置的字符是否为错别字,包括:
    判断所述句子中的字符是否在对应字符位置的扩展字集中;
    当所述句子中的字在对应字符位置的扩展字集中时,判断所述字符不是错别字;
    当所述句子中的字符不在对应字符位置的扩展字集中时,判断所述字符是错别字。
PCT/CN2021/083709 2021-02-19 2021-03-30 文本纠错方法、装置、电子设备及存储介质 WO2022174495A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110189443.XA CN112988962B (zh) 2021-02-19 2021-02-19 文本纠错方法、装置、电子设备及存储介质
CN202110189443.X 2021-02-19

Publications (1)

Publication Number Publication Date
WO2022174495A1 true WO2022174495A1 (zh) 2022-08-25

Family

ID=76393474

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/083709 WO2022174495A1 (zh) 2021-02-19 2021-03-30 文本纠错方法、装置、电子设备及存储介质

Country Status (2)

Country Link
CN (1) CN112988962B (zh)
WO (1) WO2022174495A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116306612A (zh) * 2021-12-21 2023-06-23 华为技术有限公司 一种词句生成方法及相关设备

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190102373A1 (en) * 2013-01-29 2019-04-04 Tencent Technology (Shenzhen) Company Limited Model-based automatic correction of typographical errors
CN111639489A (zh) * 2020-05-15 2020-09-08 民生科技有限责任公司 中文文本纠错系统、方法、装置及计算机可读存储介质
CN111832278A (zh) * 2020-06-15 2020-10-27 北京百度网讯科技有限公司 文档流畅度的检测方法、装置、电子设备及介质
CN112101010A (zh) * 2020-11-23 2020-12-18 中博信息技术研究院有限公司 一种基于bert的电信行业oa办公自动化文稿审核的方法

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6401060B1 (en) * 1998-06-25 2002-06-04 Microsoft Corporation Method for typographical detection and replacement in Japanese text
CN110262672B (zh) * 2019-06-18 2023-08-08 抖音视界有限公司 建议候选列表生成方法及装置
CN110807319B (zh) * 2019-10-31 2023-07-25 北京奇艺世纪科技有限公司 一种文本内容检测方法、检测装置、电子设备及存储介质
CN111611791B (zh) * 2020-04-27 2023-08-25 鼎富智能科技有限公司 一种文本处理的方法及相关装置
CN112016304A (zh) * 2020-09-03 2020-12-01 平安科技(深圳)有限公司 文本纠错方法、装置、电子设备及存储介质
CN112100388B (zh) * 2020-11-18 2021-02-23 南京华苏科技有限公司 一种长文本新闻舆情的情感极性的分析方法

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190102373A1 (en) * 2013-01-29 2019-04-04 Tencent Technology (Shenzhen) Company Limited Model-based automatic correction of typographical errors
CN111639489A (zh) * 2020-05-15 2020-09-08 民生科技有限责任公司 中文文本纠错系统、方法、装置及计算机可读存储介质
CN111832278A (zh) * 2020-06-15 2020-10-27 北京百度网讯科技有限公司 文档流畅度的检测方法、装置、电子设备及介质
CN112101010A (zh) * 2020-11-23 2020-12-18 中博信息技术研究院有限公司 一种基于bert的电信行业oa办公自动化文稿审核的方法

Also Published As

Publication number Publication date
CN112988962B (zh) 2024-05-28
CN112988962A (zh) 2021-06-18

Similar Documents

Publication Publication Date Title
WO2020119075A1 (zh) 通用文本信息提取方法、装置、计算机设备和存储介质
CN103970798B (zh) 数据的搜索和匹配
KR102268875B1 (ko) 전자 장치에 텍스트를 입력하는 시스템 및 방법
US9720903B2 (en) Method for parsing natural language text with simple links
US8239188B2 (en) Example based translation apparatus, translation method, and translation program
CN112016304A (zh) 文本纠错方法、装置、电子设备及存储介质
JP2001523019A (ja) テキストの本文の談話構造の自動認識
US8239349B2 (en) Extracting data
TW201841121A (zh) 一種自動生成語義相近句子樣本的方法
WO2022222300A1 (zh) 开放关系抽取方法、装置、电子设备及存储介质
US20160188569A1 (en) Generating a Table of Contents for Unformatted Text
WO2022134355A1 (zh) 基于关键词提示的检索方法、装置、电子设备及存储介质
CN104391837A (zh) 一种基于格语义的智能语法分析方法
Foster Treebanks gone bad: Parser evaluation and retraining using a treebank of ungrammatical sentences
US10810368B2 (en) Method for parsing natural language text with constituent construction links
Carter et al. Syntactic discriminative language model rerankers for statistical machine translation
WO2022174495A1 (zh) 文本纠错方法、装置、电子设备及存储介质
US9495638B2 (en) Scalable, rule-based processing
US20170286394A1 (en) Method for parsing natural language text with constituent construction links
US20200097549A1 (en) Semantic processing method, electronic device, and non-transitory computer readable recording medium
JP6168057B2 (ja) 不具合発生原因抽出装置、不具合発生原因抽出方法および不具合発生原因抽出プログラム
CN111898762B (zh) 深度学习模型目录创建
US20180011833A1 (en) Syntax analyzing device, learning device, machine translation device and storage medium
KR20220113075A (ko) 한국어 명사 추출 토크나이저 기반의 워드클라우드 시스템
JP3919720B2 (ja) 換言装置及びコンピュータプログラム

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21926212

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21926212

Country of ref document: EP

Kind code of ref document: A1