A text processing method, apparatus, device, medium and program product
By classifying and standardizing the text, and utilizing a tree-structured monetary dictionary and standardization techniques, the problem of low processing efficiency for text data with complex structures and non-standard formats in existing technologies has been solved, achieving efficient and accurate extraction of monetary figures.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-29
- Publication Date
- 2026-04-14
AI Technical Summary
Existing text-to-amount conversion technologies cannot adapt to complex and irregularly formatted text data, resulting in slow processing speeds, impacting hardware performance, and insufficient accuracy and efficiency when converting large amounts of text.
By classifying the text to be processed, using different methods to extract monetary amounts from regular and irregular texts, using a tree-structured monetary dictionary to split the regular text into strings, and standardizing the irregular text, the efficiency and flexibility of determining monetary amounts are improved.
It enables text data processing in various complex scenarios, improves the applicability and flexibility of monetary text extraction, and ensures the accuracy and efficiency of monetary figures.
Smart Images

Figure CN119646222B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of big data technology, and in particular to a text processing method, apparatus, device, medium and program product. Background Technology
[0002] In today's digital age, the demand for automation in financial transactions and data processing is growing. In this context, the technology for converting text-based amounts to Arabic numerals is particularly important. Automating the conversion of text-based amounts to Arabic numerals not only improves data processing efficiency but also reduces the error rate of manual operations.
[0003] Existing text-to-amount conversion technologies primarily rely on parsing each element within a numeric string. This method is generally only suitable for relatively simple, well-formatted text data, such as text directly containing Arabic numerals or simple Chinese numeric expressions. However, with the widespread adoption of e-commerce and online financial services, the types of data sources requiring monetary value extraction are increasing, including web pages, financial system log files, and messages. Existing methods cannot handle complex and irregularly formatted text. Furthermore, this method, which relies on parsing each element within a numeric string, leads to slow processing speeds when dealing with large-scale conversions of text containing monetary amounts, impacting hardware performance. Summary of the Invention
[0004] This invention provides a text processing method, apparatus, device, medium, and program product that can better handle various irregular texts, effectively identify and process monetary texts in various scenarios, and improve the efficiency, accuracy, and flexibility of determining the monetary amount in the text.
[0005] In a first aspect, embodiments of the present invention provide a text processing method, including:
[0006] Obtain the text to be processed and classify it to obtain the text type of the text to be processed; the text type is regular text or irregular text.
[0007] Based on the text type, extract the monetary text from the text to be processed to obtain at least one monetary text from the text to be processed;
[0008] For each of the at least one monetary texts, a standardization detection is performed on the current monetary text based on a pre-defined standardization detection rule to obtain a standardization detection result for the current monetary text; wherein, the standardization detection result is either standard text or non-standard text;
[0009] If the current amount text is the standard text, the text string of the current amount text is split into strings according to the pre-established tree-shaped amount dictionary to obtain each word string corresponding to the text string, and the amount number corresponding to the current amount text is obtained based on each word string;
[0010] If the current amount text is non-standard text, the current amount text is standardized based on the standardization detection result, and the amount number corresponding to the current amount text is obtained based on the standardization result.
[0011] Secondly, embodiments of the present invention also provide a text processing apparatus, the apparatus comprising:
[0012] The 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] The text extraction module is used to extract monetary text from the text to be processed according to the text type, so as to obtain at least one monetary text from the text to be processed.
[0014] The text detection module is used to perform standardization detection on the current amount text based on a pre-set standardization detection rule for each amount text of the at least one amount text, and obtain the standardization detection result of the current amount text; wherein, the standardization detection result is standard text or non-standard text;
[0015] The text segmentation module is used to, if the current amount text is the standard text, perform string segmentation on the text string of the current amount text according to the pre-established tree-shaped amount dictionary to obtain each word string corresponding to the text string, and obtain the amount number corresponding to the current amount text based on each word string;
[0016] The text processing module is used to, if the current amount text is non-standard text, perform standardization processing on the current amount text based on the standardization detection result, and obtain the amount number corresponding to the current amount text based on the standardization processing result.
[0017] Thirdly, embodiments of the present invention also provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement a text processing method as described in any of the embodiments of the present invention.
[0018] Fourthly, embodiments of the present invention also provide 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 of the embodiments of the present invention.
[0019] Fifthly, embodiments of the present invention also provide a computer program product, including a computer program that, when executed by a processor, implements a text processing method as described in any of the embodiments of the present invention.
[0020] In this embodiment of the invention, by employing different methods for extracting monetary amounts from different types of text, text data generated in various complex scenarios can be processed, improving the applicability and flexibility of monetary amount extraction. After extracting the monetary amount text, for standardized monetary amount text, a tree-structured monetary dictionary is used for rapid string segmentation and conversion, improving the efficiency of determining the monetary amount. For non-standardized monetary amount text, it can be standardized to obtain the correct monetary amount, improving the flexibility and universality of determining the monetary amount. Attached Figure Description
[0021] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0022] Figure 1 A flowchart of a text processing method provided in an embodiment of the present invention;
[0023] Figure 2 This is a schematic diagram of the structure of the tree-shaped monetary dictionary provided in an embodiment of the present invention;
[0024] Figure 3 This is a flowchart of a method for standardizing monetary text provided in an embodiment of the present invention;
[0025] Figure 4 A flowchart illustrating a method for processing first non-standard text provided in an embodiment of the present invention;
[0026] Figure 5 A flowchart illustrating a method for processing second non-standard text provided in an embodiment of the present invention;
[0027] Figure 6 A flowchart illustrating a method for processing third-party non-standard text provided in an embodiment of the present invention;
[0028] Figure 7 A flowchart illustrating a method for processing standard text provided in an embodiment of the present invention;
[0029] Figure 8 This invention provides a schematic diagram of the structure of a text processing device according to an embodiment of the present invention;
[0030] Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0031] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, the accompanying drawings show only the parts relevant to the present invention, and not all of the structures.
[0032] It should be noted that similar reference numerals and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, in the description of this invention, terms such as "first" and "second" are used only for distinguishing descriptions and should not be construed as indicating or implying relative importance. The acquisition, storage, use, and processing of data in the technical solutions of this application comply with relevant national laws and regulations. It should be noted that in the embodiments of this application, certain existing industry solutions such as software, components, and models may be mentioned. These should be considered exemplary, intended only to illustrate the feasibility of implementing the technical solutions of this application, and do not imply that the applicant has already used or necessarily used the relevant content of such solutions.
[0033] Figure 1 This is a flowchart illustrating a text processing method provided by an embodiment of the present invention. The method of this embodiment can better handle various irregular texts, effectively identify and process monetary text in various scenarios, and improve the efficiency, accuracy, and flexibility of determining the monetary amount in the text. This method can be executed by a text processing device provided by an embodiment of the present invention, which can be implemented in software and / or hardware. The following embodiments will illustrate this using the example of the device being integrated into an electronic device, which 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 it to obtain the text type of the text to be processed.
[0035] The text to be processed refers to the text from which the monetary information needs to be extracted. This text can be classified as regular text or irregular text. Regular text is characterized by a simple structure, standardized format, and uniform format, such as the text corresponding to automatically generated transaction data from automated deposit machine management systems or payment platforms. Irregular text, on the other hand, is characterized by a complex structure, non-standard format, or contains monetary information that is difficult to extract directly. Examples include text generated from data, log files, or messages on the front-end of a financial system; the monetary information in such text is typically composed of various forms of text characters.
[0036] Specifically, the server can acquire the corresponding text to be processed at preset time intervals or in real time through a pre-defined data interface connected to the system that generates the text to be processed. The server then categorizes the text according to its source or content to obtain its text type. Optionally, in this embodiment, categorizing the text to obtain its text type includes: determining the data source of the text based on its source identifier; and determining the text type based on the data source and the pre-determined types of each data source.
[0037] Here, the data source is the source of the text to be processed, and the source identifier is used to mark different data sources, with each data source corresponding to a source identifier. The data source type includes regular data type or irregular data type. The text to be processed generated by the data source with irregular data type is irregular text, and the text to be processed generated by the data source with regular data type is regular text.
[0038] In one optional implementation, the server can acquire the source identifier of the text to be processed simultaneously, and determine the data source of the text based on the source identifier. After determining the data source of the text to be processed, it determines whether the data source is a regular data type or an irregular data type. If the data source is a regular data type, the type of the text to be processed is determined to be regular text. If the data source is an irregular data type, the type of the text to be processed is determined to be irregular text. For example, the server acquires two texts to be processed: the source identifier for text 1 is webpage A, and the source identifier for text 2 is transaction data B. Based on the source identifier, the server can determine that the data source type of webpage A is an irregular data type, and further determine that the text type of text 1 is irregular text. The server determines that the data source type of transaction data B is a regular data type, and further determines that the text type of text 2 is regular text.
[0039] Based on the characteristics and format specifications of different data sources, the text type of different texts to be processed can be accurately determined, laying the foundation for adopting different processing strategies according to different text types and improving the efficiency of identifying monetary text in the text to be processed.
[0040] Step 102: Extract monetary text from the text to be processed according to the text type to obtain at least one monetary text from the text to be processed.
[0041] In this context, monetary text refers to text fragments representing monetary amounts within the text to be processed. Monetary text may contain elements such as Chinese uppercase numerals, Arabic numerals, and currency units. Each monetary number corresponds to one monetary text; therefore, the text to be processed can include multiple monetary texts. Specifically, different types of text to be processed correspond to different monetary text extraction methods. After determining the text type of the text to be processed, the monetary text extraction method corresponding to the text type can be used to extract the monetary text from the text to be processed, obtaining each monetary text within the text.
[0042] In one optional implementation, when the text to be processed is regular text, the server can directly extract the monetary text through string matching or regular expressions because regular text has a simple structure and standardized format. For example, in monetary transaction data, the position and format of the monetary field are usually fixed, so the monetary text can be extracted directly by locating the field. When the text to be processed is irregular text, the server can use techniques such as named entity recognition or semantic analysis to identify the monetary text in the text because irregular text has a complex structure and non-standard format. For example, if the text to be processed includes "My salary is 20k", the text type is irregular text. After obtaining the text to be processed, semantic analysis is performed on the text according to a pre-trained semantic analysis model, and the word "20k" following "salary is" is determined to be the monetary text. By using different extraction methods according to the text type—string matching or regular expressions for regular text and named entity recognition or semantic analysis for irregular text—the accuracy and flexibility of monetary text extraction are improved.
[0043] Step 103: For each amount text of at least one amount text, perform standardization detection on the current amount text based on the pre-set standardization detection rules to obtain the standardization detection result of the current amount text.
[0044] Among them, the specification detection result is a standard text or a non-standard text. The specification detection rule is pre-determined according to the big data of the field and is used to judge whether there is a non-standard situation in the amount text. The amount text consists of numbers and units, and the non-standard situations include non-standard units or non-standard numbers. For example, the unit is not the pre-set standard unit, or the numbers such as "ten, hundred, or thousand" repeatedly appear in the numbers.
[0045] In an optional implementation manner, the specification detection rule includes a unit detection rule and a number detection rule. After obtaining the amount text, it is detected according to the unit detection rule whether the unit of the amount text is the pre-set standard unit. If the unit of the amount text is not the standard unit, it is determined that there is a non-standard situation in the amount text, and further, the specification detection result of the amount text is determined to be a non-standard text. For example, if the pre-set unit is a Chinese unit (such as fen, jiao, and yuan), and the unit in the amount text is "pound", it is determined that the amount text is a non-standard text.
[0046] According to the number detection rule, it is detected whether there are repeatedly appearing Chinese number units (ten, hundred, or thousand) or two consecutive Chinese numbers (zero to nine) in the numbers of the amount text. If there are repeatedly appearing Chinese number units or two consecutive Chinese numbers in the numbers, it is determined that there is a non-standard situation in the amount text, and further, the specification detection result of the amount text is determined to be a non-standard text. For example, if the number in the amount text is "three hundred and fifty-four hundred", it can be determined that there are repeatedly appearing Chinese number units in the numbers, and further, the amount text is determined to be a non-standard text. For example, if the number in the amount text is "six hundred and thirty-four", it can be determined that there are two consecutive Chinese numbers in the numbers, and further, the amount text is determined to be a non-standard text. If there is no non-standard situation in the amount or unit of the amount text, it can be determined that the amount text is a standard 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 the pre-established tree-shaped amount dictionary to obtain each segmented string corresponding to the text string, and the amount number corresponding to the current amount text is obtained based on each segmented 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. Usually, it 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 will connect to at least one leaf node or other branch nodes. Figure 2 This is a schematic diagram of the structure of the tree-shaped amount dictionary provided by the embodiments 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 currency unit (such as fen, jiao, and yuan) or a Chinese numeral unit, and the second leaf node is a Chinese currency unit or a Chinese numeral unit. The third branch node is an end character (zheng), a Chinese currency unit or a Chinese numeral unit, and the third leaf node is an end character, a Chinese currency unit or a Chinese numeral unit; the fourth branch node is an end character or a Chinese currency unit, and the fourth leaf node is an end character or a Chinese currency unit; the fifth leaf node is an end character.
[0050] Specifically, after obtaining the amount text, according to the hierarchical structure of the tree-shaped amount dictionary, the text string of the amount text can be segmented to obtain each segmented string corresponding to the text string. For example, the amount text is: Three thousand six hundred and twenty-five yuan in full. After obtaining the amount text, according to the tree-shaped amount dictionary, the maximum forward matching method is used to segment the text string of the amount text, and each segmented string corresponding to the text string is: Three thousand, six hundred, twenty, and five yuan in full. Further, the Arabic numerals corresponding to each segmented string can be added (3000 + 600 + 20 + 5), and the amount number corresponding to the amount text is obtained as 3625 yuan in full. The structure of this tree-shaped amount dictionary is clear, which is convenient for expansion and maintenance. Through this tree-shaped amount dictionary, the amount text can be quickly located and segmented, improving the efficiency of determining the amount number.
[0051] Step 105: If the current amount text is an irregular text, normalize the current amount text based on the specification detection result, and obtain the amount number corresponding to the current amount text based on the normalization result.
[0052] Specifically, the specification detection rules include unit detection rules and digital detection rules. If the amount text is an irregular text, determine whether the unit is irregular or the number is irregular in the specification detection result. If the specification detection result shows that the unit is irregular, the irregular unit can be converted into a regular unit. For example, if the unit of the amount text is the Internet term "meter", then according to the predefined conversion relationship between "meter" and "yuan", "meter" is converted into "yuan". Further, determine the amount number corresponding to the amount text according to the amount text after the unit conversion. If the specification detection result shows that the number is irregular, the number of the amount text can be partially deleted or converted according to the specific irregular situation of the number, etc., to obtain the processed amount text, and obtain the amount number corresponding to the current amount text according to the processed amount text. For example, if the number in the amount text is "thirty-six yuan in total", 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 get 9, and further the amount number is obtained as 9 yuan in total. In this solution, after getting 3 and 6, 3 and 6 are directly combined to obtain the amount number as 36 yuan in total. By normalizing the irregular amount text, the irregular texts with unit irregularity and number irregularity can be flexibly processed, improving the adaptability and accuracy of determining the amount number.
[0053] The technical solution of this embodiment is to obtain the text to be processed, classify the text to be processed, and obtain the text type of the text to be processed; the text type is a regular text or an irregular text; extract the amount text from the text to be processed according to the text type, and obtain at least one amount text of the text to be processed; for each amount text of at least one amount text, perform a specification detection on the current amount text based on the predefined specification detection rules, and obtain the specification detection result of the current amount text; wherein, the specification detection result is a regular text or an irregular text; if the current amount text is a regular text, perform a string segmentation on the text string of the current amount text according to the pre-established tree-shaped amount dictionary, obtain each segmented word string corresponding to the text string, and obtain the amount number corresponding to the current amount text based on each segmented word string; if the current amount text is an irregular text, perform a normalization process on the current amount text based on the specification detection result, and obtain the amount number corresponding to the current amount text based on the normalization process result. The technical solution of this embodiment can process the text data generated in various complex scenarios by adopting different amount text extraction methods for different types of texts, improving the applicability and flexibility of the amount text extraction. After extracting the amount text, for the regular amount text, a tree-shaped amount dictionary is used for rapid string segmentation and conversion, improving the efficiency of determining the amount number. For the irregular amount text, it can be normalized to obtain the correct amount number, improving the flexibility of determining the amount number.
[0054] Figure 3The flowchart of the method for canonical detection of amount text provided by the embodiments of the present invention is a refinement based on the above embodiments. The specific method can be as follows Figure 3 shown. The method may include the following steps:
[0055] Step 301, obtain the text to be processed, classify the text to be processed, and 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, perform semantic analysis on the text to be processed according to the preset semantic analysis rules, and obtain at least one amount text of the text to be processed.
[0058] Among them, the semantic analysis rules are preset according to domain big data and other data, and are used to indicate the server to extract 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, performing semantic analysis on the text to be processed according to the preset semantic analysis rules to obtain at least one amount text of the text to be processed includes the following steps A1 - step A2:
[0059] Step A1, if the text type of the text to be processed is irregular text, identify the unit characters in the text to be processed based on each preset unit character.
[0060] Among them, the preset unit characters include all forms of amount units, such as Chinese amount units, foreign language amount units, and Internet term amount units, etc. Specifically, since the text content of irregular text is messy and large in volume, after obtaining the irregular text, all amount units (preset unit characters) can be identified in the irregular text first, without performing a character-by-character analysis on the irregular text, and quickly locate the places where amounts may appear in the text to be processed.
[0061] Exemplarily, the data source of the irregular text is the web page of a certain forum, and its text includes: "My salary is five thousand yuan; there are five people in my family." After the server obtains the text to be processed, it can quickly identify and locate "yuan", and will not mislocate the text segment containing the number "five people". Exemplarily, the irregular text includes "I can spend 30k a month, I spent 800 meters on buying this thing, and 5 people will share the cost of buying this thing". After the server obtains the text to be processed, it can quickly identify and locate "k" and "meter".
[0062] Step A2: For each unit character in the text to be processed, extract the numeric sequence adjacent to and preceding the current unit character in the text to be processed; determine the string composed of the numeric sequence and the current unit character as the current amount text.
[0063] Among them, the numeric sequence includes a Chinese numeric sequence or an Arabic numeric sequence. Specifically, after locating each unit character in the text to be processed, extract the numeric sequence composed of the numeric characters preceding the unit character. Exemplarily, after locating "元" in "我的工资是五千元", identify and extract the numeric sequence "五千" adjacent to and preceding "元". Further, determine the string "五千元" composed of the numeric sequence and the current unit character as the amount text. Exemplarily, after locating "k和米", extract the numeric sequence "30" preceding "k", and determine the amount text as: 30k. Extract the numeric sequence "800" preceding "米", and determine the amount text as: 800米.
[0064] The above steps can quickly locate the positions that may contain amounts through preset unit characters, avoiding non-targeted character-by-character analysis of the entire text, greatly saving processing time and computing resources. At the same time, quickly find the key information related to amounts, 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, perform amount text word segmentation on the text to be processed according to the preset amount keywords, and obtain at least one amount text of the text to be processed according to the amount text word segmentation result.
[0066] Among them, the amount keywords are preset characters used to identify amount texts in regular texts. Specifically, the composition structure of regular texts is simple and the format is standardized, and the expression of amounts in regular texts is relatively unified. Therefore, if the text type of the text to be processed is a regular text, the amount keywords can be directly identified in the amount text, and the amount texts in the text to be processed can be extracted according to the amount keywords. Exemplarily, the text to be processed is a consumption record automatically generated by a 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 "消费金额", and perform word segmentation on the text to be processed according to "消费金额". According to the word segmentation result, obtain amount words and non-amount words (texts corresponding to the consumption object and consumption time), and determine the amount words as the amount text. Utilizing the characteristics of simple and standardized regular text structures, quickly and accurately extract amount texts through preset amount keywords, improving the efficiency of amount text extraction.
[0067] Step 304: 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 the standardization detection result of the current amount text as the first non-standard text.
[0068] Standard unit characters are Chinese monetary units, such as jiao, fen, and yuan. Specifically, non-standard text includes non-standard unit text and non-standard number text. Non-standard unit text includes first-degree non-standard text, and non-standard number text includes second-degree and third-degree non-standard text. Monetary text consists of units and numbers. After obtaining the monetary text, the unit characters are extracted and matched against standard unit characters. If the unit character belongs to the standard unit characters, it can be further determined whether it belongs to the standard unit based on the numbers in the monetary text. If the unit character does not belong to the standard unit characters, the monetary text is determined to be first-degree non-standard text.
[0069] For example, 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 receives the unit characters of amount text 1 as "yuan", amount text 2 as "k", and amount text 3 as "US dollars", and determines amount text 2 and amount text 3 as the first non-standard text based on their unit characters.
[0070] Step 305: If the current number sequence of the current amount text is a Chinese number sequence; determine whether there are at least two identical pre-defined Chinese number unit characters in the current number sequence of the current amount text. If there are at least two identical Chinese number unit characters in the current number sequence, determine that the standardization detection result of the current amount text is the second non-standard text.
[0071] The Chinese numeric unit characters include those for "ten," "hundred," "thousand," "million," and "ten million." Specifically, non-standard text includes non-standard unit text and non-standard number text. Non-standard number text includes second-degree and third-degree non-standard text. Because the content of irregular text is often disorganized and lengthy, it may contain missing punctuation marks or line breaks, leading to errors in the extracted monetary text. Therefore, after obtaining the monetary text, the numerical sequence is extracted. If the numerical sequence is a Chinese numeric sequence, it is analyzed to determine if at least two identical Chinese numeric unit characters exist. If at least two identical Chinese numeric unit characters are found, the monetary text is classified as second-degree non-standard text.
[0072] Exemplarily, the irregular text includes "The age and amount are fifteen eighty-seven yuan". Since there is no punctuation mark between fifteen and eighty-seven in this sentence, the amount text extracted by the server is: "fifteen eighty-seven yuan". The server recognizes the digital sequence of this amount text as: "fifteen eighty-seven". Since this digital sequence has two "tens", it is determined that this amount text is the second non-standard 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 digital characters in the current digital sequence. If there are at least two consecutive pre-set Chinese digital characters in the current digital sequence, determine that the specification detection result of the current amount text is the third non-standard text.
[0074] Among them, Chinese digital characters include the abbreviated Chinese numbers from zero to nine, the capital Chinese numbers, and the variants of Chinese numbers from zero to nine (such as "liang", "two" or "san", etc.). Specifically, due to the messy and large amount of content in the irregular text, there may be a situation of continuous writing of numbers, resulting in incorrect extraction of the amount text. Therefore, after obtaining the amount text, extract the digital sequence of the amount text. If the digital sequence is a Chinese digital sequence, analyze the Chinese digital sequence to determine whether there are at least two consecutive Chinese digital characters in the digital sequence. If there are at least two consecutive Chinese digital characters in the digital sequence, determine that the specification detection result of the amount text is the third non-standard text. If the digital sequence of the amount text is an Arabic digital sequence, directly determine the amount text as the amount number corresponding to the amount text. For example, for "3600 yuan", the server does not need to modify it and directly determines that the amount number corresponding to the amount text is 3600 yuan.
[0075] Exemplarily, the irregular text includes "I spent three six eight yuan today". Since "three six eight" is continuously written in this sentence, the amount text extracted by the server is: "three six eight yuan". The server recognizes the digital sequence of this amount text as: "three six eight". Since there are three consecutive Chinese digital characters in this digital sequence, it is determined that this amount text is the third non-standard text.
[0076] The technical solution of this embodiment involves acquiring the text to be processed and classifying it to obtain its text type; the text type is either regular text or irregular text. If the text type is irregular text, semantic analysis is performed on the text according to pre-defined semantic analysis rules to obtain at least one monetary value. If the text type is regular text, monetary value word segmentation is performed on the text according to pre-defined monetary value keywords, and at least one monetary value is obtained based on the word segmentation results. It is determined whether the current unit character of the current monetary value is a pre-defined standard unit character. If the current unit character is not a standard unit character, the standardization detection result of the current monetary value is determined to be first non-standard text. If the current number sequence of the current monetary value is a Chinese numeral sequence, it is determined whether there are at least two identical pre-defined Chinese numeral unit characters in the current number sequence. If there are at least two identical Chinese numeral unit characters in the current number sequence, the standardization detection result of the current monetary value is determined to be second non-standard text. The system determines whether at least two consecutive pre-defined Chinese numeric characters exist in the current number sequence. If so, the current amount text is classified as non-standard text. This embodiment's technical solution accurately identifies the specific type of non-standard text based on its unit or number, improving the accuracy of amount text standardization judgment. It also facilitates subsequent processing of non-standard text using appropriate amount determination methods, ensuring the accuracy of amount determination for various forms of amount text.
[0077] Figure 4 This is a flowchart illustrating a method for processing first non-standard text, provided as an embodiment of the present invention. This embodiment is a refinement based on the above embodiments. 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 the special unit character that is the same as the current unit character in the pre-established special unit character conversion table.
[0079] Special units are pre-defined, non-standard units, such as foreign language monetary units, abbreviated monetary units, and monetary units used in online terminology. Specifically, non-standard text includes non-standard unit text and non-standard number text. Non-standard unit text includes first-degree non-standard text, and non-standard number text includes second-degree non-standard text and third-degree non-standard text. If the monetary text is first-degree non-standard text, it means that the unit in the monetary text is non-standard. The server can look up the special unit character in the special unit character table that matches the unit in the monetary text.
[0080] Step 402: If a special unit character that is the same as 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 number sequence of the current amount text and the current standard unit character.
[0081] Specifically, the special unit character conversion table includes all special unit characters and their corresponding relationships with standard unit characters. When a special unit character identical to the current unit character is found, the unit character in the amount text is converted into a standard single character based on the correspondence between the special unit characters and the standard unit characters. The corresponding amount is then obtained based on the numerical sequence of the amount text and the standard unit character. When no special unit character identical to the current unit character is found, the amount text is determined to be erroneous, and the server will not perform any further processing.
[0082] For example, amount text 1 is "330,000 yuan", amount text 2 is "77k", and amount text 3 is "45 US dollars". The server receives 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 3 as "US dollars". The special unit character conversion table includes "k---1000 yuan, US dollars---10 yuan", so according to the unit character conversion table, "k" is converted to 1000 yuan, and "US dollars" is converted to 10 yuan. Further, the numbers in the numerical sequence of amount texts are multiplied by the numbers in the converted standard units, resulting in the amount text 1 being "77,000 yuan" and the amount text 2 being "450 yuan".
[0083] In this embodiment, if the current amount text is a 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; based on the current number sequence of the current amount text and the current standard unit character, the amount corresponding to the current amount text is obtained. This embodiment's technical solution, through the special unit character conversion table, can perform text processing on the first non-standard text, converting non-standard unit characters into standard unit characters, laying the foundation for accurate subsequent calculation of the amount.
[0084] Figure 5 This is a flowchart illustrating a method for processing second non-standard text provided in an embodiment of the present invention. This embodiment is a refinement based on the above embodiments. 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 of the same Chinese digital unit characters in the order in which at least two identical Chinese digital unit characters appear in the current digital 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 digital unit characters in the digital sequence of the amount text. When the amount text is the second non-standard text, extract each of the same Chinese digital unit characters in the order in which at least two identical Chinese digital unit characters appear in the current digital sequence, to obtain a Chinese unit sequence. Moreover, in this solution, if the amount text is the second non-standard text, the server can identify consecutive and different Chinese units that appear in the digital sequence, and combine the identified consecutive and different Chinese units, and use them as one Chinese unit. For example, consecutive and different Chinese units such as "million", "ten million", and "hundred billion", the server can combine them into one Chinese digital unit character.
[0087] Exemplarily, the amount text is "three million three thousand three hundred and eighty-eight yuan", and the obtained digital sequence of the amount text is "three million three thousand three hundred and eighty-eight". The server will identify "million" as one unit character, so it will not determine the "hundred" in "million" and the subsequent separate "hundred" as duplicate unit characters. According to the order in which two identical "tens" appear in the digital sequence, extract two identical Chinese digital units, to obtain "ten, ten". Exemplarily, the amount text is "five thousand three hundred and eighty-six hundred and eighteen yuan", and the obtained digital sequence of the amount text is "five thousand three hundred and eighty-six hundred and eighteen". According to the order in which two identical "tens" and two identical "hundreds" appear in the digital sequence, extract two identical Chinese digital units, to obtain "hundred ten, hundred ten".
[0088] Step 502: If there are two identical and adjacent Chinese digital unit characters in the Chinese unit sequence, determine the Chinese digital unit character closest to the tail of the Chinese unit sequence among the identical Chinese unit characters 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 trailing 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 end of the Chinese unit sequence, and take the trailing 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 "hundred" is greater than the value corresponding to "hundred", so "thousand" is determined as the current Chinese digital unit character. The Chinese digital unit character before "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 end of the Chinese unit sequence) as the target Chinese unit.
[0093] Step 504: Use the character before the target Chinese unit as the starting character, delete the characters before the starting character in the current amount text to 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, use the character before the target Chinese unit in the amount text as the starting character, delete the characters before the starting character in the current amount text to obtain the standard amount text corresponding to the current amount text, and determine the amount number corresponding to the amount text according to the standard amount text. Exemplarily, if the amount text is "thirty-six thousand seven hundred and three thousand two hundred yuan", and the server determines that the "thousand" near the end of the Chinese unit sequence is the target Chinese unit, then use the character "three" before the target Chinese unit as the starting character, and delete "thirty-six thousand seven hundred" before the starting character to obtain the standard amount text "three thousand two hundred yuan". Further, the amount number corresponding to the amount text can be determined as 3200 yuan according to the standard amount text "three thousand two hundred yuan" and the tree-shaped amount dictionary.
[0095] In the technical solution of this embodiment, if the current amount text is the second non-standard text, extract each identical Chinese digital unit character in the current digital sequence according to the order in which at least two identical Chinese digital unit characters appear to obtain the Chinese unit sequence. If there are two identical and adjacent Chinese digital unit characters in the Chinese unit sequence, then determine the Chinese digital unit character closest to the end of the Chinese unit sequence among the identical Chinese unit characters as the target Chinese unit. If there are at least two identical and non-adjacent Chinese digital unit characters in the Chinese unit sequence, use 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. Use the character before the target Chinese unit as the starting character, delete the characters before the starting character in the current amount text to 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. 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, effectively convert the non-standard expression into a standard form that can be further processed, and improve the efficiency of processing the second non-standard text.
[0096] Figure 6The flowchart of a method for processing the third 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 6 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 digital characters, convert each Chinese digital character into an Arabic numeral.
[0098] Specifically, there are at least two consecutive Chinese digital characters in the digital sequence of the amount text of the third non-standard text. Chinese digital characters include the abbreviated Chinese numerals from zero to nine, the capital Chinese numerals, and variants of Chinese numerals from zero to nine (such as "俩", "两", or "仨", etc.). If the amount text is the third non-standard text and the digital sequence only includes at least two consecutive Chinese digital characters, convert each Chinese digital character into an Arabic numeral.
[0099] Step 602, combine the Arabic numerals to obtain a target digital sequence, and determine the amount numeral corresponding to the current amount text based on the target digital sequence and the unit character of the current amount text.
[0100] Specifically, after combining the Arabic numerals to obtain a target digital sequence, determine the amount numeral corresponding to the amount text according to the target digital sequence and the unit character of the amount text. Exemplarily, the amount text is: "Three hundred and sixty-eight yuan", the digital sequence is "三六八", then the server can determine "368" as the target digital sequence and determine "368 yuan" as the amount numeral corresponding to the amount text. If the amount text is the third non-standard text, but the digital sequence includes at least two consecutive Chinese digital characters and other Chinese digital characters, the server can determine that the amount text is an incorrect text and will not process it further.
[0101] For 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, convert each Chinese digital character into an Arabic numeral. Combine the Arabic numerals to obtain a target digital sequence, and determine the amount numeral corresponding to the current amount text based on the target digital sequence and the unit character of the current amount text. For the technical solution of this embodiment, by converting consecutive Chinese digital characters into Arabic numerals and combining them into a target digital sequence, the third non-standard text can be accurately processed, ensuring that the correct target digital sequence of the third non-standard text is obtained, laying a foundation for accurately determining the amount numeral subsequently.
[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 segmentation 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 segmentation 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 numbers 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 numbers 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 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 digit unit in the monetary text is "ten thousand", add up the Arabic numerals corresponding to the segmented strings before "ten thousand" to obtain the first sum; add up the numbers corresponding to the segmented 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 digit corresponding to the monetary text. Exemplarily, for the monetary text "Forty-three million six hundred and fifty thousand three hundred yuan", the segmented strings are "Four thousand", "Three hundred", "Sixty", "Fifty thousand" and "Three hundred yuan". If calculated by adding up the Arabic numerals corresponding to each segmented string, an incorrect monetary digit 4000 + 300 + 60 + 50000 + 300 = 54660 yuan will be obtained. Therefore, in this solution, first add up the Arabic numerals corresponding to the segmented strings before "ten thousand" to obtain the first sum, that is, 4000 + 300 + 60 + 5 = 4365. Add up the numbers corresponding to the segmented 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 digit 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 segmented strings before the second special character to obtain the third sum; add up the numbers corresponding to the segmented strings after the second special character and before the first special character to obtain the fourth sum; add up the numbers corresponding to the segmented 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 digit corresponding to the current monetary text.
[0110] Specifically, if the text string includes "ten thousand" and "hundred million", add the Arabic numerals corresponding to the word segmentation strings before "hundred million" to obtain the third sum; add the numbers corresponding to the word segmentation strings after "hundred million" and before "ten thousand" to obtain the fourth sum; add 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 the Arabic numerals corresponding to the word segmentation strings before "hundred million" to obtain the third sum, that is, 300 + 26 = 326. Add 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 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] For the technical solution of this embodiment, if the current amount text is a standard text, the text string of the current amount text is split 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 numerals 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 numerals corresponding to the segmented strings after the second special unit and before the first special unit are added to obtain the fourth sum; the numerals 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. The technical solution of this embodiment can accurately process amount texts of different magnitudes, correctly perform base conversion and numerical calculation, avoid errors caused by unit confusion or improper processing, and ensure the accurate amount numeral is obtained by determining whether the text string contains special characters 'ten thousand' and 'hundred million' and performing corresponding calculations according to different situations.
[0112] Figure 8 The structural schematic diagram of a text processing device provided by an embodiment of the text invention, 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 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 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 standardization detection on the current amount text based on a pre-set standardization detection rule for each amount text of the at least one amount text, and obtain the standardization detection result of the current amount text; wherein, the standardization detection result is standard text or non-standard text;
[0116] The text segmentation module 804 is used to, if the current amount text is the standard text, perform string segmentation on the text string of the current amount text according to the pre-established tree-shaped amount dictionary to obtain each word string corresponding to the text string, and obtain the amount number corresponding to the current amount text based on each word string;
[0117] The text processing module 805 is used to perform normalization processing on the current amount text based on the normalization detection result if the current amount text is non-standard text, and to 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 based on 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 types of each pre-determined data source.
[0120] Optionally, the text extraction module 802 is specifically used to: if the text type of the text to be processed is irregular text, perform semantic analysis on the text to be processed according to a pre-set semantic analysis rule to obtain at least one monetary text of the text to be processed;
[0121] If the text type of the text to be processed is the rule text, the text to be processed is segmented into monetary text based on the pre-set monetary keywords, and at least one monetary text of the text to be processed is obtained based on the monetary 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 the 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, extract the numerical sequence that is adjacent to and precedes the current unit character in the text to be processed; the numerical sequence includes Chinese numeral sequences or Arabic numeral sequences.
[0124] The string composed of the number 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 pre-set standard unit character; if the current unit character is not the standard unit character, determine the standardization detection result of the current amount text as the first non-standard text.
[0126] Optionally, the text detection module 803 is further configured to: if the current number sequence of the current amount text is a Chinese number sequence;
[0127] Determine whether there are at least two identical pre-defined Chinese numeric unit characters in the current number sequence of the current amount text. If there are at least two identical Chinese numeric unit characters in the current number sequence, determine that the standardization detection result of the current amount text is the second non-standard text.
[0128] Determine whether there are at least two consecutive pre-defined Chinese numeric characters in the current number sequence. If there are at least two consecutive pre-defined Chinese numeric characters in the current number sequence, determine that the standardization detection result of the current amount text is the third non-standard text.
[0129] Optionally, the text processing module 805 is specifically used 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 that is the same as 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;
[0131] The amount corresponding to the current amount text is obtained based on the current number 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 numeral unit character according to the order in which the at least two identical Chinese numeral unit characters appear in the current number sequence to obtain a Chinese unit sequence;
[0133] If there are two identical and adjacent Chinese numeric unit characters in the Chinese unit sequence, then 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;
[0134] The character preceding the target Chinese unit is used as the starting character. 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. The amount number corresponding to the current amount text is determined 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, take the last character of the Chinese unit sequence as the current Chinese numeric unit character;
[0136] If the value of the preceding Chinese numeral unit character is greater than the value of the current Chinese numeral unit character, then the preceding Chinese numeral unit character is determined as the current Chinese numeral unit character, until the value of the preceding Chinese numeral unit character is no greater than the value of the current character, then the current Chinese numeral unit character is determined as the target Chinese numeral 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 number sequence only includes the at least two consecutive Chinese numeral characters, then convert each Chinese numeral character into Arabic numerals, and combine the Arabic numerals to obtain the target number sequence;
[0138] The amount corresponding to the current amount text is determined based on the target number sequence and the unit character of the current amount text.
[0139] Optionally, the tree-shaped monetary dictionary includes a root node and a five-level branch structure. The first-level branch structure includes a first branch node, the second-level branch structure includes a second branch node and a second leaf node, the third-level branch structure includes a third branch node and a third leaf node, the fourth-level branch structure includes a fourth branch node and a fourth leaf node, and the fifth-level branch structure includes a fifth leaf node. Each first branch node is connected to the root node, and each first branch node is connected to either a second branch node or a second leaf node. Each second branch node is connected to either a third branch node or a leaf node. Each third branch node is connected to either a fourth branch node or a leaf node. 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 numeric 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.
[0141] Optional, text segmentation module 804, specifically used to: convert each segmented string into Arabic numerals;
[0142] If the text string does not contain a pre-defined first special character and a second special character, the Arabic numerals corresponding to each word segment are added together to obtain the amount 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 segmented strings before the first special character to obtain a first sum; add the numerals corresponding to the segmented strings after the first special character to obtain a second sum;
[0144] The product of the first sum and the value corresponding to the first special character is added to the second sum to obtain the amount 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 segments before the second special character to obtain a third sum; add the numerals corresponding to the word segments after the second special character and before the first special character to obtain a fourth sum; and add the numerals corresponding to the word segments after the first special character to obtain a fifth sum.
[0146] 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 are added together to obtain the amount corresponding to the current amount text.
[0147] The text processing apparatus provided in this embodiment of the invention can execute the text processing method provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects for executing the method. Content not described in detail in this embodiment can be referred to the description in any method embodiment of the invention.
[0148] Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention, with reference to... Figure 9 , Figure 9 The electronic device 12 shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments of this application. Figure 9 As shown, the electronic device 12 is represented 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, system memory 28, and bus 18 connecting different system components (including system memory 28 and processing unit 16).
[0149] Bus 18 represents one or more of several bus architectures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the various bus architectures. For example, these architectures include, but are not limited to, the Industry Standard Architecture (ISA) bus, the Micro Channel Architecture (MAC) bus, the Enhanced ISA bus, the Video Electronics Standards Association (VESA) local bus, and the Peripheral Component Interconnect (PCI) bus.
[0150] Electronic device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by electronic device 12, including volatile and non-volatile media, removable and non-removable media.
[0151] 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. Electronic device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, storage system 34 may be used to read and write non-removable, non-volatile magnetic media (… Figure 9 Not shown; usually referred to as a "hard drive"). Although Figure 9Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk") and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 18 via one or more data media interfaces. Memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the embodiments of this application.
[0152] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in memory 28. Such program modules 42 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. Program modules 42 typically perform the functions and / or methods described in the embodiments of this application.
[0153] Electronic device 12 can also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), and with one or more devices that enable a user to interact with electronic device 12, and / or with any device that enables electronic device 12 to communicate with one or more other computing devices (e.g., network card, modem, etc.). This communication can be performed via input / output (I / O) interface 22. Furthermore, electronic device 12 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 20. As shown, network adapter 20 communicates with other modules of electronic device 12 via bus 18. It should be understood that, although... Figure 9 As not shown, other hardware and / or software modules may be used in conjunction with 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 programs stored in the system memory 28, such as implementing a text processing method provided in this embodiment of the invention: acquiring text to be processed and classifying 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; extracting monetary text from the text to be processed according to the text type to obtain at least one monetary text of the text to be processed; performing standardization detection on the current monetary text based on a pre-set standardization detection rule for each monetary text of the at least one monetary text to obtain the standardization detection result of the current monetary text; wherein the standardization detection result is standard text or non-standard text; if the current monetary text is standard text, performing string segmentation on the text string of the current monetary text according to a pre-established tree-shaped monetary dictionary to obtain each word string corresponding to the text string, and obtaining the monetary number corresponding to the current monetary text based on each word string; if the current monetary text is non-standard text, performing standardization processing on the current monetary text based on the standardization detection result, and obtaining the monetary number corresponding to the current monetary text based on the standardization processing result.
[0155] This invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements a text processing method as provided in all embodiments of this invention: acquiring text to be processed and classifying the text to be processed to obtain a text type; the text type is regular text or irregular text; extracting monetary text from the text to be processed according to the text type to obtain at least one monetary text; performing a standardization detection on the current monetary text based on a pre-set standardization detection rule for each monetary text of the at least one monetary text to obtain a standardization detection result for the current monetary text; wherein the standardization detection result is either standard text or non-standard text; if the current monetary text is standard text, performing string segmentation on the text string of the current monetary text according to a pre-established tree-shaped monetary dictionary to obtain each word string corresponding to the text string, and obtaining the monetary number corresponding to the current monetary text based on each word string; if the current monetary text is non-standard text, performing standardization processing on the current monetary text based on the standardization detection result, and obtaining the monetary number corresponding to the current monetary text based on the standardization processing result. A computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. A computer-readable storage medium can be, for example, but not limited to, an electronic device, apparatus, or device that is electrical, magnetic, optical, electromagnetic, infrared, or semiconductor, or any combination thereof. More specific examples (a non-exhaustive list) of a computer-readable storage medium include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an electronic device, apparatus, or device that can be executed.
[0156] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, capable of sending, propagating, or transmitting programs for use by or in conjunction with an electronic device, apparatus, or device that executes instructions.
[0157] Program code contained on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.
[0158] Computer program code for performing the operations of this invention can be written in one or more programming languages or a combination thereof. Programming languages include object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as C or similar languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0159] This invention also provides a computer program product, including a computer program that, when executed by a processor, implements the text processing method provided in any embodiment of this application.
[0160] In implementing the computer program product, computer program code for performing the operations of this invention can be written in one or more programming languages or a combination thereof. Programming languages include object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as C or similar languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0161] Note that the above description only outlines preferred embodiments of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of the present invention, the scope of which is determined by the scope of the appended claims.
Claims
1. A text processing method, characterized in that, include: Obtain the text to be processed and classify it to obtain the text type of the text to be processed; the text type is regular text or irregular text. Based on the text type, extract the monetary text from the text to be processed to obtain at least one monetary text from the text to be processed; For each of the at least one monetary texts, a standardization detection is performed on the current monetary text based on a pre-defined standardization detection rule to obtain a standardization detection result for the current monetary text; wherein, the standardization detection result is either standard text or non-standard text; If the current amount text is the standard text, the text string of the current amount text is split into strings according to the pre-established tree-shaped amount dictionary to obtain each word string corresponding to the text string, and the amount number corresponding to the current amount text is obtained based on each word string; If the current amount text is non-standard text, the current amount text is standardized based on the standardization detection result, and the amount number corresponding to the current amount text is obtained based on the standardization result; The step of extracting monetary text from the text to be processed according to the text type to obtain at least one monetary text from the text to be processed includes: 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 the preset semantic analysis rules to obtain at least one monetary text of the text to be processed; If the text type of the text to be processed is the rule text, perform monetary text segmentation on the text to be processed according to the preset monetary keywords, and obtain at least one monetary text of the text to be processed based on the monetary text segmentation result; The process of performing standardization detection on the current amount text based on pre-defined standardization detection rules to obtain the standardization detection result of the current amount text includes: 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 the standard unit character, determine the standardization detection result of the current amount text as the first non-standard text. If the current number sequence of the current amount text is a Chinese number sequence; Determine whether there are at least two identical pre-defined Chinese numeric unit characters in the current number sequence of the current amount text. If there are at least two identical Chinese numeric unit characters in the current number sequence, determine that the standardization detection result of the current amount text is the second non-standard text. Determine whether there are at least two consecutive pre-defined Chinese numeric characters in the current number sequence. If there are at least two consecutive pre-defined Chinese numeric characters in the current number sequence, determine that the standardization detection result of the current amount text is the third non-standard text.
2. The method according to claim 1, characterized in that, The text to be processed is classified to obtain its text type, including: The data source of the text to be processed is determined based on 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 types of each pre-determined data source.
3. The method according to claim 1, characterized in that, 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 pre-set semantic analysis rules to obtain at least one monetary text of the text to be processed, including: 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 each preset unit character; For each unit character in the text to be processed, extract the numerical sequence that is adjacent to and precedes the current unit character in the text to be processed; the numerical sequence includes Chinese numeral sequences or Arabic numeral sequences. The string composed of the number sequence and the current unit character is determined as the current amount text.
4. The method according to claim 1, characterized in that, Based on the standardized detection results, the current amount text is standardized, and the corresponding amount number is obtained based on the standardized processing result, including: 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 the pre-established special unit character conversion table; If a special unit character that is the same as 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 corresponding to the current amount text is obtained based on the current number sequence of the current amount text and the current standard unit character.
5. The method according to claim 1, characterized in that, Based on the standardized detection results, the current amount text is standardized, and the corresponding amount number is obtained based on the standardized processing result, including: 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 number sequence to obtain a Chinese unit sequence; If there are two identical and adjacent Chinese numeric unit characters in the Chinese unit sequence, then 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; The character preceding the target Chinese unit is used as the starting character. 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. The amount number corresponding to the current amount text is determined based on the standard amount text.
6. The method according to claim 5, characterized in that, The method further includes: If there are at least two identical but non-adjacent Chinese numeric unit characters in the Chinese unit sequence, the last character of the Chinese unit sequence shall be taken as the current Chinese numeric unit character. If the value of the preceding Chinese numeral unit character is greater than the value of the current Chinese numeral unit character, then the preceding Chinese numeral unit character is determined as the current Chinese numeral unit character, until the value of the preceding Chinese numeral unit character is no greater than the value of the current Chinese numeral unit character, then the current Chinese numeral unit character is determined as the target Chinese numeral unit.
7. The method according to claim 1, characterized in that, Based on the standardized detection results, the current amount text is standardized, and the corresponding amount number is obtained based on the standardized processing result, including: If the current amount text is the third non-standard text, and the current number sequence only includes the at least two consecutive Chinese numeral characters, then each Chinese numeral character is converted into Arabic numerals, and the Arabic numerals are combined to obtain the target number sequence; The amount corresponding to the current amount text is determined based on the target number sequence and the unit character of the current amount text.
8. The method according to claim 1, characterized in that, The tree-structured monetary dictionary includes a root node and a five-level branching structure. The first level of branching includes a first branch node, the second level includes a second branch node and a second leaf node, the third level includes a third branch node and a third leaf node, the fourth level includes a fourth branch node and a fourth leaf node, and the fifth level includes a fifth leaf node. Each first branch node is connected to the root node, and each first branch node is connected to either a second branch node or a second leaf node. Each second branch node is connected to either a third branch node or a third leaf node. Each third branch node is connected to either a fourth branch node or a fourth leaf node. Each fourth branch node is connected to a fifth leaf node.
9. The method according to claim 8, characterized in that, Each node of the first branch node is a simplified Chinese numeric character, a Chinese uppercase numeric 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.
10. The method according to claim 1, characterized in that, Based on the segmented strings, the amount corresponding to the preceding amount text is obtained, including: Convert each word segment into Arabic numerals; If the text string does not contain a pre-defined first special character and a second special character, the Arabic numerals corresponding to each word segment are added together to obtain the amount corresponding to the current amount text.
11. The method according to claim 10, characterized in that, The method further includes: 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 segments before the first special character to obtain the first sum; add the numbers corresponding to the word segments after the first special character to obtain the second sum; The product of the first sum and the value corresponding to the first special character is added to the second sum to obtain the amount corresponding to the current amount text.
12. The method according to claim 10, characterized in that, The method further includes: If the text string includes the first special character and the second special character, add the Arabic numerals corresponding to the word segment strings before the second special character to get the third sum; add the numerals corresponding to the word segment strings after the second special character and before the first special character to get the fourth sum; add the numerals corresponding to the word segment strings after the first special character to get the fifth sum. 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 are added together to obtain the amount corresponding to the current amount text.
13. A text processing device, characterized in that, include: The 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; The text extraction module is used to extract monetary text from the text to be processed according to the text type, so as to obtain at least one monetary text from the text to be processed. The text detection module is used to perform standardization detection on the current amount text based on a pre-set standardization detection rule for each amount text of the at least one amount text, and obtain the standardization detection result of the current amount text; wherein, the standardization detection result is standard text or non-standard text; The text segmentation module is used to, if the current amount text is the standard text, perform string segmentation on the text string of the current amount text according to the pre-established tree-shaped amount dictionary to obtain each word string corresponding to the text string, and obtain the amount number corresponding to the current amount text based on each word string; The text processing module is used to, if the current amount text is non-standard text, perform standardization processing on the current amount text based on the standardization detection result, and obtain the amount number corresponding to the current amount text based on the standardization processing result; The text extraction module is specifically used for: 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 the preset semantic analysis rules to obtain at least one monetary text of the text to be processed; If the text type of the text to be processed is the rule text, perform monetary text segmentation on the text to be processed according to the preset monetary keywords, and obtain at least one monetary text of the text to be processed based on the monetary text segmentation result; The text detection module is specifically used for: 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 the standard unit character, determine the standardization detection result of the current amount text as the first non-standard text. If the current number sequence of the current amount text is a Chinese number sequence; Determine whether there are at least two identical pre-defined Chinese numeric unit characters in the current number sequence of the current amount text. If there are at least two identical Chinese numeric unit characters in the current number sequence, determine that the standardization detection result of the current amount text is the second non-standard text. Determine whether there are at least two consecutive pre-defined Chinese numeric characters in the current number sequence. If there are at least two consecutive pre-defined Chinese numeric characters in the current number sequence, determine that the standardization detection result of the current amount text is the third non-standard text.
14. An electronic device, characterized in that, The invention includes a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor, when executing the computer program, implements a text processing method as described in any one of claims 1-12.
15. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the program implements a text processing method as described in any one of claims 1-12.
16. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements a text processing method as described in any one of claims 1-12.
Citation Information
Patent Citations
Method for extracting amount information, terminal device and medium
CN108984500A
Method, device and equipment for correcting amount data, storage medium and product
CN116306511A