Text processing method and device, equipment, medium and program product
By classifying text and extracting amounts of different types of texts, combined with tree-shaped amount dictionary and standardized processing, the problem of difficulty in handling complex text data in the existing technology is solved, and the efficiency and flexibility of extracting amounts are improved.
Patent Information
- Application Number
- CN202411738818.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-29
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2044-11-29
AI Technical Summary
The existing text amount conversion technology is difficult to adapt to text data with complex structures and irregular formats, resulting in slow processing speed and affecting the performance of hardware devices.
By obtaining and classifying pending text, rules and irregular texts are processed using different amount text extraction methods. For standard text, a pre-established tree-shaped amount dictionary is used for string segmentation; for non-standard text, normalization is performed to obtain the amount number.
It improves the efficiency, accuracy and flexibility of text amount extraction, can process text data in various complex scenarios, and is suitable for a variety of data sources.
Smart Images

Figure CN119646222A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of big data technology, and in particular to a text processing method, device, equipment, medium and program product. Background Art
[0002] In today's digital age, the demand for automation of financial transactions and data processing is growing. The technology of converting text amounts into Arabic numerals is particularly important in this context. Automatically converting text amounts into Arabic numerals can not only improve the efficiency of data processing, but also reduce the error rate of manual operations.
[0003] Existing text amount conversion technology mainly relies on the method of parsing the elements in the digital string one by one. This method is usually only applicable to text data with relatively simple structure and standardized format, such as text directly containing Arabic numerals or simple Chinese numerical expressions. However, with the popularization of e-commerce and online financial services, there are more and more types of data sources that need to extract amount numbers, such as web pages, log files and messages of financial systems. Existing methods cannot adapt to texts with complex structures and irregular formats. In addition, this method that relies on parsing the elements in the digital string one by one will result in slow processing speed when faced with the need to convert large-scale amount text into digital amounts, affecting the performance of hardware devices. Summary of the invention
[0004] The embodiments of the present invention provide a text processing method, apparatus, device, medium and program product, which can better process various irregular texts, effectively identify and process the amount text of various scenario data, and improve the efficiency, accuracy and flexibility of determining the amount digits of the text amount.
[0005] In a first aspect, an embodiment of the present invention provides a text processing method, comprising:
[0006] Acquire a text to be processed, and classify the text to be processed to obtain a text type of the text to be processed; the text type is regular text or irregular text;
[0007] Extracting the amount text from the text to be processed according to the text type to obtain at least one amount text of the text to be processed;
[0008] For each amount text of the at least one amount text, a standard detection is performed on the current amount text based on a preset standard detection rule to obtain a standard detection result of the current amount text; wherein the standard detection result is a standard text or a non-standard text;
[0009] If the current amount text is the standard text, the text string of the current amount text is segmented according to the pre-established tree-shaped amount dictionary to obtain each segmentation string corresponding to the text string, and the amount number corresponding to the current amount text is obtained based on each segmentation string;
[0010] If the current amount text is the non-standard text, the current amount text is normalized based on the standard detection result, and the amount number corresponding to the current amount text is obtained based on the normalization result.
[0011] In a second aspect, an embodiment of the present invention further provides a text processing device, the device comprising:
[0012] A text acquisition module is used to acquire the text to be processed and classify the text to be processed to obtain the text type of the text to be processed; the text type is regular text or irregular text;
[0013] A text extraction module, used for extracting the amount text from the text to be processed according to the text type, to obtain at least one amount text of the text to be processed;
[0014] A text detection module, for performing a standard detection on the current amount text based on a preset standard detection rule for each amount text of the at least one amount text, to obtain a standard detection result of the current amount text; wherein the standard detection result is a standard text or a non-standard text;
[0015] A text segmentation module is used for, if the current amount text is the standard text, segmenting the text string of the current amount text according to a pre-established tree-shaped amount dictionary to obtain each segmentation string corresponding to the text string, and obtaining the amount number corresponding to the current amount text based on each segmentation string;
[0016] The text processing module is used to normalize the current amount text based on the standard detection result if the current amount text is the non-standard text, and obtain the amount number corresponding to the current amount text based on the normalization processing result.
[0017] In a third aspect, an embodiment of the present invention further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, a text processing method as described in any one of the embodiments of the present invention is implemented.
[0018] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a text processing method as described in any one of the embodiments of the present invention.
[0019] In a fifth aspect, an embodiment of the present invention further provides a computer program product, including a computer program, which, when executed by a processor, implements a text processing method as described in any one of the embodiments of the present invention.
[0020] In the embodiment of the present invention, by adopting different amount text extraction methods for different types of text, it is possible to process text data generated in various complex scenarios, thereby improving the applicability and flexibility of amount text extraction. After the amount text is extracted, for the standardized amount text, a tree-shaped amount dictionary is used to quickly perform character string segmentation and conversion, thereby improving the efficiency of determining the amount digit. For the non-standard amount text, it can be normalized to obtain the correct amount digit, thereby improving the flexibility and universality of determining the amount digit. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0022] Figure 1 A flowchart of a text processing method provided by an embodiment of the present invention;
[0023] Figure 2 A schematic diagram of the structure of a tree-shaped amount dictionary provided by an embodiment of the present invention;
[0024] Figure 3 A flowchart of a method for performing standard detection on an amount text provided by an embodiment of the present invention;
[0025] Figure 4 A flowchart of a method for processing a first non-standard text provided by an embodiment of the present invention;
[0026] Figure 5 A flowchart of a method for processing a second non-standard text provided by an embodiment of the present invention;
[0027] Figure 6 A flowchart of a method for processing a third non-standard text provided by an embodiment of the present invention;
[0028] Figure 7 A flowchart of a method for processing a standard text provided by an embodiment of the present invention;
[0029] Figure 8 A structural schematic diagram of a text processing device provided by an embodiment of the present invention is provided;
[0030] Fig. 9 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0031] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.
[0032] It should be noted that similar numbers and letters represent similar items in the following figures. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. At the same time, in the description of the present invention, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance. The acquisition, storage, use, processing, etc. of data in the technical solution of this application comply with the relevant provisions of national laws and regulations. It should be noted that in the embodiments of this application, certain software, components, models and other existing solutions in the industry may be mentioned, and they should be regarded as exemplary. The purpose is only to illustrate the feasibility of the implementation of the technical solution of this application, but it does not mean that the applicant has or must use the relevant content of the solution.
[0033] Figure 1 The flowchart of a text processing method provided by an embodiment of the present invention is that the method of the embodiment of the present invention can better process various irregular texts, effectively identify and process the amount text of various scenario data, and improve the efficiency, accuracy and flexibility of determining the amount digit of the text amount. The method can be executed by a text processing device provided by an embodiment of the present invention, and the device can be implemented in software and / or hardware. The following embodiments will be described by taking the device integrated in an electronic device as an example, and the electronic device can be a computer device or a server, etc. Reference Figure 1 , the method may specifically include the following steps:
[0034] Step 101: Obtain the text to be processed, and classify the text to be processed to obtain the text type of the text to be processed.
[0035] Among them, the text to be processed is the text whose amount information needs to be extracted, and the text type of the text to be processed is regular text or irregular text. Regular text is a text with a simple structure, a standardized format and a single format, such as the text corresponding to the amount flow data automatically generated by the automatic deposit machine management system or the payment platform. Irregular text is a text with a complex structure, an irregular format or containing amount information that is difficult to directly extract. For example, the text generated based on the data of the front-end web page of the financial system, log files or messages, etc., the amount information contained in the text is generally composed of text characters in various forms.
[0036] Specifically, the server can obtain the corresponding text to be processed at a preset time interval or in real time through a pre-set data interface connected to the system that generates the text to be processed, and classify the text to be processed according to the different sources of the text to be processed or the specific content of the text to be processed to obtain the text type of the text to be processed. In the embodiment of this scheme, optionally, classifying the text to be processed to obtain the text type of the text to be processed includes: determining the data source of the text to be processed according to the source identifier of the text to be processed; determining the text type of the text to be processed based on the data source of the text to be processed and the types of each data source determined in advance.
[0037] The data source is the data source of the text to be processed, and the source identifier is used to mark different data sources, and each data source corresponds to a source identifier. The type of the data source includes a regular data type or an irregular data type. The text type of the text to be processed generated by the data source of the irregular data type is irregular text, and the text type of the text to be processed generated by the data source of the regular data type is regular text.
[0038] In an optional embodiment, the server can obtain the source identifier of the text to be processed while obtaining the text to be processed, and determine the data source of the text to be processed based on the source identifier. After determining the data source of the text to be processed, determine whether the data source is a regular data type or an irregular data type. If the data source is a regular data type, determine that the type of the text to be processed is a regular text. If the data source is an irregular data type, determine that the type of the text to be processed is an irregular text. Exemplarily, the server obtains two texts to be processed, the source identifier corresponding to the text to be processed 1 is web page A, and the source identifier corresponding to the text to be processed 2 is amount flow B. The server can determine that the data source type of web page A is an irregular data type based on the source identifier, and further determine that the text type of the text to be processed 1 is an irregular text. Determine that the data source type of the amount flow B is a regular data type, and further determine that the text type of the text to be processed 2 is a regular text.
[0039] According to the characteristics and format specifications of different data sources, the text types of different texts to be processed can be accurately determined, laying the foundation for the subsequent use of different processing strategies according to different text types, and improving the efficiency of identifying amount text in the text to be processed.
[0040] Step 102: extract the amount text from the text to be processed according to the text type to obtain at least one amount text of the text to be processed.
[0041] The amount text is a text segment representing the amount in the text to be processed, and the amount text may contain elements such as Chinese capital numerals, Arabic numerals, and currency units. The text corresponding to an amount numeral is an amount text, so the text to be processed may include multiple amount texts. Specifically, different types of text to be processed correspond to different amount text extraction methods. After determining the text type of the text to be processed, the amount text extraction method corresponding to the text type can be used to extract the amount text from the text to be processed, and obtain each amount text in the text to be processed.
[0042] In an optional embodiment, when the text type of the text to be processed is regular text, since the composition structure of the regular text is simple and the format is standardized, the server can directly extract the amount text through string matching or regular expression. For example, in the amount flow data, the position and format of the amount field are usually fixed, so the amount text can be directly extracted by locating its field. When the text type of the text to be processed is irregular text, since the irregular text has a complex structure and irregular format, the server can use named entity recognition or semantic analysis and other technologies to identify the amount text in the text. For example, the text to be processed includes "My salary is 20k", and the text type of the text to be processed is irregular text. After obtaining the text to be processed, the text to be processed is semantically analyzed according to the pre-trained semantic analysis model, and it is determined that the word "20k" connected after "The salary is" is the amount text. Different extraction methods are used according to the text type, regular text uses string matching or regular expressions, and irregular text uses named entity recognition or semantic analysis, which improves the accuracy and flexibility of the amount text extraction.
[0043] Step 103: for each amount text of at least one amount text, perform a standard detection on the current amount text based on a preset standard detection rule to obtain a standard detection result of the current amount text.
[0044] The standard detection result is standard text or non-standard text. The standard detection rule is a rule pre-determined based on the domain big data and is used to determine whether the amount text has any non-standard conditions. The amount text consists of numbers and units. Non-standard conditions include non-standard units or non-standard numbers. For example, the unit is not a pre-set standard unit, and the number is repeated in the number.
[0045] In an optional implementation, the standard detection rule includes a unit detection rule and a number detection rule. After the amount text is obtained, the unit of the amount text is detected according to the unit detection rule to see if it is a pre-set standard unit. If the unit of the amount text is not a standard unit, it is determined that there is an irregularity in the amount text, and the standard detection result of the amount text is further determined to be an irregular text. For example, if the preset unit is a Chinese unit (fen, jiao, yuan, etc.), and the unit in the amount text is "pounds", the amount text is determined to be an irregular text.
[0046] According to the number detection rules, check whether there are repeated Chinese numeral units (tens, hundreds or thousands) or two consecutive Chinese numerals (zero to nine) in the amount text. If there are repeated Chinese numeral units or two consecutive Chinese numerals in the number, it is determined that there are irregularities in the amount text, and further determine that the standard detection result of the amount text is irregular text. For example, if the number of the amount text is "three hundred and fifty-four hundred", it can be determined that the Chinese numeral units are repeated in the number, and further determine that the amount text is irregular text. For example, if the number of the amount text is "six hundred and three four", it can be determined that there are two consecutive Chinese numerals in the number, and further determine that the amount text is irregular text. If there is no irregularity in the amount text or the unit is not standardized, it can be determined that the amount text is standardized text.
[0047] Step 104: If the current amount text is a standard text, the text string of the current amount text is segmented according to a pre-established tree-shaped amount dictionary to obtain each segmentation string corresponding to the text string, and the amount number corresponding to the current amount text is obtained based on each segmentation string.
[0048] Among them, the tree-shaped amount dictionary is pre-established and used to store and organize the mapping relationship between amount texts and corresponding amount numbers. The server can split the string corresponding to the standardized amount text according to the structure of the tree-shaped amount dictionary to obtain the corresponding segmented string. In this solution, optionally, the tree-shaped amount dictionary includes a root node and a five-layer branch structure. The first-layer branch structure includes first branch nodes, the second-layer branch structure includes second branch nodes and second leaf nodes, the third-layer branch structure includes third branch nodes and third leaf nodes, the fourth-layer branch structure includes fourth branch nodes and fourth leaf nodes, and the fifth-layer branch structure includes fifth leaf nodes; each first branch node is connected to the root node, and each first branch node is connected to a second branch node or a second leaf node; each second branch node is connected to a third branch node or a third leaf node; each third branch node is connected to a fourth branch node or a leaf node; each fourth branch node is connected to a fifth leaf node. Each node of the first branch node is a Chinese simplified numeral character, a Chinese capital numeral character, a Chinese variant numeral character, or a Chinese numeral unit character; each second branch node is a Chinese amount unit character or a Chinese numeral unit character, and each second leaf node is a Chinese amount unit character or a Chinese numeral unit character; each third branch node is an end character, a Chinese amount unit character, or a Chinese numeral unit character, and each third leaf node is an end character, a Chinese amount unit character, or a Chinese numeral unit character; each fourth branch node is an end character or a Chinese amount unit character, and each fourth leaf node is an end character or a Chinese amount unit character; each fifth leaf node is an end character.
[0049] Among them, the root node is the top node of the tree structure and usually does not contain specific data but serves as a connection point for other nodes. A branch node is a non-terminal node in the tree, and a branch node is connected to at least one leaf node or other branch nodes. Figure 2 It is a schematic structural diagram of the tree-shaped amount dictionary provided by the embodiment of the present invention. As Figure 2 shown, the tree-shaped amount dictionary includes a root node and a five-layer branch structure. The first-layer branch structure includes first branch nodes. The first branch nodes are Chinese simplified numerals, capital numerals, variants of capital numerals (such as two, both, or three, etc.), and Chinese numeral units (ten, hundred, or thousand) and their variants, etc. Each first branch node is connected to a second branch node. For example, Figure 2 the first branch node "two" in Figure 2The connection of each branch node is not shown, only part of it is shown). The second branch node is a Chinese monetary unit (fen, jiao, yuan, etc.) or a Chinese numeric unit, and the second leaf node is a Chinese monetary unit or a Chinese numeric unit. The third branch node is an end character (whole), a Chinese monetary unit or a Chinese numeric unit, and the third leaf node is an end character, a Chinese monetary unit or a Chinese numeric unit; the fourth branch node is an end character or a Chinese monetary unit, and the fourth leaf node is an end character or a Chinese monetary unit; the fifth leaf node is an end character.
[0050] Specifically, after obtaining the amount text, the text string of the amount text can be segmented according to the hierarchical structure of the tree-shaped amount dictionary to obtain the segmentation strings corresponding to the text string. For example, the amount text is: 3,600,205 yuan. After obtaining the amount text, the maximum forward matching method is used to segment the text string of the amount text according to the tree-shaped amount dictionary, and the segmentation strings corresponding to the text string are: 3,000, 600, 20 and 5 yuan. Further, the Arabic numerals corresponding to each segmentation string can be added (3000+600+20+5), and the amount number corresponding to the amount text is 3625 yuan. This tree-shaped amount dictionary has a clear structure and is easy to expand and maintain. Through this tree-structured amount dictionary, the amount text can be quickly located and segmented, which improves the efficiency of determining the amount number.
[0051] Step 105: If the current amount text is non-standard text, the current amount text is normalized based on the standard detection result, and the amount number corresponding to the current amount text is obtained based on the normalization result.
[0052] Specifically, the standard detection rule includes a unit detection rule and a number detection rule. If the amount text is an irregular text, determine whether the unit is irregular or the number is irregular. If the standard detection result is irregular, the irregular unit can be converted into a standard unit. For example, if the unit of the amount text is the network term "meter", then according to the predefined conversion relationship between "meter" and "yuan", "meter" is converted into "yuan". Further, the amount number corresponding to the amount text is determined according to the amount text after the unit conversion. If the standard detection result is irregular numbers, the numbers of the amount text can be partially deleted or converted according to the specific irregularity of the numbers to obtain the processed amount text, and the amount number corresponding to the current amount text is obtained according to the processed amount text. For example, the numbers in the amount text are "three and six yuan", and according to the conventional method, three and six may be converted into Arabic numerals 3 and 6, and then 3 and 6 are added to obtain 9, and the amount number is further obtained as 9 yuan. In this solution, after obtaining 3 and 6, 3 and 6 are directly combined to obtain the amount number of 36 yuan. By standardizing non-standardized amount texts, we can flexibly handle non-standardized texts with non-standard units and numbers, thereby improving the adaptability and accuracy of determining amount numbers.
[0053] The technical solution of this embodiment obtains the text to be processed, and classifies the text to be processed to obtain the text type of the text to be processed; the text type is regular text or irregular text; the amount text is extracted from the text to be processed according to the text type to obtain at least one amount text of the text to be processed; for each amount text of at least one amount text, the current amount text is subjected to standard detection based on a pre-set standard detection rule to obtain the standard detection result of the current amount text; wherein the standard detection result is a standard text or an irregular text; if the current amount text is a standard text, the text string of the current amount text is segmented according to a pre-established tree-shaped amount dictionary to obtain each word segmentation string corresponding to the text string, and the amount number corresponding to the current amount text is obtained based on each word segmentation string; if the current amount text is an irregular text, the current amount text is normalized based on the standard detection result, and the amount number corresponding to the current amount text is obtained based on the normalization processing result. The technical solution of this embodiment can process text data generated in various complex scenarios by adopting different amount text extraction methods for different types of text, thereby improving the applicability and flexibility of amount text extraction. After extracting the amount text, for the standardized amount text, the tree-shaped amount dictionary is used to quickly perform string segmentation and conversion, which improves the efficiency of determining the amount number. For the non-standard amount text, it can be normalized to obtain the correct amount number, which improves the flexibility of determining the amount number.
[0054] Figure 3The flowchart of the method for standardizing the amount text provided by the embodiment of the present invention is a refinement of the above embodiment. The specific method can be as follows Figure 3 As shown, the method may include the following steps:
[0055] Step 301: Obtain the text to be processed, and classify the text to be processed to obtain the text type of the text to be processed.
[0056] The text type is regular text or irregular text.
[0057] Step 302: If the text type of the text to be processed is irregular text, semantic analysis is performed on the text to be processed according to a preset semantic analysis rule to obtain at least one amount text of the text to be processed.
[0058] The semantic analysis rules are pre-set according to domain big data, etc., and are used to instruct the server to extract the rules of the amount text in the text to be processed. In this solution, optionally, if the text type of the text to be processed is irregular text, the text to be processed is semantically analyzed according to the pre-set semantic analysis rules to obtain at least one amount text of the text to be processed, including the following steps A1-A2:
[0059] Step A1: If the text type of the text to be processed is irregular text, the unit characters in the text to be processed are identified based on various preset unit characters.
[0060] The preset unit characters include all forms of monetary units, such as Chinese monetary units, foreign monetary units, and network lingo monetary units, etc. Specifically, since the text content of irregular text is messy and huge, after obtaining the irregular text, all monetary units (preset unit characters) can be identified in the irregular text first, without the need to analyze the irregular text word by word, and quickly locate where the amount may appear in the text to be processed.
[0061] For example, the data source of irregular text is a webpage of a forum, and the text includes: "My salary is 5,000 yuan; there are five people in my family." After receiving the text to be processed, the server can quickly identify and locate "yuan" instead of mistakenly locating the text segment containing the number "five people". For example, the irregular text includes "I can spend 30k a month, I spent 800 meters to buy this thing, and I have to share this thing with 5 people." After receiving the text to be processed, the server can quickly identify and locate "k" and "meter".
[0062] Step A2: for each unit character in the text to be processed, extract a digital sequence adjacent to and before the current unit character in the text to be processed; and determine the character string consisting of the digital sequence and the current unit character as the current amount text.
[0063] Among them, the digital sequence includes a Chinese digital sequence or an Arabic digital sequence. Specifically, after locating each unit character in the text to be processed, extract the digital sequence composed of the digital characters before the unit character. Exemplarily, after locating the "yuan" in "My salary is five thousand yuan", identify and extract the digital sequence "five thousand" adjacent to the "yuan" and before the "yuan". Further, the character string of five thousand yuan composed of the digital sequence and the current unit character is determined as the amount text. Exemplarily, after locating "k and rice", extract the digital sequence "30" before "k", and determine the amount text as: 30k. Extract the digital sequence "800" before "rice", and determine the amount text as: 800 meters.
[0064] The above steps can quickly locate the location that may contain the amount by presetting the unit characters, avoiding the untargeted word-by-word analysis of the entire text, greatly saving processing time and computing resources. At the same time, it can quickly find the key information related to the amount, improving the accuracy and efficiency of amount extraction.
[0065] Step 303: If the text type of the text to be processed is a regular text, the text to be processed is segmented according to a preset amount keyword, and at least one amount text of the text to be processed is obtained according to the amount text segmentation result.
[0066] Among them, the amount keyword is a pre-set character used to identify the amount text in the rule text. Specifically, the composition structure of the rule text is simple and the format is standardized, and the expression of the amount in the rule text is relatively uniform. Therefore, if the text type of the text to be processed is a rule text, the amount keyword can be directly identified in the amount text, and the amount text in the text to be processed can be extracted according to the amount keyword. Exemplarily, the text to be processed is a consumption record automatically generated by the payment platform, and the consumption record includes "consumption object, consumption time and consumption amount". After obtaining the text to be processed, the server can directly identify and extract the "consumption amount", and perform word segmentation on the text to be processed according to the "consumption amount", obtain the amount words and non-amount words (text corresponding to the consumption object and consumption time) according to the word segmentation results, and determine the amount words as the amount text. Taking advantage of the simple and standardized structure of the rule text, the amount text is quickly and accurately extracted through the pre-set amount keyword, thereby improving the efficiency of amount text extraction.
[0067] Step 304: determine whether the current unit character of the current amount text is a preset standard unit character. If the current unit character is not a standard unit character, determine that the standard detection result of the current amount text is the first non-standard text.
[0068] The standard unit characters are Chinese monetary units, such as jiao, fen and yuan. Specifically, the non-standard text includes non-standard unit text and non-standard number text. The non-standard unit text includes the first non-standard text, and the non-standard number text includes the second non-standard text and the third non-standard text. The amount text consists of units and numbers. After obtaining the amount text, the unit characters of the amount text are extracted, and the unit characters are matched with the standard unit characters. If the unit character belongs to the standard unit character, it can be further determined whether it belongs to the standard based on the number of the amount text. If the unit character does not belong to the standard unit character, the standard detection result of the amount text is determined to be the first non-standard text.
[0069] For example, the amount text 1 is "330,000 yuan", the amount text 2 is "77k", and the amount text 3 is "45 USD". The server obtains that the unit character of the amount text 1 is "yuan", the unit character of the amount text 2 is "k", and the unit character of the amount text 1 is "USD", and determines that the amount text 2 and the amount text 3 are the first non-standard text according to their unit characters.
[0070] Step 305: If the current digital sequence of the current amount text is a Chinese digital sequence, determine whether there are at least two identical pre-set Chinese digital unit characters in the current digital sequence of the current amount text. If there are at least two identical Chinese digital unit characters in the current digital sequence, determine that the standard detection result of the current amount text is the second non-standard text.
[0071] Among them, Chinese numeric unit characters include numeric unit characters such as "ten, hundred, thousand, million and ten million". Specifically, the irregular text includes irregular unit text and irregular numeric text. The irregular numeric text includes the second irregular text and the third irregular text. Since the content of the irregular text is messy and the content is large, there may be a lack of punctuation or a lack of line breaks, resulting in errors in the extracted amount text. Therefore, after obtaining the amount text, the digital sequence of the amount text is extracted. If the digital sequence is a Chinese digital sequence, the Chinese digital sequence is analyzed to determine whether there are at least two identical Chinese numeric unit characters in the digital sequence. If there are at least two identical Chinese numeric unit characters, it is determined that the standard detection result of the amount text is the second irregular text.
[0072] For example, the irregular text includes "age and amount are fifteen and eighty-seven yuan respectively". Since there is no punctuation mark between fifteen and eighty-seven in this sentence, the amount text extracted by the server is: "fifteen and eighty-seven yuan". The server recognizes that the digital sequence of the amount text is: "fifteen and eighty-seven". Since there are two "tens" in the digital sequence, the amount text is determined to be the second irregular text.
[0073] Step 306: If the current digital sequence of the current amount text is a Chinese digital sequence, determine whether there are at least two consecutive pre-set Chinese numeric characters in the current digital sequence. If there are at least two consecutive pre-set Chinese numeric characters in the current digital sequence, determine that the standard detection result of the current amount text is the third non-standard text.
[0074] Among them, Chinese numeric characters include abbreviated Chinese numerals from zero to nine, uppercase Chinese numerals, and variants of Chinese numerals from zero to nine (two, two or three, etc.). Specifically, due to the messy and large content of irregular text, it is possible that the numbers are written in succession, resulting in errors in the extracted amount text. Therefore, after obtaining the amount text, the digital sequence of the amount text is extracted. If the digital sequence is a Chinese digital sequence, the Chinese digital sequence is analyzed to determine whether there are at least two consecutive Chinese numeric characters in the digital sequence. If there are at least two consecutive Chinese numeric characters in the digital sequence, the standard detection result of the amount text is determined to be the third non-standard text. If the digital sequence of the amount text is an Arabic numeral sequence, the amount text is directly determined as the amount number corresponding to the amount text. For example, "3,600 yuan", the server does not need to change it, and directly determines that the amount number corresponding to the amount text is 3,600 yuan.
[0075] For example, the irregular text includes "I spent 368 yuan today". Since 368 is written in this sentence, the amount text extracted by the server is: "368 yuan". The server recognizes that the digital sequence of the amount text is: "368". The digital sequence contains three consecutive Chinese numeric characters, and the amount text is determined to be the third irregular text.
[0076] The technical solution of this embodiment obtains the text to be processed, and classifies the text to be processed to obtain the text type of the text to be processed; the text type is regular text or irregular text. If the text type of the text to be processed is irregular text, the text to be processed is semantically analyzed according to a pre-set semantic analysis rule to obtain at least one amount text of the text to be processed. If the text type of the text to be processed is regular text, the text to be processed is segmented according to a pre-set amount keyword, and at least one amount text of the text to be processed is obtained according to the amount text segmentation result. Determine whether the current unit character of the current amount text is a pre-set standard unit character. If the current unit character is not a standard unit character, determine that the standard detection result of the current amount text is the first non-standard text. If the current digital sequence of the current amount text is a Chinese digital sequence; determine whether there are at least two identical pre-set Chinese digital unit characters in the current digital sequence of the current amount text. If there are at least two identical Chinese digital unit characters in the current digital sequence, determine that the standard detection result of the current amount text is the second non-standard text. Determine whether there are at least two consecutive pre-set Chinese numeric characters in the current digital sequence. If there are at least two consecutive pre-set Chinese numeric characters in the current digital sequence, determine that the standard detection result of the current amount text is the third non-standard text. The technical solution of this embodiment can accurately determine which non-standard situation the non-standard text belongs to according to the unit or number of the text to be processed, thereby improving the accuracy of the standardization judgment of the amount text. At the same time, it is convenient to use a suitable amount number determination method to process the non-standard text in the future, ensuring the accuracy of the amount number determination of various forms of amount texts.
[0077] Figure 4 This is a flowchart of a method for processing a first non-standard text provided by an embodiment of the present invention. This embodiment is a refinement based on the above embodiment. The specific method can be as follows Figure 4 As shown, the method may include the following steps:
[0078] Step 401: If the current amount text is the first non-standard text, search for a special unit character that is the same as the current unit character in a pre-established special unit character conversion table.
[0079] Among them, the special unit is a pre-set non-standard unit, such as a foreign language amount unit, an abbreviated amount unit, and an amount unit in network terms. Specifically, the non-standard text includes a unit non-standard text and a number non-standard text. The unit non-standard text includes a first non-standard text, and the number non-standard text includes a second non-standard text and a third non-standard text. If the amount text is the first non-standard text, it means that the unit of the amount text is a non-standard unit. The server can search for a special unit character that is the same as the unit in the amount text in the special unit character table.
[0080] Step 402: If a special unit character identical to the current unit character is found, convert the current unit character according to the special unit character conversion table to obtain the current standard unit character corresponding to the current unit character; obtain the amount number corresponding to the current amount text based on the current digit sequence of the current amount text and the current standard unit character.
[0081] Specifically, the special unit character conversion table includes each special unit character and the correspondence between each special unit character and the standard unit character. When a special unit character identical to the current unit character is found, the unit character in the amount text is converted according to the correspondence between each special unit character and the standard unit character, and converted into a standard single character position, and the amount digit corresponding to the amount text is obtained based on the digit sequence of the amount text and the standard unit character. When the special unit character identical to the current unit character is not found, the amount text is determined to be an error text, and the server will not further process it.
[0082] Exemplarily, amount text 1 is "three hundred and thirty thousand yuan", amount text 2 is "77k", and amount text 3 is "45 US dollars". The server obtains the unit character of amount text 1 as "yuan", the unit character of amount text 2 as "k", and the unit character of amount text 1 as "US dollars". The special unit character conversion table includes "k---1000 yuan, US dollars---10 yuan", then "k" is converted to 1000 yuan according to the unit character conversion table, and "US dollars" is converted to 10 yuan. Further, the numbers of the digital sequence in the amount text are multiplied by the numbers of the converted standard units, and the amount numbers of amount text 1 are "77000 yuan", and the amount numbers of amount text 2 are "450 yuan".
[0083] The technical solution of this embodiment is that if the current amount text is the first non-standard text, a special unit character identical to the current unit character is searched in a pre-established special unit character conversion table. If a special unit character identical to the current unit character is found, the current unit character is converted according to the special unit character conversion table to obtain the current standard unit character corresponding to the current unit character; the amount number corresponding to the current amount text is obtained based on the current digital sequence of the current amount text and the current standard unit character. The technical solution of this embodiment can perform text processing on the first non-standard text through the special unit character conversion table, and convert the non-standard unit characters into standard unit characters, laying a foundation for the subsequent accurate calculation of the amount number.
[0084] Figure 5 The flowchart of a method for processing a second non-standard text provided by an embodiment of the present invention is a refinement of the above embodiment. The specific method can be as follows Figure 5As shown, the method may include the following steps:
[0085] Step 501: If the current amount text is the second non-standard text, extract each identical Chinese numeric unit character according to the order in which at least two identical Chinese numeric unit characters appear in the current numeric sequence to obtain a Chinese unit sequence.
[0086] Among them, the second non-standard text is a text in which there are at least two identical Chinese numeric unit characters in the digital sequence of the amount text. When the amount text is the second non-standard text, each identical Chinese numeric unit character is extracted in the order in which at least two identical Chinese numeric unit characters appear in the current digital sequence to obtain a Chinese unit sequence. Moreover, in this scheme, if the amount text is the second non-standard text, the server can identify the continuous and different Chinese units appearing in the digital sequence, and combine the identified continuous and different Chinese units as one Chinese unit. For example, continuous and different Chinese units such as "millions", "tens of millions" and "hundreds of billions" can be combined by the server into one Chinese numeric unit character.
[0087] Exemplarily, the amount text is "three million three thousand three hundred eighty-six eighteen yuan", and the digital sequence of the amount text is "three million three thousand three hundred eighty-six eighteen". The server will recognize "million" as a unit character, so the "hundred" in "million" and the separate "hundred" that appears later will not be determined as repeated unit characters. According to the order in which the two identical "tens" appear in the digital sequence, two identical Chinese digital units are extracted to obtain "ten, ten". Exemplarily, the amount text is "five thousand three hundred eighty-six four hundred and eighteen yuan", and the digital sequence of the amount text is "five thousand three hundred eighty-six four hundred and eighteen". According to the order in which the two identical "tens" and the two identical "hundreds" appear in the digital sequence, two identical Chinese digital units are extracted to obtain "hundred ten, hundred ten".
[0088] Step 502: If there are two identical and adjacent Chinese numeral unit characters in the Chinese unit sequence, the Chinese numeral unit character closest to the end of the Chinese unit sequence among the identical Chinese unit characters is determined as the target Chinese unit.
[0089] Specifically, after obtaining the Chinese unit sequence of the second non-standard text, if there are two identical and adjacent Chinese digital unit characters in the Chinese unit sequence, the later Chinese digital unit character is determined as the target Chinese unit. The server can determine the amount number corresponding to the final amount text according to the target Chinese unit. Exemplarily, the Chinese unit sequence of amount text 1 is "ten, ten". The Chinese unit sequence of amount text 2 is "hundred ten, hundred ten". Then, it can be determined that there are two identical and adjacent Chinese digital unit characters in the Chinese unit sequence of amount text 1. Further, the second "ten" in "ten, ten" is determined as the target Chinese unit.
[0090] Step 503: If there are at least two identical and non-adjacent Chinese digital unit characters in the Chinese unit sequence, take the tail character of the Chinese unit sequence as the current Chinese digital unit character. If the value of the previous Chinese digital unit character of the current Chinese digital unit character is greater than the value of the current Chinese digital unit character, then determine the previous Chinese digital unit character of the current Chinese digital unit character as the current Chinese digital unit character until the value of the previous Chinese digital unit character of the current Chinese digital unit character is not greater than the value of the current character, and then determine the current Chinese digital unit character as the target Chinese unit.
[0091] Specifically, if there are at least two identical and non-adjacent Chinese digital unit characters in the Chinese unit sequence, traverse the Chinese unit sequence starting from the tail of the Chinese unit sequence, and take the tail character of the Chinese unit sequence as the current Chinese digital unit character. Compare the value of the current Chinese digital unit character with the value of its previous Chinese digital unit character. If the value of the previous Chinese digital unit character of the current Chinese digital unit character is greater than the value of the current Chinese digital unit character, then determine the previous Chinese digital unit character of the current Chinese digital unit character as the current Chinese digital unit character until the value of the previous Chinese digital unit character of the current Chinese digital unit character is not greater than the value of the current character, and then determine the current Chinese digital unit character as the target Chinese unit.
[0092] Exemplarily, the digital sequence of the amount text is "thirty-six thousand seven hundred three thousand two hundred", and the corresponding Chinese unit sequence is "ten thousand thousand hundred hundred". The server takes the last "hundred" as the current Chinese digital unit character. The value corresponding to the "thousand" before the "hundred" is greater than the value corresponding to the "hundred", so the "thousand" is determined as the current Chinese digital unit character. The Chinese digital unit character before the "thousand" is "hundred". At this time, when the value of the previous Chinese digital unit character of the current Chinese digital unit character is not greater than the value of the current character, determine the current Chinese digital unit character (the "thousand" near the tail of the Chinese unit sequence) as the target Chinese unit.
[0093] Step 504: Take the previous character of the target Chinese unit as the starting character, delete the characters before the starting character in the current amount text, obtain the standard amount text corresponding to the current amount text, and determine the amount number corresponding to the current amount text based on the standard amount text.
[0094] Among them, the standard amount text is the amount text obtained after processing the non-standard text. Specifically, after determining the target Chinese unit, the previous character of the target Chinese unit in the amount text is used as the starting character, and the characters before the starting character in the current amount text are deleted to obtain the standard amount text corresponding to the current amount text, and the amount number corresponding to the amount text is determined according to the standard amount text. Exemplarily, the amount text is "36,732,000 yuan", and the server determines that the "thousand" near the end of the Chinese unit sequence is the target Chinese unit, then the previous character "three" of the target Chinese unit is used as the starting character, and the "36,700" before the starting character is deleted to obtain the standard amount text "3,200 yuan". Furthermore, the amount number corresponding to the amount text can be determined to be 3,200 yuan based on the standard amount text "3,200 yuan" and the tree-shaped amount dictionary.
[0095] The technical solution of this embodiment is that if the current amount text is the second non-standard text, each identical Chinese numeric unit character is extracted in the order in which at least two identical Chinese numeric unit characters appear in the current numeric sequence to obtain a Chinese unit sequence. If there are two identical and adjacent Chinese numeric unit characters in the Chinese unit sequence, the Chinese numeric unit character closest to the end of the Chinese unit sequence among the identical Chinese unit characters is determined as the target Chinese unit. If there are at least two identical and non-adjacent Chinese numeric unit characters in the Chinese unit sequence, the tail character of the Chinese unit sequence is used as the current Chinese numeric unit character, and if the value of the previous Chinese numeric unit character of the current Chinese numeric unit character is greater than the value of the current Chinese numeric unit character, the previous Chinese numeric unit character of the current Chinese numeric unit character is determined as the current Chinese numeric unit character, until the value of the previous Chinese numeric unit character of the current Chinese numeric unit character is not greater than the value of the current character, the current Chinese numeric unit character is determined to be the target Chinese unit. The previous character of the target Chinese unit is used as the starting character, and the characters before the starting character in the current amount text are deleted to obtain the standard amount text corresponding to the current amount text, and the amount number corresponding to the current amount text is determined based on the standard amount text. The technical solution of this embodiment can extract the Chinese unit sequence and determine the target Chinese unit through specific rules, can accurately identify and process the second non-standard text, and effectively convert the non-standard expression into a standard form that can be further processed, thereby improving the efficiency of processing the second non-standard text.
[0096] Figure 6The flowchart of a method for processing a third non-standard text provided by an embodiment of the present invention is a refinement of the above embodiment. The specific method can be as follows Figure 6 As shown, the method may include the following steps:
[0097] Step 601: If the current amount text is the third non-standard text, and the current digital sequence only includes at least two consecutive Chinese numeric characters, then each Chinese numeric character is converted into Arabic numerals.
[0098] Specifically, there are at least two consecutive Chinese numeric characters in the digital sequence of the amount text of the third non-standard text. Chinese numeric characters include abbreviated Chinese numerals from zero to nine, uppercase Chinese numerals, and variants of Chinese numerals from zero to nine (two, two, or three, etc.). If the amount text is the third non-standard text, and the digital sequence only includes at least two consecutive Chinese numeric characters, then each Chinese numeric character is converted into Arabic numerals.
[0099] Step 602: Combine the Arabic numerals to obtain a target numeral sequence, and determine the amount numeral corresponding to the current amount text based on the target numeral sequence and the unit character of the current amount text.
[0100] Specifically, after obtaining the target number sequence, the Arabic numerals are combined to obtain the target number sequence, and the amount number corresponding to the amount text is determined according to the target number sequence and the unit character of the amount text. Exemplarily, the amount text is: "368 yuan", and the number sequence is "368", then the server can determine "368" as the target number sequence, and determine "368 yuan" as the amount number corresponding to the amount text. If the amount text is the third non-standard text, but the number sequence includes at least two consecutive Chinese numeric characters and other Chinese numeric characters, the server can determine that the amount text is an erroneous text and will not process it further.
[0101] The technical solution of this embodiment, if the current amount text is the third non-standard text, and the current digital sequence only includes at least two consecutive Chinese digital characters, then each Chinese digital character is converted into an Arabic numeral. Each Arabic numeral is combined to obtain a target digital sequence, and the amount digit corresponding to the current amount text is determined based on the target digital sequence and the unit character of the current amount text. The technical solution of this embodiment, by converting consecutive Chinese digital characters into Arabic numerals and combining them into a target digital sequence, can accurately process the third non-standard text, ensure that the correct target digital sequence of the third non-standard text is obtained, and lay the foundation for the subsequent accurate determination of the amount digit.
[0102] Figure 7The flowchart of a method for processing standard text provided by an embodiment of the present invention. This embodiment is a refinement based on the above embodiment. The specific method can be as follows Figure 7 shown. The method may include the following steps:
[0103] Step 701: If the current amount text is standard text, perform string splitting on the text string of the current amount text according to the pre-established tree-shaped amount dictionary to obtain each segmented string corresponding to the text string.
[0104] Step 702: Convert each segmented string into an Arabic numeral.
[0105] Step 703: If the text string does not include the preset first special character and second special character, add the Arabic numerals corresponding to each segmented string to obtain the amount numeral corresponding to the current amount text.
[0106] Among them, the first special character is "ten thousand", and the second special character is "hundred million". Specifically, if the text string of the amount text does not include "ten thousand" and "hundred million", that is, when the largest amount numeral unit in the amount text is "thousand", the Arabic numerals corresponding to each segmented string can be directly added to obtain the amount numeral corresponding to the current amount text. For example, the amount text is: Three thousand six hundred and twenty-five yuan in total. After obtaining the amount text, perform string splitting on the text string of the amount text according to the tree-shaped amount dictionary to obtain each segmented string corresponding to the text string as: Three thousand, six hundred, twenty, and five yuan in total. Further, the numerals corresponding to each segmented string can be added (3000 + 600 + 20 + 5) to obtain the amount numeral corresponding to the amount text as 3625 yuan in total.
[0107] Step 704: If the text string includes the first special character and does not include the second special character, add the Arabic numerals corresponding to the segmented strings before the first special character to obtain the first sum; add the numerals corresponding to the segmented strings after the first special character to obtain the second sum; multiply the first sum by the value corresponding to the first special character and add the result to the second sum to obtain the amount numeral corresponding to the current amount text.
[0108] Specifically, if the text string includes the first special character and does not include the second special character, that is, when the largest monetary unit in the monetary text is "ten thousand", add up the Arabic numerals corresponding to the word segmentation strings before "ten thousand" to obtain the first sum; add up the numbers corresponding to the word segmentation strings after "ten thousand" to obtain the second sum; add the product of the first sum and the value corresponding to the first special character to the second sum to obtain the monetary number corresponding to the monetary text. Exemplarily, for the monetary text "Forty-three million six hundred and fifty thousand three hundred yuan in total", the word segmentation strings are "Four thousand", "Three hundred", "Sixty", "Fifty thousand", and "Three hundred yuan in total". If the Arabic numerals corresponding to each word segmentation string are added up, an incorrect monetary number 4000 + 300 + 60 + 50000 + 300 = 54660 yuan will be obtained. Therefore, in this solution, first add up the Arabic numerals corresponding to the word segmentation strings before "ten thousand" to obtain the first sum, that is, 4000 + 300 + 60 + 5 = 4365. Add up the numbers corresponding to the word segmentation strings after "ten thousand" to obtain the second sum, that is, 300. Add the product of the first sum and the value corresponding to the first special character to the second sum to obtain the monetary number corresponding to the monetary text, that is, 4365 × 10000 + 300 = 43650300.
[0109] Step 705: If the text string includes the first special character and the second special character, add up the Arabic numerals corresponding to the word segmentation strings before the second special character to obtain the third sum; add up the numbers corresponding to the word segmentation strings after the second special character and before the first special character to obtain the fourth sum; add up the numbers corresponding to the word segmentation strings after the first special character to obtain the fifth sum; add the product of the third sum and the value corresponding to the second special character, the product of the fourth sum and the value corresponding to the first special character, and the fifth sum to obtain the monetary number corresponding to the current monetary text.
[0110] Specifically, if the text string includes "ten thousand" and "hundred million", add up the Arabic numerals corresponding to the word segmentation strings before "hundred million" to obtain the third sum; add up the numbers corresponding to the word segmentation strings after "hundred million" and before "ten thousand" to obtain the fourth sum; add up the numbers corresponding to the word segmentation strings after "ten thousand" to obtain the fifth sum; add the product of the third sum and the value corresponding to "ten thousand", the product of the fourth sum and the value corresponding to "hundred million", and the fifth sum to obtain the amount number corresponding to the amount text. Exemplarily, the amount text is "Three hundred and twenty-six billion four thousand three hundred and sixty-five thousand three hundred yuan exactly", and the word segmentation strings are "Three hundred", "Twenty-six billion", "Four thousand", "Three hundred", "Sixty", "Fifty thousand", and "Three hundred yuan exactly". In this solution, first add up the Arabic numerals corresponding to the word segmentation strings before "hundred million" to obtain the third sum, that is, 300 + 26 = 326. Add up the numbers corresponding to the word segmentation strings after "hundred million" and before "ten thousand" to obtain the fourth sum, that is, 4000 + 300 + 60 + 5 = 4365. Add up the numbers corresponding to the word segmentation strings after "ten thousand" to obtain the fifth sum, that is, 300. Add the product of the third sum and the value corresponding to "ten thousand", the product of the fourth sum and the value corresponding to "hundred million", and the fifth sum to obtain the amount number corresponding to the amount text, that is, 326 × 10000000 + 4365 × 10000 + 300 = 32643650300 yuan.
[0111] In the technical solution of this embodiment, if the current amount text is a standard text, the text string of the current amount text is segmented according to the pre-established tree-shaped amount dictionary to obtain each segmented string corresponding to the text string. Each segmented string is converted into an Arabic numeral. If the text string does not include the preset first special unit and second special unit, the Arabic numerals corresponding to each segmented string are added to obtain the amount numeral corresponding to the current amount text. If the text string includes the first special unit and does not include the second special unit, the Arabic numerals corresponding to the segmented strings before the first special unit are added to obtain the first sum; the numbers corresponding to the segmented strings after the first special unit are added to obtain the second sum; the product of the first sum and the value corresponding to the first special unit is added to the second sum to obtain the amount numeral corresponding to the current amount text. If the text string includes the first special unit and the second special unit, the Arabic numerals corresponding to the segmented strings before the second special unit are added to obtain the third sum; the numbers corresponding to the segmented strings after the second special unit and before the first special unit are added to obtain the fourth sum; the numbers corresponding to the segmented strings after the first special unit are added to obtain the fifth sum; the product of the third sum and the value corresponding to the second special unit, the product of the fourth sum and the value corresponding to the first special unit, and the fifth sum are added to obtain the amount numeral corresponding to the current amount text. If the current amount text is a non-standard text, it is normalized based on the standard detection result, and the amount numeral corresponding to the current amount text is obtained based on the normalization result. In the technical solution of this embodiment, by determining whether the text string contains special characters "ten thousand" and "hundred million" and performing corresponding calculations according to different situations, it is possible to accurately process amount texts of different magnitudes, correctly perform base conversion and numerical calculations, avoid errors caused by unit confusion or improper processing, and ensure accurate amount numerals are obtained.
[0112] Figure 8 The structural schematic diagram of a text processing device provided by an embodiment of the text invention, and this device is applicable to execute a text processing method provided by an embodiment of the present invention. As Figure 8 shown, this device may specifically include:
[0113] A text acquisition module 801, configured to acquire a text to be processed and classify the text to be processed to obtain the text type of the text to be processed; the text type is a regular text or an irregular text;
[0114] A text extraction module 802, configured to extract at least one amount text from the text to be processed according to the text type to obtain at least one amount text of the text to be processed;
[0115] The text detection module 803 is used to perform a standard detection on the current amount text based on a preset standard detection rule for each amount text of the at least one amount text, and obtain a standard detection result of the current amount text; wherein the standard detection result is a standard text or a non-standard text;
[0116] The text segmentation module 804 is used for, if the current amount text is the standard text, segmenting the text string of the current amount text according to the pre-established tree-shaped amount dictionary to obtain each segmentation string corresponding to the text string, and obtaining the amount number corresponding to the current amount text based on each segmentation string;
[0117] The text processing module 805 is used to normalize the current amount text based on the standard detection result if the current amount text is the non-standard text, and obtain the amount number corresponding to the current amount text based on the normalization processing result.
[0118] Optionally, the text acquisition module 801 is specifically used to: determine the data source of the text to be processed according to the source identifier of the text to be processed;
[0119] The text type of the text to be processed is determined based on the data source of the text to be processed and the predetermined types of each data source.
[0120] Optionally, the text extraction module 802 is specifically used to: if the text type of the text to be processed is the irregular text, perform semantic analysis on the text to be processed according to a preset semantic analysis rule to obtain at least one amount text of the text to be processed;
[0121] If the text type of the text to be processed is the regular text, the text to be processed is segmented into money texts according to a preset money text keyword, and at least one money text of the text to be processed is obtained according to the money text segmentation result.
[0122] Optionally, the text extraction module 802 is further configured to: if the text type of the text to be processed is the irregular text, identify unit characters in the text to be processed based on each preset unit character;
[0123] For each unit character in the text to be processed, extracting a digital sequence adjacent to and before the current unit character in the text to be processed; the digital sequence includes a Chinese digital sequence or an Arabic digital sequence;
[0124] A character string consisting of the digital sequence and the current unit character is determined as the current amount text.
[0125] Optionally, the text detection module 803 is specifically used to determine whether the current unit character of the current amount text is a preset standard unit character, and if the current unit character is not the standard unit character, determine that the standard detection result of the current amount text is the first non-standard text.
[0126] Optionally, the text detection module 803 is further used for: if the current digit sequence of the current amount text is a Chinese digit sequence;
[0127] Determine whether there are at least two identical preset Chinese numeric unit characters in the current digital sequence of the current amount text, and if there are at least two identical Chinese numeric unit characters in the current digital sequence, determine that the standard detection result of the current amount text is a second non-standard text;
[0128] Determine whether there are at least two consecutive pre-set Chinese numeric characters in the current numeric sequence. If there are at least two consecutive pre-set Chinese numeric characters in the current numeric sequence, determine that the standard detection result of the current amount text is a third non-standard text.
[0129] Optionally, the text processing module 805 is specifically configured to: if the current amount text is the first non-standard text, search for a special unit character that is the same as the current unit character in a pre-established special unit character conversion table;
[0130] If a special unit character identical to the current unit character is found, convert the current unit character according to the special unit character conversion table to obtain a current standard unit character corresponding to the current unit character;
[0131] The amount digit corresponding to the current amount text is obtained based on the current digit sequence of the current amount text and the current standard unit character.
[0132] Optionally, the text processing module 805 is further configured to: if the current amount text is the second non-standard text, extract each identical Chinese numeric unit character according to the order in which the at least two identical Chinese numeric unit characters appear in the current numeric sequence to obtain a Chinese unit sequence;
[0133] If there are two identical and adjacent Chinese numeral unit characters in the Chinese unit sequence, the Chinese numeral unit character closest to the end of the Chinese unit sequence among the identical Chinese unit characters is determined as the target Chinese unit;
[0134] Take the previous character of the target Chinese unit as the starting character, delete the characters before the starting character in the current amount text, obtain the standard amount text corresponding to the current amount text, and determine the amount number corresponding to the current amount text based on the standard amount text.
[0135] Optionally, the text processing module 805 is further configured to: if there are at least two identical and non-adjacent Chinese numeric unit characters in the Chinese unit sequence, use the tail character of the Chinese unit sequence as the current Chinese numeric unit character;
[0136] If the value of the previous Chinese numeric unit character of the current Chinese numeric unit character is greater than the value of the current Chinese numeric unit character, the previous Chinese numeric unit character of the current Chinese numeric unit character is determined as the current Chinese numeric unit character. Until the value of the previous Chinese numeric unit character of the current Chinese numeric unit character is not greater than the value of the current character, the current Chinese numeric unit character is determined to be the target Chinese unit.
[0137] Optionally, the text processing module 805 is further configured to: if the current amount text is the third non-standard text, and the current digital sequence only includes the at least two consecutive Chinese digital characters, convert each of the Chinese digital characters into Arabic numerals, and combine the Arabic numerals to obtain a target digital sequence;
[0138] The amount digit corresponding to the current amount text is determined based on the target digit sequence and the unit character of the current amount text.
[0139] Optionally, the tree-shaped amount dictionary includes a root node and a five-layer branch structure, the first layer branch structure includes a first branch node, the second layer branch structure includes a second branch node and a second leaf node, the third layer branch structure includes a third branch node and a third leaf node, the fourth layer branch structure includes a fourth branch node and a fourth leaf node, and the fifth layer branch structure includes a fifth leaf node; each first branch node is connected to the root node, each first branch node is connected to a second branch node or a second leaf node; each second branch node is connected to a third branch node or a leaf node; each third branch node is connected to a fourth branch node or a leaf node; and each fourth branch node is connected to a fifth leaf node.
[0140] Optionally, each node of the first branch node is a simplified Chinese numeric character, a Chinese uppercase data character, a Chinese variant numeric character or a Chinese numeric unit character; each second branch node is a Chinese monetary amount unit character or a Chinese numeric unit character, and each second leaf node is a Chinese monetary amount unit character or a Chinese numeric unit character; each third branch node is an end character, a Chinese monetary amount unit character or a Chinese numeric unit character, and each third leaf node is an end character, a Chinese monetary amount unit character or a Chinese numeric unit character; each fourth branch node is an end character or a Chinese monetary amount unit character, and each fourth leaf node is an end character or a Chinese monetary amount unit character; each fifth leaf node is an end character.
[0141] Optionally, the text segmentation module 804 is specifically used to: convert each word segmentation string into Arabic numerals;
[0142] If the text string does not include the preset first special character and the second special character, the Arabic numerals corresponding to the word segmentation strings are added to obtain the amount numeral corresponding to the current amount text.
[0143] Optionally, the text segmentation module 804 is further configured to: if the text string includes the first special character but does not include the second special character, add the Arabic numerals corresponding to the word segmentation string before the first special character to obtain a first sum; and add the numerals corresponding to the word segmentation string after the first special character to obtain a second sum;
[0144] The product of the first sum and the numerical value corresponding to the first special character is added to the second sum to obtain the amount digit corresponding to the current amount text.
[0145] Optionally, the text segmentation module 804 is further configured to: if the text string includes the first special character and the second special character, add the Arabic numerals corresponding to the word segmentation string before the second special character to obtain a third sum; add the numerals corresponding to the word segmentation string after the second special character and before the first special character to obtain a fourth sum; add the numerals corresponding to the word segmentation string after the first special character to obtain a fifth sum;
[0146] The product of the third sum and the numerical value corresponding to the second special character, the product of the fourth sum and the numerical value corresponding to the first special character, and the fifth sum are added together to obtain the amount digit corresponding to the current amount text.
[0147] The text processing device provided in the embodiment of the present invention can execute the text processing method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method. For the contents not described in detail in this embodiment, reference can be made to the description in any method embodiment of the present invention.
[0148] Fig. 9 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention, referring to Fig. 9 , Fig. 9 The electronic device 12 shown is only an example and should not limit the functions and scope of use of the embodiments of the present application. Fig. 9 As shown, the electronic device 12 is in the form of a general purpose computing device. The components of the electronic device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 that connects various system components (including the system memory 28 and the processing unit 16).
[0149] Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. By way of example, these architectures include, but are not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MAC) bus, an Enhanced ISA bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnect (PCI) bus.
[0150] The electronic device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the electronic device 12, including volatile and non-volatile media, removable and non-removable media.
[0151] The system memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. The electronic device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 34 may be used to read and write non-removable, non-volatile magnetic media ( Fig. 9 not shown, usually called a "hard drive"). Although Fig. 9Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical medium) may be provided. In these cases, each drive may be connected to the bus 18 via one or more data medium interfaces. The memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present application.
[0152] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in the memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. The program modules 42 generally perform the functions and / or methods of the embodiments described herein.
[0153] The electronic device 12 may also communicate with one or more external devices 14 (e.g., keyboards, pointing devices, displays 24, etc.), may communicate with one or more devices that enable a user to interact with the electronic device 12, and / or may communicate with any device that enables the electronic device 12 to communicate with one or more other computing devices (e.g., a network card, a modem, etc.). Such communication may be performed via an input / output (I / O) interface 22. Furthermore, the electronic device 12 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 20. As shown, the network adapter 20 communicates with other modules of the electronic device 12 via the bus 18. It should be understood that although Fig. 9 Not shown, other hardware and / or software modules may be used in conjunction with the electronic device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0154] The processing unit 16 executes various functional applications and data processing by running the program stored in the system memory 28, for example, a text processing method provided in an embodiment of the present invention is implemented: obtaining a text to be processed, and classifying the text to be processed to obtain a text type of the text to be processed; the text type is regular text or irregular text; performing amount text extraction on the text to be processed according to the text type to obtain at least one amount text of the text to be processed; for each amount text of the at least one amount text, performing a standard detection on the current amount text based on a pre-set standard detection rule to obtain a standard detection result of the current amount text; wherein the standard detection result is a standard text or a non-standard text; if the current amount text is the standard text, performing a string segmentation on the text string of the current amount text according to a pre-established tree-shaped amount dictionary to obtain each word segmentation string corresponding to the text string, and obtaining the amount number corresponding to the current amount text based on the each word segmentation string; if the current amount text is the non-standard text, performing a standardization process on the current amount text based on the standardization test result, and obtaining the amount number corresponding to the current amount text based on the standardization process result.
[0155] An embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, a text processing method as provided in all the embodiments of the present invention is implemented: obtaining a text to be processed, and classifying the text to be processed to obtain a text type of the text to be processed; the text type is a regular text or an irregular text; performing amount text extraction on the text to be processed according to the text type to obtain at least one amount text of the text to be processed; for each amount text of the at least one amount text, performing a standard detection on the current amount text based on a pre-set standard detection rule to obtain a standard detection result of the current amount text; wherein the standard detection result is a standard text or a non-standard text; if the current amount text is the standard text, performing a character string segmentation on the text character string of the current amount text according to a pre-established tree-shaped amount dictionary to obtain each word segmentation string corresponding to the text character string, and obtaining the amount number corresponding to the current amount text based on the each word segmentation string; if the current amount text is the non-standard text, performing a standardization process on the current amount text based on the standardization test result, and obtaining the amount number corresponding to the current amount text based on the standardization process result. Computer readable medium can be a computer readable signal medium or a computer readable storage medium. Computer readable storage medium can be, for example, but not limited to, an electronic device, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of computer readable storage medium include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer readable storage medium can be any tangible medium containing or storing a program, which can be used by or in combination with an instruction execution electronic device, device or device.
[0156] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction-executing electronic device, apparatus, or device.
[0157] The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0158] Computer program code for performing the operations of the present invention may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0159] An embodiment of the present invention further provides a computer program product, including a computer program, which, when executed by a processor, implements a text processing method as provided in any embodiment of the present application.
[0160] In the process of implementation, the computer program product can be written in one or more programming languages or a combination thereof to perform the computer program code of the present invention, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (for example, using an Internet service provider to connect through the Internet).
[0161] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A text processing method, characterized in that: include: Acquire a text to be processed, and classify the text to be processed to obtain a text type of the text to be processed; the text type is regular text or irregular text; Extracting the amount text from the text to be processed according to the text type to obtain at least one amount text of the text to be processed; For each amount text of the at least one amount text, a standard detection is performed on the current amount text based on a preset standard detection rule to obtain a standard detection result of the current amount text; wherein the standard detection result is a standard text or a non-standard text; If the current amount text is the standard text, the text string of the current amount text is segmented according to the pre-established tree-shaped amount dictionary to obtain each segmentation string corresponding to the text string, and the amount number corresponding to the current amount text is obtained based on each segmentation string; If the current amount text is the non-standard text, the current amount text is normalized based on the standard detection result, and the amount number corresponding to the current amount text is obtained based on the normalization result.
2. The method according to claim 1, characterized in that Classifying the text to be processed to obtain the text type of the text to be processed includes: Determining the data source of the text to be processed according to the source identifier of the text to be processed; The text type of the text to be processed is determined based on the data source of the text to be processed and the predetermined types of each data source.
3. The method according to claim 1, characterized in that Extracting the amount text from the text to be processed according to the text type to obtain at least one amount text of the text to be processed includes: If the text type of the text to be processed is the irregular text, semantic analysis is performed on the text to be processed according to a preset semantic analysis rule to obtain at least one amount text of the text to be processed; If the text type of the text to be processed is the regular text, the text to be processed is segmented into money texts according to a preset money text keyword, and at least one money text of the text to be processed is obtained according to the money text segmentation result.
4. The method according to claim 3, characterized in that If the text type of the text to be processed is the irregular text, semantic analysis is performed on the text to be processed according to a preset semantic analysis rule to obtain at least one amount text of the text to be processed, including: If the text type of the text to be processed is the irregular text, identifying unit characters in the text to be processed based on each preset unit character; For each unit character in the text to be processed, extracting a digital sequence adjacent to and before the current unit character in the text to be processed; the digital sequence includes a Chinese digital sequence or an Arabic digital sequence; A character string consisting of the digital sequence and the current unit character is determined as the current amount text.
5. The method according to claim 1, characterized in that Based on the preset standard detection rules, the current amount text is subjected to standard detection, and the standard detection result of the current amount text is obtained, including: Determine whether the current unit character of the current amount text is a preset standard unit character. If the current unit character is not the standard unit character, determine that the standard detection result of the current amount text is the first non-standard text.
6. The method according to claim 1, characterized in that Based on the preset standard detection rules, the current amount text is subjected to standard detection, and the standard detection result of the current amount text is obtained, including: If the current digit sequence of the current amount text is a Chinese digit sequence; Determine whether there are at least two identical preset Chinese numeric unit characters in the current digital sequence of the current amount text, and if there are at least two identical Chinese numeric unit characters in the current digital sequence, determine that the standard detection result of the current amount text is a second non-standard text; Determine whether there are at least two consecutive pre-set Chinese numeric characters in the current numeric sequence. If there are at least two consecutive pre-set Chinese numeric characters in the current numeric sequence, determine that the standard detection result of the current amount text is a third non-standard text.
7. The method according to claim 5, characterized in that The current amount text is normalized based on the normalization detection result, and the amount number corresponding to the current amount text is obtained based on the normalization processing result, including: If the current amount text is the first non-standard text, searching for a special unit character identical to the current unit character in a pre-established special unit character conversion table; If a special unit character identical to the current unit character is found, convert the current unit character according to the special unit character conversion table to obtain a current standard unit character corresponding to the current unit character; The amount digit corresponding to the current amount text is obtained based on the current digit sequence of the current amount text and the current standard unit character.
8. The method according to claim 6, characterized in that The current amount text is normalized based on the normalization detection result, and the amount number corresponding to the current amount text is obtained based on the normalization processing result, including: If the current amount text is the second non-standard text, extracting each identical Chinese numeric unit character according to the order in which the at least two identical Chinese numeric unit characters appear in the current numeric sequence to obtain a Chinese unit sequence; If there are two identical and adjacent Chinese numeral unit characters in the Chinese unit sequence, the Chinese numeral unit character closest to the end of the Chinese unit sequence among the identical Chinese unit characters is determined as the target Chinese unit; Take the previous character of the target Chinese unit as the starting character, delete the characters before the starting character in the current amount text, obtain the standard amount text corresponding to the current amount text, and determine the amount number corresponding to the current amount text based on the standard amount text.
9. The method according to claim 8, characterized in that The method further comprises: If there are at least two identical and non-adjacent Chinese numeric unit characters in the Chinese unit sequence, the tail character of the Chinese unit sequence is used as the current Chinese numeric unit character; If the value of the previous Chinese numeric unit character of the current Chinese numeric unit character is greater than the value of the current Chinese numeric unit character, the previous Chinese numeric unit character of the current Chinese numeric unit character is determined as the current Chinese numeric unit character. Until the value of the previous Chinese numeric unit character of the current Chinese numeric unit character is not greater than the value of the current character, the current Chinese numeric unit character is determined to be the target Chinese unit.
10. The method according to claim 6, characterized in that The current amount text is normalized based on the normalization detection result, and the amount number corresponding to the current amount text is obtained based on the normalization processing result, including: If the current amount text is the third non-standard text, and the current digital sequence only includes the at least two consecutive Chinese digital characters, converting each of the Chinese digital characters into Arabic numerals, and combining the Arabic numerals to obtain a target digital sequence; The amount digit corresponding to the current amount text is determined based on the target digit sequence and the unit character of the current amount text.
11. The method according to claim 1, characterized in that: The tree-shaped amount dictionary includes a root node and a five-layer branch structure, wherein the first layer branch structure includes a first branch node, the second layer branch structure includes a second branch node and a second leaf node, the third layer branch structure includes a third branch node and a third leaf node, the fourth layer branch structure includes a fourth branch node and a fourth leaf node, and the fifth layer branch structure includes a fifth leaf node; each first branch node is connected to the root node, each first branch node is connected to a second branch node or a second leaf node; each second branch node is connected to a third branch node or a third leaf node; each third branch node is connected to a fourth branch node or a fourth leaf node; and each fourth branch node is connected to a fifth leaf node.
12. The method according to claim 11, characterized in that Each node of the first branch node is a simplified Chinese numeric character, a Chinese uppercase data character, a Chinese variant numeric character or a Chinese numeric unit character; each second branch node is a Chinese monetary unit character or a Chinese numeric unit character, and each second leaf node is a Chinese monetary unit character or a Chinese numeric unit character; each third branch node is an end character, a Chinese monetary unit character or a Chinese numeric unit character, and each third leaf node is an end character, a Chinese monetary unit character or a Chinese numeric unit character; each fourth branch node is an end character or a Chinese monetary unit character, and each fourth leaf node is an end character or a Chinese monetary unit character; each fifth leaf node is an end character.
13. The method according to claim 1, characterized in that The amount corresponding to the preceding amount text is obtained based on each segmentation string, including: Convert each word segment string into Arabic numerals; If the text string does not include the preset first special character and the second special character, the Arabic numerals corresponding to the word segmentation strings are added to obtain the amount numeral corresponding to the current amount text.
14. The method according to claim 13, characterized in that The method further comprises: If the text string includes the first special character but does not include the second special character, add the Arabic numerals corresponding to the word segmentation string before the first special character to obtain a first sum; add the numerals corresponding to the word segmentation string after the first special character to obtain a second sum; The product of the first sum and the numerical value corresponding to the first special character is added to the second sum to obtain the amount digit corresponding to the current amount text.
15. The method according to claim 13, characterized in that The method further comprises: If the text string includes the first special character and the second special character, add the Arabic numerals corresponding to the word segmentation string before the second special character to obtain a third sum; add the numerals corresponding to the word segmentation string after the second special character and before the first special character to obtain a fourth sum; add the numerals corresponding to the word segmentation string after the first special character to obtain a fifth sum; The product of the third sum and the numerical value corresponding to the second special character, the product of the fourth sum and the numerical value corresponding to the first special character, and the fifth sum are added together to obtain the amount digit corresponding to the current amount text.
16. A text processing device, characterized in that: include: A text acquisition module is used to acquire the text to be processed and classify the text to be processed to obtain the text type of the text to be processed; the text type is regular text or irregular text; A text extraction module, used for extracting the amount text from the text to be processed according to the text type, to obtain at least one amount text of the text to be processed; A text detection module, for performing a standard detection on the current amount text based on a preset standard detection rule for each amount text of the at least one amount text, to obtain a standard detection result of the current amount text; wherein the standard detection result is a standard text or a non-standard text; A text segmentation module is used for, if the current amount text is the standard text, segmenting the text string of the current amount text according to a pre-established tree-shaped amount dictionary to obtain each segmentation string corresponding to the text string, and obtaining the amount number corresponding to the current amount text based on each segmentation string; The text processing module is used to normalize the current amount text based on the standard detection result if the current amount text is the non-standard text, and obtain the amount number corresponding to the current amount text based on the normalization processing result.
17. An electronic device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements a text processing method as claimed in any one of claims 1 to 15 when executing the computer program.
18. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, a text processing method as described in any one of claims 1 to 15 is implemented.
19. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the computer program implements a text processing method according to any one of claims 1 to 15.
Citation Information
Patent Citations
Method for extracting amount information, terminal device and medium
CN108984500A
Method and device for recognizing numerals in speech, computer equipment and storage medium
CN109147767A
Bill amount identification method and device, computer equipment and storage medium
CN113408536A
Method and device for identifying amount character string
CN115525805A
Method, device and equipment for correcting amount data, storage medium and product
CN116306511A